コード例 #1
0
        void OnHaxeCompleteResultHandler(HaxeComplete hc, List <HaxePositionResult> result, HaxeCompleteStatus status)
        {
            var results = new FRResults();

            switch (status)
            {
            case HaxeCompleteStatus.ERROR:
                TraceManager.AddAsync(hc.Errors, -3);
                break;

            case HaxeCompleteStatus.USAGE:
                if (!IgnoreDeclarationSource)
                {
                    var sci  = ASContext.CurSciControl;
                    var path = sci.FileName;
                    if (!results.ContainsKey(path))
                    {
                        results.Add(path, new List <SearchMatch>());
                    }
                    var index     = hc.Expr.PositionExpression;
                    var line      = sci.LineFromPosition(index);
                    var lineStart = sci.PositionFromLine(line);
                    var lineEnd   = sci.LineEndPosition(line);
                    var lineText  = sci.GetLine(line);
                    var value     = hc.Expr.Value;
                    results[path].Add(new SearchMatch
                    {
                        Column    = index - lineStart,
                        Index     = index,
                        Length    = value.Length,
                        Line      = line + 1,
                        LineStart = lineStart,
                        LineEnd   = lineEnd,
                        LineText  = lineText,
                        Value     = value
                    });
                }
                foreach (var it in result)
                {
                    var path = it.Path;
                    if (!results.ContainsKey(path))
                    {
                        results.Add(path, new List <SearchMatch>());
                    }
                    var matches   = results[path];
                    var sci       = AssociatedDocumentHelper.LoadDocument(path).SciControl;
                    var line      = it.LineStart - 1;
                    var lineStart = sci.PositionFromLine(line);
                    var lineEnd   = sci.LineEndPosition(line);
                    var lineText  = sci.GetLine(line);
                    var value     = lineText.Substring(it.CharacterStart, it.CharacterEnd - it.CharacterStart);
                    matches.Add(new SearchMatch
                    {
                        Column    = it.CharacterStart,
                        Index     = lineStart + it.CharacterStart,
                        Length    = value.Length,
                        Line      = line + 1,
                        LineStart = lineStart,
                        LineEnd   = lineEnd,
                        LineText  = lineText,
                        Value     = value
                    });
                }
                break;
            }
            FindFinished(results);
        }
コード例 #2
0
        void AddDiagnosticsResults(List <LintingResult> list, HaxeCompleteStatus status, List <HaxeDiagnosticsResult> results, HaxeComplete hc)
        {
            if (status == HaxeCompleteStatus.DIAGNOSTICS && results != null)
            {
                foreach (var res in results)
                {
                    var range = res.Range ?? res.Args.Range;

                    var result = new LintingResult
                    {
                        File      = range.Path,
                        FirstChar = range.CharacterStart,
                        Length    = range.CharacterEnd - range.CharacterStart,
                        Line      = range.LineStart + 1,
                    };

                    switch (res.Severity)
                    {
                    case HaxeDiagnosticsSeverity.INFO:
                        result.Severity = LintingSeverity.Info;
                        break;

                    case HaxeDiagnosticsSeverity.ERROR:
                        result.Severity = LintingSeverity.Error;
                        break;

                    case HaxeDiagnosticsSeverity.WARNING:
                        result.Severity = LintingSeverity.Warning;
                        break;

                    default:
                        continue;
                    }

                    switch (res.Kind)
                    {
                    case HaxeDiagnosticsKind.UnusedImport:
                        result.Description = TextHelper.GetString("Info.UnusedImport");
                        break;

                    case HaxeDiagnosticsKind.UnresolvedIdentifier:
                        result.Description = TextHelper.GetString("Info.UnresolvedIdentifier");
                        break;

                    case HaxeDiagnosticsKind.CompilerError:
                    case HaxeDiagnosticsKind.RemovableCode:
                        result.Description = res.Args.Description;
                        break;

                    default:     //in case new kinds are added in new compiler versions
                        continue;
                    }

                    list.Add(result);
                }
            }
            else if (status == HaxeCompleteStatus.ERROR)
            {
                PluginBase.RunAsync(() =>
                {
                    TraceManager.Add(hc.Errors, (int)TraceType.Error);
                });
            }
        }