Exemple #1
0
 public Task <IEnumerable <ReferenceLocation> > FindReferencesInDocumentAsync(ISymbol symbol, Document document, CancellationToken cancellationToken)
 {
     return(symbol is TSymbol && CanFind((TSymbol)symbol)
         ? FindReferencesInDocumentAsync((TSymbol)symbol, document, cancellationToken)
         : SpecializedTasks.EmptyEnumerable <ReferenceLocation>());
 }
 protected virtual Task <IEnumerable <ISymbol> > GetPreselectedSymbolsWorker(AbstractSyntaxContext context, int position, OptionSet options, CancellationToken cancellationToken)
 {
     return(SpecializedTasks.EmptyEnumerable <ISymbol>());
 }
 public static Task<RemoteHostClient> TryGetRemoteHostClientAsync(
     this Workspace workspace, CancellationToken cancellationToken)
     => workspace.Services.GetService<IRemoteHostClientService>()?.TryGetRemoteHostClientAsync(cancellationToken) ?? SpecializedTasks.Default<RemoteHostClient>();
Exemple #4
0
 protected virtual Task <ImmutableArray <ISymbol> > GetPreselectedSymbolsAsync(SyntaxContext context, int position, OptionSet options, CancellationToken cancellationToken)
 {
     return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
 }
Exemple #5
0
 public virtual Task <object> GetPreviewAsync(CancellationToken cancellationToken)
 => SpecializedTasks.Default <object>();
        private Task <ImmutableArray <ISymbol> > GetSymbolsCoreAsync(
            SyntaxContext context, int position, OptionSet options, bool preselect, CancellationToken cancellationToken)
        {
            var newExpression = GetObjectCreationNewExpression(context.SyntaxTree, position, cancellationToken);

            if (newExpression == null)
            {
                return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
            }

            var typeInferenceService = context.GetLanguageService <ITypeInferenceService>();
            var type = typeInferenceService.InferType(
                context.SemanticModel, position, objectAsDefault: false, cancellationToken: cancellationToken);

            // Unwrap an array type fully.  We only want to offer the underlying element type in the
            // list of completion items.
            var isArray = false;

            while (type is IArrayTypeSymbol)
            {
                isArray = true;
                type    = ((IArrayTypeSymbol)type).ElementType;
            }

            if (type == null ||
                (isArray && preselect))
            {
                // In the case of array creation, we don't offer a preselected/hard-selected item because
                // the user may want an implicitly-typed array creation

                return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
            }

            // Unwrap nullable
            if (type.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T)
            {
                type = type.GetTypeArguments().FirstOrDefault();
            }

            if (type.SpecialType == SpecialType.System_Void)
            {
                return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
            }

            if (type.ContainsAnonymousType())
            {
                return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
            }

            if (!type.CanBeReferencedByName)
            {
                return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
            }

            // Normally the user can't say things like "new IList".  Except for "IList[] x = new |".
            // In this case we do want to allow them to preselect certain types in the completion
            // list even if they can't new them directly.
            if (!isArray)
            {
                if (type.TypeKind == TypeKind.Interface ||
                    type.TypeKind == TypeKind.Pointer ||
                    type.TypeKind == TypeKind.Dynamic ||
                    type.IsAbstract)
                {
                    return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
                }

                if (type.TypeKind == TypeKind.TypeParameter &&
                    !((ITypeParameterSymbol)type).HasConstructorConstraint)
                {
                    return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
                }
            }

            if (!type.IsEditorBrowsable(options.GetOption(RecommendationOptions.HideAdvancedMembers, context.SemanticModel.Language), context.SemanticModel.Compilation))
            {
                return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
            }

            return(Task.FromResult(ImmutableArray.Create((ISymbol)type)));
        }
 public Task <ImmutableArray <TextSpan> > GetSpansAsync(Document document, CancellationToken cancellationToken)
 => _session?.GetSpansAsync(document, cancellationToken) ?? SpecializedTasks.EmptyImmutableArray <TextSpan>();
 protected override Task <Session> TryCreateServiceSessionAsync(
     string serviceName, PinnedRemotableDataScope snapshot, object callbackTarget, CancellationToken cancellationToken)
 {
     return(SpecializedTasks.Default <Session>());
 }
Exemple #9
0
 public override Task <Connection> TryCreateConnectionAsync(string serviceName, object callbackTarget, CancellationToken cancellationToken)
 {
     return(SpecializedTasks.Default <Connection>());
 }
Exemple #10
0
 public override Task <object> GetPreviewAsync(CancellationToken cancellationToken)
 {
     // The top-level action won't show any preview.
     // However, the nested sub-actions returned above will show preview.
     return(SpecializedTasks.Default <object>());
 }
 private Task <ImmutableDictionary <SchemeName, ImmutableArray <RegistryItem> > > GetColorSchemeRegistryItemsAsync(CancellationToken arg)
 => SpecializedTasks.FromResult(_colorSchemes.ToImmutableDictionary(kvp => kvp.Key, kvp => RegistryItemConverter.Convert(kvp.Value)));
            //public bool CanResolveType(ProjectId projectId, string assemblyName, string fullyQualifiedTypeName)
            //{
            //    return false;
            //}

            public Task <string?> ResolveAssemblyPathAsync(ProjectId projectId, string assemblyName, string?fullyQualifiedTypeName, CancellationToken cancellationToken)
            {
                // Assembly path resolution not supported at the default workspace level.
                return(SpecializedTasks.Null <string>());
            }
Exemple #13
0
 protected virtual Task <IEnumerable <ISymbol> > DetermineCascadedSymbolsAsync(TSymbol symbol, Solution solution, IImmutableSet <Project> projects, CancellationToken cancellationToken)
 {
     return(SpecializedTasks.EmptyEnumerable <ISymbol>());
 }
Exemple #14
0
 public Task <IEnumerable <ISymbol> > DetermineCascadedSymbolsAsync(ISymbol symbol, Solution solution, IImmutableSet <Project> projects, CancellationToken cancellationToken)
 {
     return(symbol is TSymbol && CanFind((TSymbol)symbol)
         ? DetermineCascadedSymbolsAsync((TSymbol)symbol, solution, projects, cancellationToken)
         : SpecializedTasks.EmptyEnumerable <ISymbol>());
 }
 public Task <ImmutableArray <Project> > DetermineProjectsToSearchAsync(ISymbol symbol, Solution solution, IImmutableSet <Project>?projects = null, CancellationToken cancellationToken = default)
 => SpecializedTasks.EmptyImmutableArray <Project>();
Exemple #16
0
 protected sealed override Task <Solution?> GetChangedSolutionAsync(CancellationToken cancellationToken)
 => SpecializedTasks.Null <Solution>();
 public Task <ImmutableArray <FinderLocation> > FindReferencesInDocumentAsync(
     ISymbol symbol, Document document, SemanticModel semanticModel,
     FindReferencesSearchOptions options, CancellationToken cancellationToken)
 {
     return(SpecializedTasks.EmptyImmutableArray <FinderLocation>());
 }
Exemple #18
0
 protected override Task <ImmutableArray <ISymbol> > GetSymbolsWorker(SyntaxContext context, int position, OptionSet options, CancellationToken cancellationToken)
 {
     return(SpecializedTasks.EmptyImmutableArray <ISymbol>());
 }
Exemple #19
0
 public override Task <ImmutableArray <Diagnostic> > AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken)
 {
     // No syntax diagnostics produced by the EnC engine.
     return(SpecializedTasks.EmptyImmutableArray <Diagnostic>());
 }
Exemple #20
0
 public Task <ImmutableArray <ReferenceLocation> > FindReferencesInDocumentAsync(
     SymbolAndProjectId symbolAndProjectId, Document document, CancellationToken cancellationToken = default)
 {
     return(SpecializedTasks.EmptyImmutableArray <ReferenceLocation>());
 }
 public Task <ImmutableArray <ActiveStatementTrackingSpan> > GetAdjustedTrackingSpansAsync(Document document, ITextSnapshot snapshot, CancellationToken cancellationToken)
 => _session?.GetAdjustedTrackingSpansAsync(document, snapshot, cancellationToken) ?? SpecializedTasks.EmptyImmutableArray <ActiveStatementTrackingSpan>();
Exemple #22
0
 public Task <INavigableLocation?> GetLocationForSpanAsync(Workspace workspace, DocumentId documentId, TextSpan textSpan, bool allowInvalidSpan, CancellationToken cancellationToken)
 => SpecializedTasks.Null <INavigableLocation>();
 protected override Task <ImmutableArray <Diagnostic> > GetDiagnosticsWorkerAsync(TestWorkspace workspace, TestParameters parameters)
 => SpecializedTasks.EmptyImmutableArray <Diagnostic>();
Exemple #24
0
 public Task <INavigableLocation?> GetLocationForLineAndOffsetAsync(Workspace workspace, DocumentId documentId, int lineNumber, int offset, CancellationToken cancellationToken)
 => SpecializedTasks.Null <INavigableLocation>();
Exemple #25
0
 public virtual Task <IEnumerable <SuggestedActionSet> > GetActionSetsAsync(CancellationToken cancellationToken)
 => SpecializedTasks.EmptyEnumerable <SuggestedActionSet>();
Exemple #26
0
 public Task <INavigableLocation?> GetLocationForPositionAsync(Workspace workspace, DocumentId documentId, int position, int virtualSpace, CancellationToken cancellationToken)
 => SpecializedTasks.Null <INavigableLocation>();
 public override Task <ImmutableArray <Diagnostic> > AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken)
 => SpecializedTasks.EmptyImmutableArray <Diagnostic>();
 public Task <ImmutableArray <Document> > DetermineDocumentsToSearchAsync(
     ISymbol symbol, Project project, IImmutableSet <Document> documents,
     FindReferencesSearchOptions options, CancellationToken cancellationToken)
 {
     return(SpecializedTasks.EmptyImmutableArray <Document>());
 }
 public override Task <ImmutableArray <Project> > DetermineProjectsToSearchAsync(ISymbol symbol, Solution solution, IImmutableSet <Project> projects, CancellationToken cancellationToken)
 {
     return(symbol is TSymbol && CanFind((TSymbol)symbol)
         ? DetermineProjectsToSearchAsync((TSymbol)symbol, solution, projects, cancellationToken)
         : SpecializedTasks.EmptyImmutableArray <Project>());
 }
Exemple #30
0
 public Task <IEnumerable <Document> > DetermineDocumentsToSearchAsync(ISymbol symbol, Project project, IImmutableSet <Document> documents, CancellationToken cancellationToken)
 {
     return(symbol is TSymbol && CanFind((TSymbol)symbol)
         ? DetermineDocumentsToSearchAsync((TSymbol)symbol, project, documents, cancellationToken)
         : SpecializedTasks.EmptyEnumerable <Document>());
 }