本文整理汇总了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;
});
示例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);
}
示例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);
}
示例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))
);
}
示例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)] :
[];
};
示例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))
);
}