本文整理汇总了TypeScript中vscode-languageserver.IConnection.onDidChangeWatchedFiles方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IConnection.onDidChangeWatchedFiles方法的具体用法?TypeScript IConnection.onDidChangeWatchedFiles怎么用?TypeScript IConnection.onDidChangeWatchedFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode-languageserver.IConnection
的用法示例。
在下文中一共展示了IConnection.onDidChangeWatchedFiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
connection: IConnection, documents: TextDocuments, baseDir: string,
converter: AnalyzerLSPConverter, logger: Logger) {
super();
const fileLoader = new FsUrlLoader(baseDir);
const inMemoryOverlayLoader = new InMemoryOverlayUrlLoader(fileLoader);
this.inMemoryDocuments = inMemoryOverlayLoader.urlContentsMap;
this.urlLoader = inMemoryOverlayLoader;
const {fire, stream} = EventStream.create<FileEvent[]>();
this.fileChanges = stream;
documents.onDidOpen((change) => {
logger.log(`Opened: ${change.document.uri}`);
});
this.disposables.push(documents.onDidChangeContent((change) => {
logger.log(`Changed in memory: ${change.document.uri}`);
// A document has changed in memory!
const url = converter.getAnalyzerUrl(change.document);
if (!url) {
return; // don't care
}
this.inMemoryDocuments.set(url, change.document.getText());
// Publish document change so other parts of the system can react.
fire([{type: FileChangeType.Changed, uri: change.document.uri}]);
}));
this.disposables.push(documents.onDidClose((event) => {
logger.log(`Closed: ${event.document.uri}`);
// The file is no longer managed in memory, so we should delete it from
// the in-memory map.
const url = converter.getAnalyzerUrl(event.document);
if (url === undefined) {
return; // don't care
}
this.inMemoryDocuments.delete(url);
fire([{type: FileChangeType.Changed, uri: event.document.uri}]);
}));
connection.onDidChangeWatchedFiles((req) => {
for (const change of req.changes) {
logger.log(`Changed on disk: ${change.uri}`);
}
const inMemoryURIs = new Set(documents.keys());
// We will get documents.onDidChangeContent events for changes of
// in-memory buffers, so we filter them out to avoid sending duplicate
// events for those changes.
const diskBackedChanges =
req.changes.filter((ch) => !inMemoryURIs.has(ch.uri));
fire(diskBackedChanges);
});
}
示例2: handleOnCompletion
diagnostics.push({
severity: DiagnosticSeverity.Warning,
range: {
start: { line: i, character: index},
end: { line: i, character: index + 10 }
},
message: `${line.substr(index, 10)} should be spelled TypeScript`
});
}
}
// Send the computed diagnostics to VSCode.
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
}
connection.onDidChangeWatchedFiles((change) => {
// Monitored files have change in VSCode
//connection.console.log('We recevied an file change event');
});
//Math.pow(3,1);
// This handler provides the initial list of the completion items.
connection.onCompletion(handleOnCompletion);
function handleOnCompletion(textDocumentPosition: TextDocumentIdentifier) : CompletionItem[]
{
// The pass parameter contains the position of the text document in
// which code complete got requested. For the example we ignore this
// info and always provide the same completion items.
return [
{
label: 'SELECT',
示例3: validateMany
if (configFiles.length !== 0 || (packageFile && packageFile.hasOwnProperty('pugLintConfig'))) {
return Promise.reject(new ResponseError<InitializeError>(99, puglintNotFound, { retry: true }));
}
});
});
});
connection.onDidChangeConfiguration((params) => {
editorSettings = params.settings.puglint;
if (!configResolver) {
return;
}
validateMany(allDocuments.all());
});
connection.onDidChangeWatchedFiles(() => {
configWatcherStatus = true;
if (!configResolver) {
return;
}
validateMany(allDocuments.all());
});
allDocuments.onDidClose((event) => {
connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
});
connection.listen();