2
// PageInfoVisitor.cs: Collects information about the document from ASP.NET
3
// document tree, for code completion and other services.
6
// Michael Hutchinson <m.j.hutchinson@gmail.com>
8
// Copyright (C) 2006 Michael Hutchinson
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:
21
// The above copyright notice and this permission notice shall be
22
// included in all copies or substantial portions of the Software.
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.
34
using MonoDevelop.AspNet.Parser.Dom;
35
using MonoDevelop.AspNet;
37
namespace MonoDevelop.AspNet.Parser
39
public class PageInfoVisitor : Visitor
43
public PageInfoVisitor (PageInfo info)
48
public override void Visit (DirectiveNode node)
50
if (info.Subtype == WebSubtype.None)
51
info.SetSubtypeFromDirective (node.Name);
55
if (info.Subtype != WebSubtype.WebForm && info.Subtype != WebSubtype.MasterPage
56
&& info.Subtype != WebSubtype.WebControl)
59
info.InheritedClass = node.Attributes ["inherits"] as string;
60
if (info.InheritedClass == null)
61
info.InheritedClass = node.Attributes ["class"] as string;
63
info.CodeBehindFile = node.Attributes ["codebehind"] as string;
64
info.Language = node.Attributes ["language"] as string;
65
info.CodeFile = node.Attributes ["codefile"] as string;
68
public override void Visit (TextNode node)
70
int start = node.Text.IndexOf ("<!DOCTYPE");
73
int end = node.Text.IndexOf (">", start);
74
info.DocType = node.Text.Substring (start, end - start + 1);
79
public override void Visit (TagNode node)
81
//as soon as tags are declared, doctypes and the page directive must been set
86
public PageInfo Info {
90
public override string ToString ()
92
return info.ToString ();