Esempio n. 1
0
 public void ShowParseErrors(ParserSyntaxError error)
 {
     listBoxFiles.Items.Add(Path.GetFileName(error.FileName));
     ShowParseError(error);
     this.TopMost = true;
     this.ShowDialog(this.ParentForm);
 }
Esempio n. 2
0
 public FileParseErrorArgs(ParserSyntaxError parseError, FileVersion fileVersion, IFileInformation fileInfo)
 {
     this.parseError = parseError;
     this.fileVersion = fileVersion;
     this.fileInfo = fileInfo;
 }
        private void AddErrorToToolWindow(ParserSyntaxError error)
        {
            Node node = new Node();

            errorTreeList.Nodes.Add(node);

            node.Cells.Add(new Cell());
            node.Cells.Add(new Cell());

            node.Text = error.LineNumber.ToString();
            node.Cells[1].Text = error.StartOffset.ToString();
            node.Cells[2].Text = error.ErrorMessage;

            errorToolWindow.Activate();
            errorToolWindow.State = ActiproSoftware.UIStudio.Dock.ToolWindowState.DockableInsideHost;
        }
 public void AddError(ParserSyntaxError parseError)
 {
     errors.Add(parseError);
 }
        private void MarkError(ParserSyntaxError error)
        {
            //DocumentPosition pos = ;
            int offset = error.StartOffset == -1 ? editor.Document.PositionToOffset(new DocumentPosition(error.LineNumber, 0)) : error.StartOffset;
            DynamicToken token = (DynamicToken)editor.Document.Tokens.GetTokenAtOffset(offset);
            SpanIndicatorLayer indicatorLayer = editor.Document.SpanIndicatorLayers[ErrorLayerKey];
            SpanIndicator indicator = new WaveLineSpanIndicator("ErrorIndicator", Color.Red);
            if (indicatorLayer == null)
            {
                indicatorLayer = new SpanIndicatorLayer(ErrorLayerKey, 1);
                editor.Document.SpanIndicatorLayers.Add(indicatorLayer);
            }
            int startOffset = Math.Min(token.StartOffset, indicatorLayer.Document.Length - 1);
            int length = Math.Max(token.Length, 1);

            if (startOffset < 0)
                return; // don't add indicators for errors without an offset.

            SpanIndicator[] indicators = indicatorLayer.GetIndicatorsForTextRange(new ActiproSoftware.SyntaxEditor.TextRange(startOffset, startOffset + length));
            foreach (SpanIndicator i in indicators)
            {
                // If there is already an error indicator on that word, don't add another one.
                if (i.TextRange.StartOffset == startOffset && i.TextRange.Length == length)
                    continue;
            }
            indicatorLayer.Add(indicator, startOffset, length);
        }
Esempio n. 6
0
        /// <summary>
        /// Creates a VB.Net CodeRoot from the result of the semantic parse.
        /// </summary>
        /// <param name="request">The <see cref="SemanticParserServiceRequest"/> that contains the parse results.</param>
        private void CreateCodeRoot(SemanticParserServiceRequest request)
        {
            try
            {
                if (request == null) throw new ArgumentNullException("request");

                // Reset the formatter.
                formatter = new VBCodeFormatter(document, formatSettings, controller);

                // Load the document outline
                CompilationUnit compilationUnit = request.SemanticParseData as CompilationUnit;
                if (compilationUnit == null)
                {
                    throw new InvalidOperationException(
                        "The Actipro parser did not return a CompilationUnit object. Unable to process this file.");
                }

                foreach (object obj in compilationUnit.SyntaxErrors)
                {
                    SyntaxError error = (SyntaxError)obj;
                    int lineNumber = document.OffsetToPosition(error.TextRange.StartOffset).Line;

                    ParserSyntaxError pse = new ParserSyntaxError(error.Message, error.TextRange.StartOffset,
                                                                  error.TextRange.Length, lineNumber, currentFilename, document.GetSubstring(error.TextRange));
                    syntaxErrors.Add(pse);
                }
                // Create region objects before handling AST.
                CreateRegions(compilationUnit);

                ProcessNode(compilationUnit, compilationUnit);

                //PostProcessComments();

                FixParentReferences();
            }
            catch (ParserException e)
            {
                exceptionThrown = e;
            }
            catch (Exception e)
            {
                exceptionThrown = new ParserException("An exception as thrown during parsing", e);
            }
        }
Esempio n. 7
0
 private void ShowParseError(ParserSyntaxError error)
 {
     this.Text = "Parse Error: " + error.Filename;
     label1.Text = string.Format("{0} could not be parsed. There seems to be a syntax error near line {1}, column {2}. Please fix the error before trying to parse again. If you believe the code is syntactically correct then please send a copy of the file to [email protected]", error.FileName, error.LineNumber, error.StartPos);
     SetSyntaxLanguage();
     syntaxEditor1.Text = error.OriginalText;
     MarkErrorWord(syntaxEditor1, error.LineNumber, error.StartPos, "Parse Error");
 }