Ejemplo n.º 1
0
        public void ParseGothicSrc()
        {
            var AppDir       = AppDomain.CurrentDomain.BaseDirectory;
            var externals    = new Dictionary <Uri, ParseResult>();
            var buildInsPath = Path.Combine(AppDir, "DaedalusBuiltins");

            foreach (var builtIn in Directory.EnumerateFiles(buildInsPath, "*.d"))
            {
                var builtInUri   = new Uri(builtIn);
                var parsedResult = FastCompiler.Load(builtIn, true);
                externals[builtInUri] = parsedResult;
            }

            string srcPath      = @"A:\Spiele\Gothic II_Mods\_work\Data\Scripts\Content\Gothic.src";
            var    parseResults = FastCompiler.ParseSrc(srcPath, externals);
        }
Ejemplo n.º 2
0
        private PublishDiagnosticsParams ParseInternal(Uri uri, string text, bool detailed, CancellationToken cancellation)
        {
            var newUri    = new Uri(Uri.UnescapeDataString(uri.AbsoluteUri));
            var localPath = newUri.LocalPath;

            // Workaround: Skip externals. Too many wrong function definitions
            if (localPath.Contains("AI_Intern", StringComparison.OrdinalIgnoreCase) && localPath.EndsWith("Externals.d", StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            ParseResult parserResult = null;

            if (string.IsNullOrWhiteSpace(text))
            {
                parserResult = FastCompiler.Load(localPath, detailed, GetDocuments().Values);
            }
            else
            {
                parserResult = FastCompiler.Parse(text, newUri, detailed, GetDocuments().Values);
            }
            PublishDiagnosticsParams result = null;

            if (parserResult.SyntaxErrors.Count > 0)
            {
                result = new PublishDiagnosticsParams
                {
                    Uri         = newUri,
                    Diagnostics = new Container <Diagnostic>(parserResult.SyntaxErrors
                                                             .Select(x => new Diagnostic
                    {
                        Message = x.ErrorCode.Description,
                        Code    = x.ErrorCode.Code,
                        //Source = localPath,
                        Severity = DiagnosticSeverityFromSyntaxError(x),
                        Range    = new OmniSharp.Extensions.LanguageServer.Protocol.Models.Range(new Position(x.Line - 1, x.Column), new Position(x.Line - 1, x.Column)),
                    }))
                };
            }
            UpdateParseResult(uri, parserResult);
            return(result);
        }