Exemplo n.º 1
0
        public ICompilationUnit Parse(IProjectContent projectContent, string fileName, string fileContent)
        {
            //try
            {
                NRefactory.IParser p = null;

                ICompilationUnit cu = null;

                lock (obs)
                {
                    //using (NRefactory.IParser p = NRefactory.ParserFactory.CreateParser(NRefactory.SupportedLanguage.CSharp, new StringReader(fileContent)))

                    p = NRefactory.ParserFactory.CreateParser(NRefactory.SupportedLanguage.CSharp, new StringReader(fileContent));
                    {
                        cu = Parse(p, fileName, projectContent);
                    }
                }

                return(cu);
            }
            //catch (Exception ex)
            //{


            //}

            //finally
            //{


            //}
            //return null;
        }
Exemplo n.º 2
0
        ICompilationUnit Parse(NRefactory.IParser p, string fileName, IProjectContent projectContent)
        {
            p.Lexer.SpecialCommentTags = lexerTags;
            p.ParseMethodBodies        = false;
            p.Parse();
            lastErrors = p.Errors;
            Dom.NRefactoryResolver.NRefactoryASTConvertVisitor visitor = new Dom.NRefactoryResolver.NRefactoryASTConvertVisitor(projectContent);
            visitor.Specials = p.Lexer.SpecialTracker.CurrentSpecials;
            visitor.VisitCompilationUnit(p.CompilationUnit, null);
            visitor.Cu.FileName            = fileName;
            visitor.Cu.ErrorsDuringCompile = p.Errors.Count > 0;
            RetrieveRegions(visitor.Cu, p.Lexer.SpecialTracker);
            AddCommentTags(visitor.Cu, p.Lexer.TagComments);

            string rootNamespace = null;

            if (projectContent.Project != null)
            {
                rootNamespace = ((IProject)projectContent.Project).RootNamespace;
            }
            if (rootNamespace != null && rootNamespace.Length > 0)
            {
                foreach (IClass c in visitor.Cu.Classes)
                {
                    c.FullyQualifiedName = rootNamespace + "." + c.FullyQualifiedName;
                }
            }

            return(visitor.Cu);
        }
Exemplo n.º 3
0
 public ICompilationUnit Parse(IProjectContent projectContent, string fileName, string fileContent)
 {
     using (NRefactory.IParser p = NRefactory.ParserFactory.CreateParser(NRefactory.SupportedLanguage.VBNet, new StringReader(fileContent)))
     {
         return(Parse(p, fileName, projectContent));
     }
 }
Exemplo n.º 4
0
 private ICompilationUnit Parse(NRefactory.IParser p, string fileName, IProjectContent projectContent)
 {
     p.Lexer.SpecialCommentTags = _lexerTags;
     p.ParseMethodBodies        = true;
     p.Parse();
     _lastErrors = p.Errors;
     Dom.NRefactoryResolver.NRefactoryASTConvertVisitor visitor = new Dom.NRefactoryResolver.NRefactoryASTConvertVisitor(projectContent);
     visitor.Specials = p.Lexer.SpecialTracker.CurrentSpecials;
     visitor.VisitCompilationUnit(p.CompilationUnit, null);
     visitor.Cu.FileName            = fileName;
     visitor.Cu.ErrorsDuringCompile = p.Errors.Count > 0;
     RetrieveRegions(visitor.Cu, p.Lexer.SpecialTracker);
     AddCommentTags(visitor.Cu, p.Lexer.TagComments);
     return(visitor.Cu);
 }