~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/addins/AspNetAddIn/MonoDevelop.AspNet.Parser/PageInfoVisitor.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
//
 
10
//
 
11
// This source code is licenced under The MIT License:
 
12
//
 
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.
 
31
//
 
32
 
 
33
using System;
 
34
using MonoDevelop.AspNet.Parser.Dom;
 
35
using MonoDevelop.AspNet;
 
36
 
 
37
namespace MonoDevelop.AspNet.Parser
 
38
{
 
39
        public class PageInfoVisitor : Visitor
 
40
        {
 
41
                PageInfo info;
 
42
                
 
43
                public PageInfoVisitor (PageInfo info)
 
44
                {
 
45
                        this.info = info;
 
46
                }
 
47
                
 
48
                public override void Visit (DirectiveNode node)
 
49
                {
 
50
                        if (info.Subtype == WebSubtype.None)
 
51
                                info.SetSubtypeFromDirective (node.Name);
 
52
                        else
 
53
                                return;
 
54
                        
 
55
                        if (info.Subtype != WebSubtype.WebForm && info.Subtype != WebSubtype.MasterPage
 
56
                            && info.Subtype != WebSubtype.WebControl)
 
57
                                return;
 
58
                        
 
59
                        info.InheritedClass = node.Attributes ["inherits"] as string;
 
60
                        if (info.InheritedClass == null)
 
61
                                info.InheritedClass = node.Attributes ["class"] as string;
 
62
                        
 
63
                        info.CodeBehindFile = node.Attributes ["codebehind"] as string;
 
64
                        info.Language = node.Attributes ["language"] as string;
 
65
                        info.CodeFile = node.Attributes ["codefile"] as string;
 
66
                }
 
67
                
 
68
                public override void Visit (TextNode node)
 
69
                {
 
70
                        int start = node.Text.IndexOf ("<!DOCTYPE");
 
71
                        if (start < 0)
 
72
                                return;
 
73
                        int end = node.Text.IndexOf (">", start);
 
74
                        info.DocType = node.Text.Substring (start, end - start + 1);
 
75
                        QuickExit = true;
 
76
                }
 
77
 
 
78
                
 
79
                public override void Visit (TagNode node)
 
80
                {
 
81
                        //as soon as tags are declared, doctypes and the page directive must been set
 
82
                        QuickExit = true;
 
83
                }
 
84
 
 
85
                
 
86
                public PageInfo Info {
 
87
                        get { return info; }
 
88
                }
 
89
                
 
90
                public override string ToString ()
 
91
                {
 
92
                        return info.ToString ();
 
93
                }
 
94
        }
 
95
}