CodeCellState GetCodeCellStateById(CodeCellId codeCellId) { var documentId = codeCellId.ToDocumentId(); return(CodeCells.Values.FirstOrDefault( codeCell => codeCell.DocumentId == documentId)); }
public void Empty() { CodeCellId emptySubmissionId = default; DocumentId emptyDocumentId = default; DocumentId convertedSubmissionId = emptySubmissionId.ToDocumentId(); Assert.Equal(emptyDocumentId, convertedSubmissionId); }
public CodeCellId InsertCell( CodeCellBuffer buffer, CodeCellId previousCellId, CodeCellId nextCellId) => AddSubmission( buffer.CurrentText, previousCellId.ToDocumentId(), nextCellId.ToDocumentId()).ToCodeCellId();
public Task <CodeAnalysis.Compilation> EmitCellCompilationAsync( CodeCellId cellId, EvaluationEnvironment evaluationEnvironment, CancellationToken cancellationToken = default) => EmitSubmissionCompilationAsync( cellId.ToDocumentId(), evaluationEnvironment, cancellationToken);
public async Task <ImmutableList <InteractiveDiagnostic> > GetCellDiagnosticsAsync( CodeCellId cellId, CancellationToken cancellationToken = default) => (await GetSubmissionCompilationDiagnosticsAsync( cellId.ToDocumentId(), cancellationToken)) .Filter() .Select(ConversionExtensions.ToInteractiveDiagnostic) .ToImmutableList();
Document GetDocument(CodeCellId codeCellId) { var document = workspace.CurrentSolution?.GetDocument(codeCellId.ToDocumentId()); if (document == null) { throw new ArgumentException( $"documnent {codeCellId} does not exist in workspace", nameof(codeCellId)); } return(document); }
public async Task <IEnumerable <Models.CompletionItem> > GetCompletionsAsync( CodeCellId cellId, Position position, CancellationToken cancellationToken = default) { if (completionController == null) { completionController = new CompletionController(this); } return(await completionController.ProvideFilteredCompletionItemsAsync( await GetSourceTextAsync( cellId.ToDocumentId(), cancellationToken), position, cancellationToken)); }
public async Task <SignatureHelp> GetSignatureHelpAsync( CodeCellId cellId, Position position, CancellationToken cancellationToken = default) { if (signatureHelpController == null) { signatureHelpController = new SignatureHelpController(this); } return(await signatureHelpController.ComputeSignatureHelpAsync( await GetSourceTextAsync( cellId.ToDocumentId(), cancellationToken), position, cancellationToken)); }
public async Task <Hover> GetHoverAsync( CodeCellId cellId, Position position, CancellationToken cancellationToken = default) { if (hoverController == null) { hoverController = new HoverController(this); } return(await hoverController.ProvideHoverAsync( await GetSourceTextAsync( cellId.ToDocumentId(), cancellationToken), position, cancellationToken)); }
public async Task <bool> IsCellOutdatedAsync( CodeCellId cellId, CancellationToken cancellationToken = default) { var documentId = cellId.ToDocumentId(); if (HaveAnyLoadDirectiveFilesChanged(documentId)) { // A trick to force Roslyn into invalidating the tree it's holding on // to representing code pulled in via any #load directives in the cell. // Unfortunately we have to go from SourceText → string → SourceText // to force SourceText.Container.TextChanged to be raised. // See https://github.com/dotnet/roslyn/issues/21964 SetCellBuffer( cellId, await GetCellBufferAsync(cellId, cancellationToken)); return(true); } return(false); }
public async Task <IReadOnlyList <InteractiveDiagnostic> > GetCellDiagnosticsAsync( CodeCellId cellId, CancellationToken cancellationToken = default) { ImmutableArray <Diagnostic> diagnostics; if (lastEmitDiagnostics != null) { diagnostics = lastEmitDiagnostics.Value; lastEmitDiagnostics = null; } else { diagnostics = await GetSubmissionCompilationDiagnosticsAsync( cellId.ToDocumentId(), cancellationToken); } return(diagnostics .Filter() .Select(ConversionExtensions.ToInteractiveDiagnostic) .ToImmutableList()); }
public void SetCellBuffer(CodeCellId cellId, string buffer) => workspace.ApplyDocumentTextChanged( cellId.ToDocumentId(), SourceText.From(buffer ?? string.Empty));
public bool IsCellComplete(CodeCellId cellId) => IsDocumentSubmissionComplete(cellId.ToDocumentId());
public void RemoveCell(CodeCellId cellId, CodeCellId nextCellId) => RemoveSubmission( cellId.ToDocumentId(), nextCellId.ToDocumentId());
public CodeCellId InsertCell( CodeCellId previousCellId, CodeCellId nextCellId) => AddSubmission( previousCellId.ToDocumentId(), nextCellId.ToDocumentId()).ToCodeCellId();
public bool ShouldInvalidateCellBuffer(CodeCellId cellId) => HaveAnyLoadDirectiveFilesChanged(cellId.ToDocumentId());
public async Task <string> GetCellBufferAsync( CodeCellId cellId, CancellationToken cancellationToken = default) => (await GetSourceTextAsync(cellId.ToDocumentId(), cancellationToken)).ToString();