~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/AspNetParser.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-09-10 16:54:48 UTC
  • mfrom: (19.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100910165448-0rybfk25zd4o9431
Tags: 2.4+dfsg-2
* debian/patches/inject_Mono.Debugger.Soft_source.patch,
  debian/patches/use_system_Mono.Debugger.Soft.patch,
  debian/control:
  + Build against system Soft Debugger, since we now have a new
    enough Mono to match MonoDevelop's required API

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
using MonoDevelop.Projects.Dom;
33
33
using MonoDevelop.Projects.Dom.Parser;
 
34
using MonoDevelop.AspNet.Parser.Dom;
 
35
using System.Collections.Generic;
 
36
using MonoDevelop.Core;
34
37
 
35
38
 
36
39
namespace MonoDevelop.AspNet.Parser
50
53
                
51
54
                public override ParsedDocument Parse (ProjectDom dom, string fileName, string fileContent)
52
55
                {
53
 
                        using (TextReader tr = new StringReader (fileContent)) {
54
 
                                Document doc = new Document (tr, null, fileName);
55
 
                                AspNetParsedDocument result = new AspNetParsedDocument (fileName) {
56
 
                                        PageInfo = new PageInfo (),
57
 
                                        Document = doc
58
 
                                };
59
 
                                
60
 
                                doc.RootNode.AcceptVisit (new PageInfoVisitor (result.PageInfo));
61
 
                                
62
 
                                foreach (ParserException pe in doc.ParseErrors)
63
 
                                        result.Add (new Error (
64
 
                                                pe.IsWarning? ErrorType.Warning : ErrorType.Error,
65
 
                                                pe.Line, pe.Column, pe.Message));
 
56
                        using (var tr = new StringReader (fileContent)) {
 
57
                                var info = new PageInfo ();
 
58
                                var rootNode = new RootNode ();
 
59
                                var errors = new List<Error> ();
 
60
                                
 
61
                                try {
 
62
                                        rootNode.Parse (fileName, tr);
 
63
                                } catch (Exception ex) {
 
64
                                        LoggingService.LogError ("Unhandled error parsing ASP.NET document '" + (fileName ?? "") + "'", ex);
 
65
                                        errors.Add (new Error (ErrorType.Error, 0, 0, "Unhandled error parsing ASP.NET document: " + ex.Message));
 
66
                                }
 
67
                                
 
68
                                
 
69
                                foreach (var pe in rootNode.ParseErrors)
 
70
                                        errors.Add (new Error (ErrorType.Error, pe.Location.BeginLine, pe.Location.BeginColumn, pe.Message));
 
71
                                
 
72
                                info.Populate (rootNode, errors);
 
73
                                
 
74
                                var type = AspNetAppProject.DetermineWebSubtype (fileName);
 
75
                                if (type != info.Subtype) {
 
76
                                        if (info.Subtype == WebSubtype.None) {
 
77
                                                errors.Add (new Error (ErrorType.Error, 1, 1, "File directive is missing"));
 
78
                                        } else {
 
79
                                                type = info.Subtype;
 
80
                                                errors.Add (new Error (ErrorType.Warning, 1, 1, "File directive does not match page extension"));
 
81
                                        }
 
82
                                }
 
83
                                
 
84
                                var result = new AspNetParsedDocument (fileName, type, rootNode, info);
 
85
                                result.Add (errors);
 
86
                                                                
 
87
                                /*
 
88
                                if (MonoDevelop.Core.LoggingService.IsLevelEnabled (MonoDevelop.Core.Logging.LogLevel.Debug)) {
 
89
                                        DebugStringVisitor dbg = new DebugStringVisitor ();
 
90
                                        rootNode.AcceptVisit (dbg);
 
91
                                        System.Text.StringBuilder sb = new System.Text.StringBuilder ();
 
92
                                        sb.AppendLine ("Parsed AspNet file:");
 
93
                                        sb.AppendLine (dbg.DebugString);
 
94
                                        if (errors.Count > 0) {
 
95
                                                sb.AppendLine ("Errors:");
 
96
                                                foreach (ParserException ex in errors)
 
97
                                                        sb.AppendLine (ex.ToString ());
 
98
                                        }
 
99
                                        MonoDevelop.Core.LoggingService.LogDebug (sb.ToString ());
 
100
                                }*/
66
101
                                
67
102
                                return result;
68
103
                        }
69
104
                }
 
105
                
 
106
                internal void AddError (ErrorType type, ILocation location, string message)
 
107
                {
 
108
                        
 
109
                }
 
110
                
 
111
                void Init (TextReader sr)
 
112
                {
 
113
                        
 
114
                        
 
115
                        
 
116
                }
70
117
        }
71
118
}