コード例 #1
0
                private WorkItem(
                    DocumentId?documentId,
                    ProjectId projectId,
                    string language,
                    InvocationReasons invocationReasons,
                    bool isLowPriority,
                    SyntaxPath?activeMember,
                    ImmutableHashSet <IIncrementalAnalyzer> specificAnalyzers,
                    bool retry,
                    IAsyncToken asyncToken)
                {
                    Debug.Assert(documentId == null || documentId.ProjectId == projectId);

                    DocumentId        = documentId;
                    ProjectId         = projectId;
                    Language          = language;
                    InvocationReasons = invocationReasons;
                    IsLowPriority     = isLowPriority;

                    ActiveMember      = activeMember;
                    SpecificAnalyzers = specificAnalyzers;

                    IsRetry = retry;

                    AsyncToken = asyncToken;
                }
コード例 #2
0
                private async Task <bool> TryEnqueueFromHintAsync(Document document, SyntaxPath?changedMember)
                {
                    if (changedMember == null)
                    {
                        return(false);
                    }
                    // see whether we already have semantic model. otherwise, use the expansive full project dependency one
                    // TODO: if there is a reliable way to track changed member, we could use GetSemanticModel here which could
                    //       rebuild compilation from scratch
                    if (!document.TryGetSemanticModel(out var model) ||
                        !changedMember.TryResolve(await document.GetSyntaxRootAsync(CancellationToken).ConfigureAwait(false), out SyntaxNode declarationNode))
                    {
                        return(false);
                    }

                    var symbol = model.GetDeclaredSymbol(declarationNode, CancellationToken);

                    if (symbol == null)
                    {
                        return(false);
                    }

                    return(await TryEnqueueFromMemberAsync(document, symbol).ConfigureAwait(false) ||
                           await TryEnqueueFromTypeAsync(document, symbol).ConfigureAwait(false));
                }
コード例 #3
0
        public static void LogWorkItemEnqueue(
            LogAggregator logAggregator,
            string language,
            DocumentId?documentId,
            InvocationReasons reasons,
            bool lowPriority,
            SyntaxPath?activeMember,
            bool added
            )
        {
            logAggregator.IncreaseCount(language);
            logAggregator.IncreaseCount(added ? NewWorkItem : UpdateWorkItem);

            if (documentId != null)
            {
                logAggregator.IncreaseCount(activeMember == null ? TopLevel : MemberLevel);

                if (lowPriority)
                {
                    logAggregator.IncreaseCount(LowerPriority);
                    logAggregator.IncreaseCount(ValueTuple.Create(LowerPriority, documentId.Id));
                }
            }

            foreach (var reason in reasons)
            {
                logAggregator.IncreaseCount(reason);
            }
        }
コード例 #4
0
 public Data(Project project, DocumentId documentId, Document?document, SyntaxPath?changedMember, IAsyncToken asyncToken)
 {
     _documentId   = documentId;
     _document     = document;
     Project       = project;
     ChangedMember = changedMember;
     AsyncToken    = asyncToken;
 }
コード例 #5
0
 public Data(
     Document document,
     SyntaxPath?changedMember,
     IAsyncToken asyncToken
     )
 {
     AsyncToken    = asyncToken;
     Document      = document;
     ChangedMember = changedMember;
 }
コード例 #6
0
                public WorkItem With(
                    InvocationReasons invocationReasons, SyntaxPath?currentMember,
                    ImmutableHashSet <IIncrementalAnalyzer> analyzers, bool retry, IAsyncToken asyncToken)
                {
                    // dispose old one
                    AsyncToken.Dispose();

                    // create new work item
                    return(new WorkItem(
                               DocumentId, ProjectId, Language,
                               InvocationReasons.With(invocationReasons),
                               IsLowPriority,
                               ActiveMember == currentMember ? currentMember : null,
                               Union(analyzers), IsRetry || retry,
                               asyncToken));
                }
コード例 #7
0
                public void Enqueue(Document document, SyntaxPath?changedMember)
                {
                    UpdateLastAccessTime();

                    using (_workGate.DisposableWait(CancellationToken))
                    {
                        if (_pendingWork.TryGetValue(document.Id, out var data))
                        {
                            // create new async token and dispose old one.
                            var newAsyncToken = Listener.BeginAsyncOperation(
                                nameof(Enqueue),
                                tag: _registration.Workspace
                                );
                            data.AsyncToken.Dispose();

                            _pendingWork[document.Id] = new Data(
                                document,
                                data.ChangedMember == changedMember ? changedMember : null,
                                newAsyncToken
                                );
                            return;
                        }

                        _pendingWork.Add(
                            document.Id,
                            new Data(
                                document,
                                changedMember,
                                Listener.BeginAsyncOperation(
                                    nameof(Enqueue),
                                    tag: _registration.Workspace
                                    )
                                )
                            );
                        _gate.Release();
                    }

                    Logger.Log(
                        FunctionId.WorkCoordinator_SemanticChange_Enqueue,
                        s_enqueueLogger,
                        Environment.TickCount,
                        document.Id,
                        changedMember != null
                        );
                }
コード例 #8
0
                private static SyntaxNode?GetMemberNode(
                    ISyntaxFactsService service,
                    SyntaxNode?root,
                    SyntaxPath?memberPath
                    )
                {
                    if (root == null || memberPath == null)
                    {
                        return(null);
                    }

                    if (!memberPath.TryResolve(root, out SyntaxNode? memberNode))
                    {
                        return(null);
                    }

                    return(service.IsMethodLevelMember(memberNode) ? memberNode : null);
                }
コード例 #9
0
 public WorkItem(
     DocumentId documentId,
     string language,
     InvocationReasons invocationReasons,
     bool isLowPriority,
     SyntaxPath?activeMember,
     IAsyncToken asyncToken
     )
     : this(
         documentId,
         documentId.ProjectId,
         language,
         invocationReasons,
         isLowPriority,
         activeMember,
         ImmutableHashSet.Create <IIncrementalAnalyzer>(),
         retry : false,
         asyncToken
         )
 {
 }