protected override Task <ImmutableArray <Document> > DetermineDocumentsToSearchAsync(
            IMethodSymbol symbol,
            Project project,
            IImmutableSet <Document>?documents,
            FindReferencesSearchOptions options,
            CancellationToken cancellationToken)
        {
            return(FindDocumentsAsync(project, documents, async(d, c) =>
            {
                var index = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false);
                if (index.ContainsBaseConstructorInitializer)
                {
                    return true;
                }

                if (index.ProbablyContainsIdentifier(symbol.ContainingType.Name))
                {
                    if (index.ContainsThisConstructorInitializer)
                    {
                        return true;
                    }
                    else if (project.Language == LanguageNames.VisualBasic && index.ProbablyContainsIdentifier("New"))
                    {
                        // "New" can be explicitly accessed in xml doc comments to reference a constructor.
                        return true;
                    }
                }

                return false;
            }, cancellationToken));
        }
Ejemplo n.º 2
0
        protected override Task <ImmutableArray <Document> > DetermineDocumentsToSearchAsync(
            IMethodSymbol symbol,
            Project project,
            IImmutableSet <Document> documents,
            FindReferencesSearchOptions options,
            CancellationToken cancellationToken)
        {
            return(FindDocumentsAsync(project, documents, async(d, c) =>
            {
                var index = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false);
                if (index.ContainsBaseConstructorInitializer)
                {
                    return true;
                }

                if (index.ProbablyContainsIdentifier(symbol.ContainingType.Name))
                {
                    if (index.ContainsThisConstructorInitializer)
                    {
                        return true;
                    }
                }

                return false;
            }, cancellationToken));
        }
Ejemplo n.º 3
0
        public static async ValueTask <SyntaxTreeIndex> GetSyntaxTreeIndexAsync(this Document document, CancellationToken cancellationToken)
        {
            var result = await SyntaxTreeIndex.GetIndexAsync(document, loadOnly : false, cancellationToken).ConfigureAwait(false);

            Contract.ThrowIfNull(result);
            return(result);
        }
 private Task <ImmutableArray <Document> > FindDocumentWithElementAccessExpressionsAsync(
     Project project, IImmutableSet <Document> documents, CancellationToken cancellationToken)
 {
     return(FindDocumentsAsync(project, documents, async(d, c) =>
     {
         var info = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false);
         return info.ContainsElementAccessExpression;
     }, cancellationToken));
 }
 public void AddItem(SyntaxTreeIndex syntaxIndex)
 {
     foreach (var(receiverType, symbolInfoIndices) in syntaxIndex.ReceiverTypeNameToExtensionMethodMap)
     {
         foreach (var index in symbolInfoIndices)
         {
             _mapBuilder.Add(receiverType, syntaxIndex.DeclaredSymbolInfos[index]);
         }
     }
 }
Ejemplo n.º 6
0
            public override Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
            {
                if (!document.SupportsSyntaxTree)
                {
                    // Not a language we can produce indices for (i.e. TypeScript).  Bail immediately.
                    return(Task.CompletedTask);
                }

                return(SyntaxTreeIndex.PrecalculateAsync(document, cancellationToken));
            }
Ejemplo n.º 7
0
 /// <summary>
 /// Finds all the documents in the provided project that contain a global attribute in them.
 /// </summary>
 protected static Task <ImmutableArray <Document> > FindDocumentsWithGlobalAttributesAsync(
     Project project,
     IImmutableSet <Document>?documents,
     CancellationToken cancellationToken)
 {
     return(FindDocumentsAsync(project, documents, async(d, c) =>
     {
         var info = await SyntaxTreeIndex.GetRequiredIndexAsync(d, c).ConfigureAwait(false);
         return info.ContainsGlobalAttributes;
     }, cancellationToken));
 }
Ejemplo n.º 8
0
            public override Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
            {
                if (document.Project.Solution.Workspace.Kind != WorkspaceKind.RemoteWorkspace &&
                    document.Project.Solution.Workspace.Options.GetOption(SymbolFinderOptions.OutOfProcessAllowed))
                {
                    // if FAR feature is set to run on remote host, then we don't need to build inproc cache.
                    // remote host will build this cache in remote host.
                    return(SpecializedTasks.EmptyTask);
                }

                return(SyntaxTreeIndex.PrecalculateAsync(document, cancellationToken));
            }
            public override async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
            {
                if (!document.SupportsSyntaxTree)
                {
                    // Not a language we can produce indices for (i.e. TypeScript).  Bail immediately.
                    return;
                }

                await SyntaxTreeIndex.PrecalculateAsync(document, cancellationToken).ConfigureAwait(false);

                await TopLevelSyntaxTreeIndex.PrecalculateAsync(document, cancellationToken).ConfigureAwait(false);
            }
Ejemplo n.º 10
0
 protected Task <ImmutableArray <Document> > FindDocumentsAsync(
     Project project,
     IImmutableSet <Document> documents,
     PredefinedType predefinedType,
     CancellationToken cancellationToken)
 {
     return(FindDocumentsAsync(project, documents, async(d, c) =>
     {
         var info = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false);
         return info.ContainsPredefinedType(predefinedType);
     }, cancellationToken));
 }
        protected static Task<ImmutableArray<Document>> FindDocumentsAsync(
            Project project,
            IImmutableSet<Document>? documents,
            PredefinedOperator op,
            CancellationToken cancellationToken)
        {
            if (op == PredefinedOperator.None)
                return SpecializedTasks.EmptyImmutableArray<Document>();

            return FindDocumentsAsync(project, documents, async (d, c) =>
            {
                var info = await SyntaxTreeIndex.GetRequiredIndexAsync(d, c).ConfigureAwait(false);
                return info.ContainsPredefinedOperator(op);
            }, cancellationToken);
        }
                public void AddItem(SyntaxTreeIndex syntaxIndex)
                {
                    foreach (var(targetType, symbolInfoIndices) in syntaxIndex.SimpleExtensionMethodInfo)
                    {
                        foreach (var index in symbolInfoIndices)
                        {
                            _simpleItemBuilder.Add(targetType, syntaxIndex.DeclaredSymbolInfos[index]);
                        }
                    }

                    foreach (var index in syntaxIndex.ComplexExtensionMethodInfo)
                    {
                        _complexItemBuilder.Add(syntaxIndex.DeclaredSymbolInfos[index]);
                    }
                }
Ejemplo n.º 13
0
            public override Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
            {
                if (!document.SupportsSyntaxTree)
                {
                    // Not a language we can produce indices for (i.e. TypeScript).  Bail immediately.
                    return(Task.CompletedTask);
                }

                if (!RemoteFeatureOptions.ShouldComputeIndex(document.Project.Solution.Workspace))
                {
                    return(Task.CompletedTask);
                }

                return(SyntaxTreeIndex.PrecalculateAsync(document, cancellationToken));
            }
Ejemplo n.º 14
0
        /// <summary>
        /// Finds all the documents in the provided project that contain the requested string
        /// values
        /// </summary>
        protected Task <ImmutableArray <Document> > FindDocumentsAsync(Project project, IImmutableSet <Document> documents, CancellationToken cancellationToken, params string[] values)
        {
            return(FindDocumentsAsync(project, documents, async(d, c) =>
            {
                var info = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false);
                foreach (var value in values)
                {
                    if (!info.ProbablyContainsIdentifier(value))
                    {
                        return false;
                    }
                }

                return true;
            }, cancellationToken));
        }
Ejemplo n.º 15
0
        protected async Task <ImmutableArray <Document> > FindDocumentsAsync(
            Project project,
            IImmutableSet <Document> documents,
            PredefinedOperator op,
            CancellationToken cancellationToken)
        {
            if (op == PredefinedOperator.None)
            {
                return(ImmutableArray <Document> .Empty);
            }

            return(await FindDocumentsAsync(project, documents, async (d, c) =>
            {
                var info = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false);
                return info.ContainsPredefinedOperator(op);
            }, cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 16
0
        protected static async Task <ImmutableArray <string> > GetAllMatchingGlobalAliasNamesAsync(
            Project project, string name, int arity, CancellationToken cancellationToken)
        {
            using var result = TemporaryArray <string> .Empty;

            foreach (var document in await project.GetAllRegularAndSourceGeneratedDocumentsAsync(cancellationToken).ConfigureAwait(false))
            {
                var index = await SyntaxTreeIndex.GetRequiredIndexAsync(document, cancellationToken).ConfigureAwait(false);

                foreach (var alias in index.GetGlobalAliases(name, arity))
                {
                    result.Add(alias);
                }
            }

            return(result.ToImmutableAndClear());
        }
Ejemplo n.º 17
0
        public async Task RunSerialIndexing()
        {
            Console.WriteLine("start profiling now");
            // Thread.Sleep(10000);
            Console.WriteLine("Starting serial indexing");
            var start = DateTime.Now;

            foreach (var project in _workspace.CurrentSolution.Projects)
            {
                foreach (var document in project.Documents)
                {
                    // await WalkTree(document);
                    await SyntaxTreeIndex.PrecalculateAsync(document, default).ConfigureAwait(false);
                }
            }
            Console.WriteLine("Serial: " + (DateTime.Now - start));
            Console.ReadLine();
        }
Ejemplo n.º 18
0
            private async Task AddDocumentsWithPotentialConflicts(IEnumerable <Document> documents)
            {
                try
                {
                    foreach (var document in documents)
                    {
                        if (_documentsIdsToBeCheckedForConflict.Contains(document.Id))
                        {
                            continue;
                        }

                        var info = await SyntaxTreeIndex.GetIndexAsync(document, CancellationToken.None).ConfigureAwait(false);

                        if (info.ProbablyContainsEscapedIdentifier(_originalText))
                        {
                            _documentsIdsToBeCheckedForConflict.Add(document.Id);
                            continue;
                        }

                        if (info.ProbablyContainsIdentifier(_replacementText))
                        {
                            _documentsIdsToBeCheckedForConflict.Add(document.Id);
                            continue;
                        }

                        foreach (var replacementName in _possibleNameConflicts)
                        {
                            if (info.ProbablyContainsIdentifier(replacementName))
                            {
                                _documentsIdsToBeCheckedForConflict.Add(document.Id);
                                break;
                            }
                        }
                    }
                }
                catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
                {
                    throw ExceptionUtilities.Unreachable;
                }
            }
Ejemplo n.º 19
0
        public async Task RunFullParallelIndexing()
        {
            Console.WriteLine("Attach now");
            Console.ReadLine();
            Console.WriteLine("Starting indexing");
            var start = DateTime.Now;
            var tasks = _workspace.CurrentSolution.Projects.SelectMany(p => p.Documents).Select(d => Task.Run(
                                                                                                    () => SyntaxTreeIndex.PrecalculateAsync(d, default))).ToList();
            await Task.WhenAll(tasks);

            Console.WriteLine("Solution parallel: " + (DateTime.Now - start));
        }
Ejemplo n.º 20
0
 public static ValueTask <SyntaxTreeIndex> GetSyntaxTreeIndexAsync(this Document document, CancellationToken cancellationToken)
 => SyntaxTreeIndex.GetIndexAsync(document, loadOnly: false, cancellationToken);
Ejemplo n.º 21
0
 public static Task <SyntaxTreeIndex> GetSyntaxTreeIndexAsync(this Document document, bool loadOnly, CancellationToken cancellationToken)
 => SyntaxTreeIndex.GetIndexAsync(document, loadOnly, cancellationToken);
 public override Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
 {
     return(SyntaxTreeIndex.PrecalculateAsync(document, cancellationToken));
 }