类org.eclipse.lsp4j.DidSaveTextDocumentParams源码实例Demo

下面列出了怎么用org.eclipse.lsp4j.DidSaveTextDocumentParams的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lsp4intellij   文件: EditorEventManager.java
/**
 * Notifies the server that the corresponding document has been saved
 */
public void documentSaved() {
    pool(() -> {
        if (!editor.isDisposed()) {
            DidSaveTextDocumentParams params = new DidSaveTextDocumentParams(identifier, editor.getDocument().getText());
            requestManager.didSave(params);
        }
    });
}
 
public void documentSaved(long timestamp) {
    this.modificationStamp = timestamp;
    ServerCapabilities serverCapabilities = languageServerWrapper.getServerCapabilities();
    if(serverCapabilities != null ) {
        Either<TextDocumentSyncKind, TextDocumentSyncOptions> textDocumentSync = serverCapabilities.getTextDocumentSync();
        if(textDocumentSync.isRight() && textDocumentSync.getRight().getSave() == null) {
            return;
        }
    }
    TextDocumentIdentifier identifier = new TextDocumentIdentifier(fileUri.toString());
    DidSaveTextDocumentParams params = new DidSaveTextDocumentParams(identifier, document.getText());
    languageServerWrapper.getInitializedServer().thenAcceptAsync(ls -> ls.getTextDocumentService().didSave(params));
}
 
源代码3 项目: lemminx   文件: XMLTextDocumentService.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
	computeAsync((monitor) -> {
		// A document was saved, collect documents to revalidate
		SaveContext context = new SaveContext(params.getTextDocument().getUri());
		doSave(context);
		return null;
	});
}
 
源代码4 项目: camel-language-server   文件: DiagnosticRunner.java
private String retrieveFullText(DidSaveTextDocumentParams params) {
	String camelText = params.getText();
	if (camelText == null) {
		camelText = camelLanguageServer.getTextDocumentService().getOpenedDocument(params.getTextDocument().getUri()).getText();
	}
	return camelText;
}
 
private TextDocumentIdentifier initAnLaunchDiagnostic() throws FileNotFoundException {
	File f = new File("src/test/resources/workspace/diagnostic/camel-with-unknownParameter.xml");
	camelLanguageServer = initializeLanguageServer(new FileInputStream(f), ".xml");
	
	TextDocumentIdentifier textDocumentIdentifier = new TextDocumentIdentifier(DUMMY_URI+".xml");
	DidSaveTextDocumentParams params = new DidSaveTextDocumentParams(textDocumentIdentifier);
	camelLanguageServer.getTextDocumentService().didSave(params);
	
	await().timeout(AWAIT_TIMEOUT).untilAsserted(() -> assertThat(lastPublishedDiagnostics).isNotNull());
	await().timeout(AWAIT_TIMEOUT).untilAsserted(() -> assertThat(lastPublishedDiagnostics.getDiagnostics()).hasSize(1));
	return textDocumentIdentifier;
}
 
private TextDocumentIdentifier initAnLaunchDiagnostic() throws FileNotFoundException {
	File f = new File("src/test/resources/workspace/diagnostic/camel-with-invalid-enum.xml");
	camelLanguageServer = initializeLanguageServer(new FileInputStream(f), ".xml");
	
	TextDocumentIdentifier textDocumentIdentifier = new TextDocumentIdentifier(DUMMY_URI+".xml");
	DidSaveTextDocumentParams params = new DidSaveTextDocumentParams(textDocumentIdentifier);
	camelLanguageServer.getTextDocumentService().didSave(params);
	
	await().timeout(AWAIT_TIMEOUT).untilAsserted(() -> assertThat(lastPublishedDiagnostics).isNotNull());
	await().timeout(AWAIT_TIMEOUT).untilAsserted(() -> assertThat(lastPublishedDiagnostics.getDiagnostics()).hasSize(1));
	return textDocumentIdentifier;
}
 
protected void testDiagnostic(String fileUnderTest, int expectedNumberOfError, String extension) throws FileNotFoundException {
	File f = new File("src/test/resources/workspace/diagnostic/" + fileUnderTest + extension);
	camelLanguageServer = initializeLanguageServer(new FileInputStream(f), extension);
	
	DidSaveTextDocumentParams params = new DidSaveTextDocumentParams(new TextDocumentIdentifier(DUMMY_URI+extension));
	camelLanguageServer.getTextDocumentService().didSave(params);
	
	await().timeout(AWAIT_TIMEOUT).untilAsserted(() -> assertThat(lastPublishedDiagnostics).isNotNull());
	await().timeout(AWAIT_TIMEOUT).untilAsserted(() -> assertThat(lastPublishedDiagnostics.getDiagnostics()).hasSize(expectedNumberOfError));
}
 
源代码8 项目: n4js   文件: AbstractIdeTest.java
/** Save the given, open file's in-memory content to disk. Does *not* close the file. */
protected void saveOpenedFile(FileURI fileURI) {
	if (!isOpen(fileURI)) {
		Assert.fail("file is not open: " + fileURI);
	}
	OpenFileInfo info = openFiles.get(fileURI);
	// 1) save current content to disk
	changeFileOnDiskWithoutNotification(fileURI, info.content);
	// 2) notify LSP server
	VersionedTextDocumentIdentifier docId = new VersionedTextDocumentIdentifier(fileURI.toString(), info.version);
	DidSaveTextDocumentParams params = new DidSaveTextDocumentParams(docId);
	languageServer.didSave(params);
}
 
public void didSave(DidSaveTextDocumentParams params) {
	ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
	try {
		JobHelpers.waitForJobs(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, new NullProgressMonitor());
		ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
			@Override
			public void run(IProgressMonitor monitor) throws CoreException {
				handleSaved(params);
			}
		}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
	} catch (CoreException e) {
		JavaLanguageServerPlugin.logException("Handle document save ", e);
	}
}
 
private void saveDocument(ICompilationUnit cu) throws Exception {
	DidSaveTextDocumentParams saveParms = new DidSaveTextDocumentParams();
	TextDocumentIdentifier textDocument = new TextDocumentIdentifier();
	textDocument.setUri(JDTUtils.toURI(cu));
	saveParms.setTextDocument(textDocument);
	saveParms.setText(cu.getSource());
	lifeCycleHandler.didSave(saveParms);
	waitForBackgroundJobs();
}
 
源代码11 项目: groovy-language-server   文件: GroovyServices.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
	// nothing to handle on save at this time
}
 
@Override
public void didSave(DidSaveTextDocumentParams params) {
	LOGGER.info("didSave: {}", params.getTextDocument());
	new DiagnosticRunner(getCamelCatalog(), camelLanguageServer).compute(params);
}
 
源代码13 项目: camel-language-server   文件: DiagnosticRunner.java
public void compute(DidSaveTextDocumentParams params) {
	String camelText = retrieveFullText(params);
	computeDiagnostics(camelText, params.getTextDocument().getUri());
}
 
源代码14 项目: rdflint   文件: RdfLintLanguageServer.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
  // refresh all tripleset
  refreshFileTripleSet();
}
 
源代码15 项目: n4js   文件: XLanguageServerImpl.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
	lspBuilder.didSave(params);
}
 
源代码16 项目: n4js   文件: LSPBuilder.java
public void didSave(DidSaveTextDocumentParams params) {
	runBuildable("didSave", () -> toBuildable(params));
}
 
源代码17 项目: n4js   文件: LSPBuilder.java
/**
 * Evaluate the params and deduce the respective build command.
 */
protected XBuildable toBuildable(DidSaveTextDocumentParams params) {
	return workspaceManager.didSave(getURI(params.getTextDocument()));
}
 
源代码18 项目: netbeans   文件: TextDocumentServiceImpl.java
@Override
public void didSave(DidSaveTextDocumentParams arg0) {
    //TODO: nothing for now?
}
 
源代码19 项目: syndesis   文件: TeiidDdlTextDocumentService.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
    LOGGER.debug("didSave: {}", params.getTextDocument());
}
 
源代码20 项目: eclipse.jdt.ls   文件: JDTLanguageServer.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
	logInfo(">> document/didSave");
	documentLifeCycleHandler.didSave(params);
}
 
源代码21 项目: eclipse.jdt.ls   文件: SyntaxLanguageServer.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
	logInfo(">> document/didSave");
	documentLifeCycleHandler.didSave(params);
}
 
源代码22 项目: vscode-as3mxml   文件: ActionScriptServices.java
/**
 * Called when a file being edited is saved.
 */
@Override
public void didSave(DidSaveTextDocumentParams params)
{
    if(realTimeProblems)
    {
        //as long as we're checking on change, we shouldn't need to do
        //anything on save because we should already have the correct state
        return;
    }

    TextDocumentIdentifier 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;
    }
    WorkspaceFolderData folderData = workspaceFolderManager.getWorkspaceFolderDataForSourceFile(path);
    if (folderData == null)
    {
        return;
    }
    getProject(folderData);
    ILspProject project = folderData.project;
    if (project == null)
    {
        //something went wrong while creating the project
        return;
    }

    //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);
}
 
源代码23 项目: xtext-core   文件: LanguageServerImpl.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
	// nothing to do
}
 
源代码24 项目: lsp4j   文件: MockLanguageServer.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
}
 
源代码25 项目: saros   文件: DocumentServiceStub.java
@Override
public void didSave(DidSaveTextDocumentParams params) {
  System.out.println("didSave");
}
 
源代码26 项目: lsp4j   文件: TextDocumentService.java
/**
 * The document save notification is sent from the client to the server when
 * the document for saved in the client.
 * 
 * Registration Options: TextDocumentSaveRegistrationOptions
 */
@JsonNotification
void didSave(DidSaveTextDocumentParams params);
 
 类所在包
 类方法
 同包方法