void UploadParserError(Document doc, NRefactory.Parser.Errors e)
 {
     if (_winErrorList != null)
     {
         _winErrorList.ProjectErrors(doc, e);
     }
 }
Beispiel #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);
        }
Beispiel #3
0
        public void ProjectErrors(Document doc, NRefactory.Parser.Errors p)
        {
            ListViewItem lvItem;
            string       msg    = p.ErrorOutput.Trim();
            int          lineNo = (p.LineNo - 1);
            int          ColNo  = (p.ColumnNo - 1);

            string fileName = doc.FileName;

            lineNo = lineNo < 0 ? 0 : lineNo;
            ColNo  = ColNo < 0 ? 0 : ColNo;
            try
            {
                lvItem     = new ListViewItem(new string[] { "", "0", msg, fileName, lineNo.ToString(), ColNo.ToString() });
                lvItem.Tag = fileName + "-" + lineNo.ToString() + "-" + ColNo.ToString();
                foreach (ListViewItem lvExisting in lvErrorList.Items)
                {
                    if (lvExisting.Tag.ToString() == lvItem.Tag.ToString())
                    {
                        try
                        {
                            doc.HighlightRemove(Convert.ToInt32("0" + lvExisting.SubItems[4].Text), Convert.ToInt32("0" + lvExisting.SubItems[5].Text));
                        }
                        finally
                        {
                            lvExisting.Remove();
                        }
                    }
                    if (Convert.ToInt32("0" + lvExisting.SubItems[1].Text) == 0 && lvExisting.SubItems[3].Text == fileName) //Parser Errors
                    {
                        try
                        {
                            doc.HighlightRemove(Convert.ToInt32("0" + lvExisting.SubItems[4].Text), Convert.ToInt32("0" + lvExisting.SubItems[5].Text));
                        }
                        finally
                        {
                            lvExisting.Remove();
                        }
                    }
                }
                if (p.Count == 0)
                {
                    return;
                }
                doc.HighlightError(lineNo, ColNo, false, msg);
                lvItem.StateImageIndex = 3;
                lvErrorList.Items.Add(lvItem);
            }
            finally
            {
                UpdateSummary();
            }
        }
        void ParseContentThread(Object stateInfo)
        {
            object[] param            = (object[])stateInfo;
            object   sender           = param[0];
            ParseContentEventArgs e   = param[1] as ParseContentEventArgs;
            bool             IsOpened = (bool)param[2];
            ParseInformation pi       = Parser.ProjectParser.ParseProjectContents(e.FileName, e.Content, IsOpened);

            NRefactory.Parser.Errors errors = Parser.ProjectParser.LastParserErrors;
            Document doc = sender as Document;

            BeginInvoke(new MethodInvoker(delegate { UploadParserError(doc, errors); }));
        }
Beispiel #5
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);
 }
Beispiel #6
0
        public static ParseInformation ParseProjectContents(string fileName, string Content, bool IsOpened)
        {
            if (projContentInfo.ContainsKey(fileName) == false)
            {
                projContentInfo[fileName] = new ProjectContentItem(fileName, Content, IsOpened);
            }

            projContentInfo[fileName].Contents = Content;

            IParser parser = GetParser(fileName);

            if (parser == null)
            {
                return(null);
            }

            ICompilationUnit parserOutput = null;

            parserOutput    = parser.Parse(projectContent, fileName, Content);
            lastParserError = parser.LastErrors;

            if (projContentInfo.ContainsKey(fileName))
            {
                ParseInformation parseInformation = projContentInfo[fileName].ParsedContents;
                if (parseInformation == null)
                {
                    parseInformation = new ParseInformation();
                    projContentInfo[fileName].ParsedContents = parseInformation;
                }
                projectContent.UpdateCompilationUnit(parseInformation.MostRecentCompilationUnit, parserOutput, fileName);
            }
            else
            {
                projectContent.UpdateCompilationUnit(null, parserOutput, fileName);
            }

            return(UpdateParseInformation(parserOutput, fileName));
        }
Beispiel #7
0
        public static ParseInformation ParseProjectContents(string fileName, string Content, bool IsOpened)
        {
            //try
            //   {

            lock (s_obs)
            {
                if (s_projContentInfo == null)
                {
                    s_projContentInfo = new Dictionary <string, ProjectContentItem>();
                }

                if (s_projContentInfo.ContainsKey(fileName) == false)
                {
                    s_projContentInfo[fileName] = new ProjectContentItem(fileName, Content, IsOpened);
                }

                s_projContentInfo[fileName].Contents = Content;

                IParser parser = GetParser(fileName);
                if (parser == null)
                {
                    MessageBox.Show("Parser errors..");
                    return(null);
                }

                ICompilationUnit parserOutput = null;
                parserOutput = parser.Parse(s_projectContent, fileName, Content);

                if (parserOutput == null)
                {
                    MessageBox.Show("Parser errors..");
                    return(null);
                }

                s_lastParserError = parser.LastErrors;

                if (s_projContentInfo.ContainsKey(fileName))
                {
                    ParseInformation parseInformation = s_projContentInfo[fileName].ParsedContents;
                    if (parseInformation == null)
                    {
                        parseInformation = new ParseInformation();
                        s_projContentInfo[fileName].ParsedContents = parseInformation;
                    }
                    s_projectContent.UpdateCompilationUnit(parseInformation.MostRecentCompilationUnit, parserOutput, fileName);
                }
                else
                {
                    s_projectContent.UpdateCompilationUnit(null, parserOutput, fileName);
                }



                return(UpdateParseInformation(parserOutput, fileName));

                //   }
                //}
                //catch (Exception ex)
                //{

                //}
                //finally
                //{


                //}
                //return null;
            }
        }