Ejemplo n.º 1
0
        CodeCellState GetCodeCellStateById(CodeCellId codeCellId)
        {
            var documentId = codeCellId.ToDocumentId();

            return(CodeCells.Values.FirstOrDefault(
                       codeCell => codeCell.DocumentId == documentId));
        }
Ejemplo n.º 2
0
        public void Empty()
        {
            CodeCellId emptySubmissionId     = default;
            DocumentId emptyDocumentId       = default;
            DocumentId convertedSubmissionId = emptySubmissionId.ToDocumentId();

            Assert.Equal(emptyDocumentId, convertedSubmissionId);
        }
Ejemplo n.º 3
0
 public CodeCellId InsertCell(
     CodeCellBuffer buffer,
     CodeCellId previousCellId,
     CodeCellId nextCellId)
 => AddSubmission(
     buffer.CurrentText,
     previousCellId.ToDocumentId(),
     nextCellId.ToDocumentId()).ToCodeCellId();
Ejemplo n.º 4
0
 public Task <CodeAnalysis.Compilation> EmitCellCompilationAsync(
     CodeCellId cellId,
     EvaluationEnvironment evaluationEnvironment,
     CancellationToken cancellationToken = default)
 => EmitSubmissionCompilationAsync(
     cellId.ToDocumentId(),
     evaluationEnvironment,
     cancellationToken);
Ejemplo n.º 5
0
 public async Task <ImmutableList <InteractiveDiagnostic> > GetCellDiagnosticsAsync(
     CodeCellId cellId,
     CancellationToken cancellationToken = default)
 => (await GetSubmissionCompilationDiagnosticsAsync(
         cellId.ToDocumentId(),
         cancellationToken))
 .Filter()
 .Select(ConversionExtensions.ToInteractiveDiagnostic)
 .ToImmutableList();
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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));
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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());
        }
Ejemplo n.º 12
0
 public void SetCellBuffer(CodeCellId cellId, string buffer)
 => workspace.ApplyDocumentTextChanged(
     cellId.ToDocumentId(),
     SourceText.From(buffer ?? string.Empty));
Ejemplo n.º 13
0
 public bool IsCellComplete(CodeCellId cellId)
 => IsDocumentSubmissionComplete(cellId.ToDocumentId());
Ejemplo n.º 14
0
 public void RemoveCell(CodeCellId cellId, CodeCellId nextCellId)
 => RemoveSubmission(
     cellId.ToDocumentId(),
     nextCellId.ToDocumentId());
Ejemplo n.º 15
0
 public CodeCellId InsertCell(
     CodeCellId previousCellId,
     CodeCellId nextCellId)
 => AddSubmission(
     previousCellId.ToDocumentId(),
     nextCellId.ToDocumentId()).ToCodeCellId();
Ejemplo n.º 16
0
 public bool ShouldInvalidateCellBuffer(CodeCellId cellId)
 => HaveAnyLoadDirectiveFilesChanged(cellId.ToDocumentId());
Ejemplo n.º 17
0
 public async Task <string> GetCellBufferAsync(
     CodeCellId cellId,
     CancellationToken cancellationToken = default)
 => (await GetSourceTextAsync(cellId.ToDocumentId(), cancellationToken)).ToString();