下面列出了org.eclipse.lsp4j.DidOpenTextDocumentParams#getTextDocument ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public T onDidOpenTextDocument(DidOpenTextDocumentParams params) {
TextDocumentItem item = params.getTextDocument();
synchronized (documents) {
T document = createDocument(item);
documents.put(document.getUri(), document);
return document;
}
}
@Override
public void didOpen(DidOpenTextDocumentParams params) {
TextDocumentItem textDocument = params.getTextDocument();
LOGGER.info("didOpen: {}", textDocument);
openedDocuments.put(textDocument.getUri(), textDocument);
new DiagnosticRunner(getCamelCatalog(), camelLanguageServer).compute(params);
}
@Override
public void didOpen(DidOpenTextDocumentParams params) {
TextDocumentItem textDocument = params.getTextDocument();
LOGGER.debug("didOpen: {}", textDocument);
openedDocuments.put(textDocument.getUri(), textDocument);
new DdlDiagnostics(this.teiidLanguageServer).publishDiagnostics(textDocument);
}
@Override
public void didOpen(DidOpenTextDocumentParams params) {
TextDocumentItem textDocument = params.getTextDocument();
openFilesManager.openFile(getURI(textDocument), textDocument.getVersion(), textDocument.getText());
}
/**
* Called whan a file is opened for editing in Visual Studio Code. We store
* the file's contents in a String since any changes that have been made to
* it may not have been saved yet. This method will not be called again if
* the user simply switches to a different tab for another file and then
* switched back to this one, without every closing it completely. In
* other words, the language server does not usually know which file is
* currently visible to the user in VSCode.
*/
@Override
public void didOpen(DidOpenTextDocumentParams params)
{
TextDocumentItem textDocument = params.getTextDocument();
String textDocumentUri = textDocument.getUri();
if (!textDocumentUri.endsWith(FILE_EXTENSION_AS)
&& !textDocumentUri.endsWith(FILE_EXTENSION_MXML))
{
//code intelligence is available only in .as and .mxml files
//so we ignore other file extensions
return;
}
Path path = LanguageServerCompilerUtils.getPathFromLanguageServerURI(textDocumentUri);
if (path == null)
{
return;
}
//even if it's not in a workspace folder right now, store it just in
//case we need it later.
//example: if we modify to source-path compiler option
String text = textDocument.getText();
fileTracker.openFile(path, text);
WorkspaceFolderData folderData = workspaceFolderManager.getWorkspaceFolderDataForSourceFile(path);
if (folderData == null)
{
return;
}
if (fallbackConfig != null && folderData.equals(workspaceFolderManager.getFallbackFolderData()))
{
fallbackConfig.didOpen(path);
}
getProject(folderData);
ILspProject project = folderData.project;
if (project == null)
{
//something went wrong while creating the project
return;
}
//notify the workspace that it should read the file from memory
//instead of loading from the file system
String normalizedPath = FilenameNormalization.normalize(path.toAbsolutePath().toString());
IFileSpecification fileSpec = fileTracker.getFileSpecification(normalizedPath);
compilerWorkspace.fileChanged(fileSpec);
//if it's an included file, switch to the parent file
IncludeFileData includeFileData = folderData.includedFiles.get(path.toString());
if (includeFileData != null)
{
path = Paths.get(includeFileData.parentPath);
}
checkProjectForProblems(folderData);
}
/**
* Evaluate the params and deduce the respective build command.
* @since 2.20
*/
protected Buildable toBuildable(DidOpenTextDocumentParams params) {
TextDocumentItem textDocument = params.getTextDocument();
return workspaceManager.didOpen(getURI(textDocument), textDocument.getVersion(), textDocument.getText());
}