* Makefile.am:
[monodevelop.git] / main / src / addins / AspNetAddIn / MonoDevelop.AspNet.Parser / PageInfoVisitor.cs
blob5fc6178c657852978b17fddb6249b7ffdf483529
1 //
2 // PageInfoVisitor.cs: Collects information about the document from ASP.NET
3 // document tree, for code completion and other services.
4 //
5 // Authors:
6 // Michael Hutchinson <m.j.hutchinson@gmail.com>
7 //
8 // Copyright (C) 2006 Michael Hutchinson
9 //
11 // This source code is licenced under The MIT License:
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System;
34 using MonoDevelop.AspNet.Parser.Dom;
35 using MonoDevelop.AspNet;
37 namespace MonoDevelop.AspNet.Parser
39 public class PageInfoVisitor : Visitor
41 PageInfo info;
43 public PageInfoVisitor (PageInfo info)
45 this.info = info;
48 public override void Visit (DirectiveNode node)
50 if (info.Subtype == WebSubtype.None) {
51 info.SetSubtypeFromDirective (node.Name);
53 else if (String.Compare (node.Name, "mastertype", StringComparison.OrdinalIgnoreCase) == 0)
55 info.MasterPageTypeName = node.Attributes["typename"] as string;
56 info.MasterPageTypeVPath = node.Attributes["virtualpath"] as string;
57 return;
59 else
60 return;
62 //after SetSubtypeFromDirective
63 if (info.Subtype != WebSubtype.WebForm && info.Subtype != WebSubtype.MasterPage
64 && info.Subtype != WebSubtype.WebControl)
65 return;
67 info.InheritedClass = node.Attributes ["inherits"] as string;
68 if (info.InheritedClass == null)
69 info.InheritedClass = node.Attributes ["class"] as string;
71 info.CodeBehindFile = node.Attributes ["codebehind"] as string;
72 info.Language = node.Attributes ["language"] as string;
73 info.CodeFile = node.Attributes ["codefile"] as string;
74 info.MasterPageFile = node.Attributes ["masterpagefile"] as string;
77 public override void Visit (TextNode node)
79 int start = node.Text.IndexOf ("<!DOCTYPE");
80 if (start < 0)
81 return;
82 int end = node.Text.IndexOf (">", start);
83 info.DocType = node.Text.Substring (start, end - start + 1);
84 QuickExit = true;
88 public override void Visit (TagNode node)
90 //as soon as tags are declared, doctypes and the page directive must been set
91 QuickExit = true;
95 public PageInfo Info {
96 get { return info; }
99 public override string ToString ()
101 return info.ToString ();