當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript TextDocument.validateRange方法代碼示例

本文整理匯總了TypeScript中vscode.TextDocument.validateRange方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TextDocument.validateRange方法的具體用法?TypeScript TextDocument.validateRange怎麽用?TypeScript TextDocument.validateRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vscode.TextDocument的用法示例。


在下文中一共展示了TextDocument.validateRange方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Range

 .map(({ message, lineNumber }) => {
     const range = document.validateRange(new Range(
         lineNumber - 1, 0, lineNumber - 1, Number.MAX_VALUE));
     const diagnostic = new Diagnostic(range, message);
     diagnostic.source = "fish";
     return diagnostic;
 });
開發者ID:feosuna1,項目名稱:dotfiles,代碼行數:7,代碼來源:extension.ts

示例2: provideChangesHover

    async provideChangesHover(
        document: TextDocument,
        position: Position,
        token: CancellationToken
    ): Promise<Hover | undefined> {
        if (!Container.lineTracker.includes(position.line)) return undefined;

        const lineState = Container.lineTracker.getState(position.line);
        const commit = lineState !== undefined ? lineState.commit : undefined;
        if (commit === undefined) return undefined;

        // Avoid double annotations if we are showing the whole-file hover blame annotations
        if (Container.config.hovers.annotations.changes) {
            const fileAnnotations = await Container.fileAnnotations.getAnnotationType(window.activeTextEditor);
            if (fileAnnotations !== undefined) return undefined;
        }

        const wholeLine = Container.config.hovers.currentLine.over === 'line';
        // If we aren't showing the hover over the whole line, make sure the annotation is on
        if (!wholeLine && Container.lineAnnotations.suspended) return undefined;

        const range = document.validateRange(
            new Range(position.line, wholeLine ? 0 : Number.MAX_SAFE_INTEGER, position.line, Number.MAX_SAFE_INTEGER)
        );
        if (!wholeLine && range.start.character !== position.character) return undefined;

        const trackedDocument = await Container.tracker.get(document);
        if (trackedDocument === undefined) return undefined;

        const message = await Annotations.changesHoverMessage(commit, trackedDocument.uri, position.line);
        if (message === undefined) return undefined;

        return new Hover(message, range);
    }
開發者ID:chrisleaman,項目名稱:vscode-gitlens,代碼行數:34,代碼來源:lineHoverController.ts

示例3: provideDetailsHover

    async provideDetailsHover(
        document: TextDocument,
        position: Position,
        token: CancellationToken
    ): Promise<Hover | undefined> {
        if (!Container.lineTracker.includes(position.line)) return undefined;

        const lineState = Container.lineTracker.getState(position.line);
        const commit = lineState !== undefined ? lineState.commit : undefined;
        if (commit === undefined) return undefined;

        // Avoid double annotations if we are showing the whole-file hover blame annotations
        const fileAnnotations = await Container.fileAnnotations.getAnnotationType(window.activeTextEditor);
        if (fileAnnotations !== undefined && Container.config.hovers.annotations.details) return undefined;

        const wholeLine = Container.config.hovers.currentLine.over === 'line';
        // If we aren't showing the hover over the whole line, make sure the annotation is on
        if (!wholeLine && Container.lineAnnotations.suspended) return undefined;

        const range = document.validateRange(
            new Range(position.line, wholeLine ? 0 : Number.MAX_SAFE_INTEGER, position.line, Number.MAX_SAFE_INTEGER)
        );
        if (!wholeLine && range.start.character !== position.character) return undefined;

        // Get the full commit message -- since blame only returns the summary
        let logCommit = lineState !== undefined ? lineState.logCommit : undefined;
        if (logCommit === undefined && !commit.isUncommitted) {
            logCommit = await Container.git.getCommitForFile(commit.repoPath, commit.uri.fsPath, {
                ref: commit.sha
            });
            if (logCommit !== undefined) {
                // Preserve the previous commit from the blame commit
                logCommit.previousSha = commit.previousSha;
                logCommit.previousFileName = commit.previousFileName;

                if (lineState !== undefined) {
                    lineState.logCommit = logCommit;
                }
            }
        }

        let editorLine = position.line;
        const line = editorLine + 1;
        const commitLine = commit.lines.find(l => l.line === line) || commit.lines[0];
        editorLine = commitLine.originalLine - 1;

        const trackedDocument = await Container.tracker.get(document);
        if (trackedDocument === undefined) return undefined;

        const message = await Annotations.detailsHoverMessage(
            logCommit || commit,
            trackedDocument.uri,
            editorLine,
            Container.config.defaultDateFormat,
            fileAnnotations
        );
        return new Hover(message, range);
    }
開發者ID:chrisleaman,項目名稱:vscode-gitlens,代碼行數:58,代碼來源:lineHoverController.ts

示例4: provideChangesHover

    async provideChangesHover(
        document: TextDocument,
        position: Position,
        token: CancellationToken
    ): Promise<Hover | undefined> {
        const commit = await this.getCommitForHover(position);
        if (commit === undefined) return undefined;

        const hover = await Annotations.changesHover(commit, position.line, await GitUri.fromUri(document.uri));
        if (hover.hoverMessage === undefined) return undefined;

        return new Hover(
            hover.hoverMessage,
            document.validateRange(new Range(position.line, 0, position.line, Number.MAX_SAFE_INTEGER))
        );
    }
開發者ID:eamodio,項目名稱:vscode-git-codelens,代碼行數:16,代碼來源:blameAnnotationProvider.ts

示例5: async

const getFormatRangeEdits = async (
    document: TextDocument,
    range?: Range,
): Promise<ReadonlyArray<TextEdit>> => {
    const actualRange = document.validateRange(
        range || new Range(0, 0, Number.MAX_VALUE, Number.MAX_VALUE));
    const result = await runInWorkspace(
        vscode.workspace.getWorkspaceFolder(document.uri),
        ["fish_indent"], document.getText(actualRange),
    ).catch((error) => {
        vscode.window.showErrorMessage(
            `Failed to run fish_indent: ${error}`);
        // Re-throw the error to make the promise fail
        throw error;
    });
    return result.exitCode === 0 ?
        [TextEdit.replace(actualRange, result.stdout)] :
        [];
};
開發者ID:feosuna1,項目名稱:dotfiles,代碼行數:19,代碼來源:extension.ts

示例6: provideDetailsHover

    async provideDetailsHover(
        document: TextDocument,
        position: Position,
        token: CancellationToken
    ): Promise<Hover | undefined> {
        const commit = await this.getCommitForHover(position);
        if (commit === undefined) return undefined;

        // Get the full commit message -- since blame only returns the summary
        let logCommit: GitCommit | undefined = undefined;
        if (!commit.isUncommitted) {
            logCommit = await Container.git.getLogCommitForFile(commit.repoPath, commit.uri.fsPath, {
                ref: commit.sha
            });
            if (logCommit !== undefined) {
                // Preserve the previous commit from the blame commit
                logCommit.previousFileName = commit.previousFileName;
                logCommit.previousSha = commit.previousSha;
            }
        }

        let editorLine = this.editor.selection.active.line;
        const line = editorLine + 1;
        const commitLine = commit.lines.find(l => l.line === line) || commit.lines[0];
        editorLine = commitLine.originalLine - 1;

        const message = Annotations.getHoverMessage(
            logCommit || commit,
            Container.config.defaultDateFormat,
            await Container.git.getRemotes(commit.repoPath),
            this.annotationType,
            editorLine
        );
        return new Hover(
            message,
            document.validateRange(new Range(position.line, 0, position.line, Number.MAX_SAFE_INTEGER))
        );
    }
開發者ID:eamodio,項目名稱:vscode-git-codelens,代碼行數:38,代碼來源:blameAnnotationProvider.ts


注:本文中的vscode.TextDocument.validateRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。