コード例 #1
0
        public static DefinitionSpan ToDefinition(CodexSemanticStore store, BoundSourceFileBuilder builder, CodexSpan span)
        {
            if ((span.ReferenceKind.IsValid && !string.Equals(nameof(ReferenceKind.Definition), store.ReferenceKinds[span.ReferenceKind].Name,
                                                              StringComparison.OrdinalIgnoreCase)) || !span.Symbol.IsValid)
            {
                return(null);
            }

            var      symbol   = store.Symbols[span.Symbol];
            SymbolId symbolId = GetSpanSymbolId(symbol);

            var projectId = symbol.Project.IsValid ? store.Projects.Get(symbol.Project).Name : builder.ProjectId;

            return(new DefinitionSpan()
            {
                Start = span.Start,
                Length = span.Length,
                Definition = new DefinitionSymbol()
                {
                    Id = symbolId,
                    ShortName = symbol.ShortName,
                    DisplayName = symbol.DisplayName,
                    ContainerQualifiedName = symbol.ContainerQualifiedName,
                    SymbolDepth = symbol.SymbolDepth,
                    ReferenceKind = nameof(ReferenceKind.Definition),
                    Kind = symbol.Kind,
                    ProjectId = projectId,
                },
            });
        }
コード例 #2
0
        public static ReferenceSpan ToReference(CodexSemanticStore store, BoundSourceFileBuilder builder, CodexSpan span)
        {
            if (!span.ReferenceKind.IsValid || !span.Symbol.IsValid)
            {
                return(null);
            }

            var      symbol   = store.Symbols[span.Symbol];
            SymbolId symbolId = GetSpanSymbolId(symbol);

            var projectId = symbol.Project.IsValid ? store.Projects.Get(symbol.Project).Name : builder.ProjectId;

            return(new ReferenceSpan()
            {
                Start = span.Start,
                Length = span.Length,
                Reference = new ReferenceSymbol()
                {
                    Id = symbolId,
                    ReferenceKind = store.ReferenceKinds[span.ReferenceKind].Name,
                    Kind = "symbol",
                    ProjectId = projectId,
                },
            });
        }
コード例 #3
0
        public static ClassificationSpan ToClassification(CodexSemanticStore store, CodexSpan span)
        {
            if (!span.Classification.IsValid && !span.Symbol.IsValid)
            {
                return(null);
            }

            return(new ClassificationSpan()
            {
                Start = span.Start,
                Length = span.Length,
                LocalGroupId = span.LocalId.IsValid ? span.LocalId.Id + 1 : 0,
                Classification = span.Classification.IsValid ? store.Classifications[span.Classification].Name : "text"
            });
        }
コード例 #4
0
        public override void Initialize(Repo repo)
        {
            var dd = new Dictionary <string, RepoProject>();

            foreach (var semanticDataDirectory in semanticDataDirectories)
            {
                var store = new CodexSemanticStore(semanticDataDirectory);
                store.Load();

                foreach (var project in store.Projects.List)
                {
                    var repoProject = new RepoProject(project.Name, repo)
                    {
                        ProjectDirectory = project.Directory,
                        // $TODO;
                        //ProjectFile = projectFile
                    };

                    dd.Add(project.Name, repoProject);

                    repo.Projects.Add(repoProject);
                }

                foreach (var file in store.Files.List)
                {
                    if (!m_fileToStoreMap.ContainsKey(file.Path))
                    {
                        RepoFile repoFile;
                        if (!repo.FilesByPath.TryGetValue(file.Path, out repoFile))
                        {
                            RepoProject project;
                            if (!dd.TryGetValue(store.Projects[file.Project].Name, out project))
                            {
                                project = repo.DefaultRepoProject;
                            }

                            repoFile = project.AddFile(file.Path);
                        }

                        m_fileToStoreMap[repoFile.RepoRelativePath] = file;
                    }
                }
            }
        }