Beispiel #1
0
        public SourceFileRenderer(BoundSourceFile sourceFile, string projectId)
        {
            Contract.Requires(sourceFile != null);

            _sourceFile    = sourceFile;
            this.projectId = projectId;
        }
        public override Task UploadAsync(IRepoFile repoFile, BoundSourceFile boundSourceFile)
        {
            if (RepoUrlSelector != null && repoFile.RepoRelativePath != null)
            {
                boundSourceFile.SourceFile.Info.WebAddress = RepoUrlSelector(repoFile.RepoRelativePath);
            }

            return(base.UploadAsync(repoFile, boundSourceFile));
        }
Beispiel #3
0
        public static ListSegment <ReferenceSpan> FindOverlappingReferenceSpans(this BoundSourceFile boundSourceFile, Range span)
        {
            if (boundSourceFile.References == null)
            {
                return(new ListSegment <ReferenceSpan>(CollectionUtilities.Empty <ReferenceSpan> .List));
            }

            return(boundSourceFile.References.GetRange(span, CompareSpanMin, CompareSpanMax));
        }
Beispiel #4
0
 public static SourceFileModel FromObjectModel(BoundSourceFile boundSourceFile)
 {
     return(new SourceFileModel
     {
         Uid = boundSourceFile.Uid,
         Content = boundSourceFile.SourceFile.GetContentsAsync().Result,
         Language = boundSourceFile.SourceFile.Info.Language,
         Path = boundSourceFile.SourceFile.Info.Path,
         ExcludeFromSearch = boundSourceFile.ExcludeFromSearch,
         RepoRelativePath = boundSourceFile.SourceFile.Info.RepoRelativePath,
         WebAddress = boundSourceFile.SourceFile.Info.WebAddress,
         ProjectId = boundSourceFile.ProjectId,
         Classifications = FromObjectModel(boundSourceFile.ClassificationSpans),
         Definitions = FromObjectModel(boundSourceFile.Definitions),
         References = new ReferenceListModel(boundSourceFile.References),
         SearchReferencesSource = FromObjectModel(boundSourceFile.References),
         Properties = boundSourceFile.SourceFile.Info.Properties
     });
 }
Beispiel #5
0
 public async Task UploadAsync(IRepoFile repoFile, BoundSourceFile boundSourceFile)
 {
     await Provider.AddSourcesToIndexAsync(repoFile.Repo.TargetIndex, new[] { ModelConverter.FromObjectModel(boundSourceFile) });
 }
 public DocumentOutlineRenderer(string projectId, BoundSourceFile boundSourceFile)
 {
     this.projectId       = projectId;
     this.boundSourceFile = boundSourceFile;
 }
 public Task UploadAsync(IRepoFile repoFile, BoundSourceFile boundSourceFile)
 {
     return(Task.FromResult(true));
 }
 public virtual Task UploadAsync(IRepoFile repoFile, BoundSourceFile boundSourceFile)
 {
     return(analysisTarget.UploadAsync(repoFile, boundSourceFile));
 }
 public void ReportDocument(BoundSourceFile boundSourceFile, RepoFile file)
 {
     foreach (var reference in boundSourceFile.References)
     {
     }
 }
        protected static void UploadSourceFile(AnalysisServices services, RepoFile file, BoundSourceFile boundSourceFile)
        {
            if (file.IsSingleton)
            {
                boundSourceFile.MakeSingleton();
            }

            services.TaskDispatcher.QueueInvoke(() =>
            {
                int uploadCount = Interlocked.Increment(ref file.PrimaryProject.Repo.UploadCount);
                file.PrimaryProject.Repo.AnalysisServices.Logger.WriteLine($"Uploading source: '{boundSourceFile.ProjectId}::{boundSourceFile.SourceFile.Info.Path}' ({uploadCount} of {file.PrimaryProject.Repo.FileCount})");
                return(services.AnalysisTarget.UploadAsync(
                           file,
                           boundSourceFile));
            },
                                                TaskType.Upload);
        }
Beispiel #11
0
        public async Task Populate(BoundSourceFile boundSourceFile)
        {
            contents = await boundSourceFile.SourceFile.GetContentsAsync();

            repoRelativePath = boundSourceFile.SourceFile.Info.RepoRelativePath;
            webLink          = boundSourceFile.SourceFile.Info.WebAddress;

            segmentLength = contents.Length;
            var segment = new SegmentModel();

            segments.Add(segment);

            classifications.AddRange(boundSourceFile.ClassificationSpans.Select(classification =>
            {
                return(new ClassificationSpan()
                {
                    name = SourceFileRenderer.MapClassificationToCssClass(classification.Classification),
                    position = classification.Start,
                    length = classification.Length
                });
            }).Where(span => !string.IsNullOrEmpty(span.name)));

            documentSymbols.AddRange(boundSourceFile.Definitions.Select(definition =>
            {
                return(new SymbolInformation()
                {
                    name = definition.Definition.ShortName,
                    containerName = definition.Definition.ContainerQualifiedName,
                    symbolKind = definition.Definition.Kind,
                    span = new Span()
                    {
                        position = definition.Start,
                        length = definition.Length
                    }
                });
            }));

            foreach (var reference in boundSourceFile.References)
            {
                if (reference.Reference.IsImplicitlyDeclared)
                {
                    continue;
                }

                var symbolSpan = new SymbolSpan()
                {
                    symbol    = reference.Reference.Id.Value,
                    projectId = reference.Reference.ProjectId,
                    span      = new Span()
                    {
                        position = reference.Start,
                        length   = reference.Length
                    }
                };

                if (reference.Reference.ReferenceKind == nameof(ReferenceKind.Definition))
                {
                    segment.definitions.Add(symbolSpan);
                }
                else
                {
                    segment.references.Add(symbolSpan);
                }
            }
        }