• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PublishDiagnosticsParams类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.lsp4j.PublishDiagnosticsParams的典型用法代码示例。如果您正苦于以下问题:Java PublishDiagnosticsParams类的具体用法?Java PublishDiagnosticsParams怎么用?Java PublishDiagnosticsParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PublishDiagnosticsParams类属于org.eclipse.lsp4j包,在下文中一共展示了PublishDiagnosticsParams类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testDidOpenStandaloneFile

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Test
public void testDidOpenStandaloneFile() throws Exception {
	IJavaProject javaProject = newDefaultProject();
	IPackageFragmentRoot sourceFolder = javaProject.getPackageFragmentRoot(javaProject.getProject().getFolder("src"));
	IPackageFragment pack1 = sourceFolder.createPackageFragment("java", false, null);

	// @formatter:off
	String standaloneFileContent =
			"package java;\n"+
			"public class Foo extends UnknownType {"+
			"	public void method1(){\n"+
			"		super.whatever();"+
			"	}\n"+
			"}";
	// @formatter:on
	ICompilationUnit cu1 = pack1.createCompilationUnit("Foo.java", standaloneFileContent, false, null);

	openDocument(cu1, cu1.getSource(), 1);

	List<PublishDiagnosticsParams> diagnosticReports = getClientRequests("publishDiagnostics");
	assertEquals(1, diagnosticReports.size());
	PublishDiagnosticsParams diagParam = diagnosticReports.get(0);
	assertEquals(0, diagParam.getDiagnostics().size());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:25,代码来源:DocumentLifeCycleHandlerTest.java


示例2: testDidOpenNotOnClasspath

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Test
public void testDidOpenNotOnClasspath() throws Exception {
	importProjects("eclipse/hello");
	IProject project = WorkspaceHelper.getProject("hello");
	URI uri = project.getFile("nopackage/Test2.java").getRawLocationURI();
	ICompilationUnit cu = JDTUtils.resolveCompilationUnit(uri);
	String source = FileUtils.readFileToString(FileUtils.toFile(uri.toURL()));
	openDocument(cu, source, 1);
	Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
	assertEquals(project, cu.getJavaProject().getProject());
	assertEquals(source, cu.getSource());
	List<PublishDiagnosticsParams> diagnosticReports = getClientRequests("publishDiagnostics");
	assertEquals(1, diagnosticReports.size());
	PublishDiagnosticsParams diagParam = diagnosticReports.get(0);
	assertEquals(1, diagParam.getDiagnostics().size());
	closeDocument(cu);
	Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
	diagnosticReports = getClientRequests("publishDiagnostics");
	assertEquals(2, diagnosticReports.size());
	diagParam = diagnosticReports.get(1);
	assertEquals(0, diagParam.getDiagnostics().size());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:DocumentLifeCycleHandlerTest.java


示例3: assertNewProblemReported

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
private void assertNewProblemReported(ExpectedProblemReport... expectedReports) {
	List<PublishDiagnosticsParams> diags = getClientRequests("publishDiagnostics");
	assertEquals(expectedReports.length, diags.size());

	for (int i = 0; i < expectedReports.length; i++) {
		PublishDiagnosticsParams diag = diags.get(i);
		ExpectedProblemReport expected = expectedReports[i];
		assertEquals(JDTUtils.toURI(expected.cu), diag.getUri());
		if (expected.problemCount != diag.getDiagnostics().size()) {
			String message = "";
			for (Diagnostic d : diag.getDiagnostics()) {
				message += d.getMessage() + ", ";
			}
			assertEquals(message, expected.problemCount, diag.getDiagnostics().size());
		}

	}
	diags.clear();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:DocumentLifeCycleHandlerTest.java


示例4: getDiagnostics

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
protected Map<String, List<Diagnostic>> getDiagnostics() {
  try {
    final Function1<CancelIndicator, HashMap<String, List<Diagnostic>>> _function = (CancelIndicator it) -> {
      final HashMap<String, List<Diagnostic>> result = CollectionLiterals.<String, List<Diagnostic>>newHashMap();
      final Function1<Pair<String, Object>, Object> _function_1 = (Pair<String, Object> it_1) -> {
        return it_1.getValue();
      };
      Iterable<PublishDiagnosticsParams> _filter = Iterables.<PublishDiagnosticsParams>filter(ListExtensions.<Pair<String, Object>, Object>map(this.notifications, _function_1), PublishDiagnosticsParams.class);
      for (final PublishDiagnosticsParams diagnostic : _filter) {
        result.put(diagnostic.getUri(), diagnostic.getDiagnostics());
      }
      return result;
    };
    return this.languageServer.getRequestManager().<HashMap<String, List<Diagnostic>>>runRead(_function).get();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:AbstractLanguageServerTest.java


示例5: subscribe

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Inject
private void subscribe(EventService eventService, RequestTransmitter requestTransmitter) {
  eventService.subscribe(
      event -> {
        PublishDiagnosticsParams params = event.getParams();
        if (params.getUri() != null) {
          params.setUri(params.getUri().substring(16));
        }
        endpointIds.forEach(
            endpointId ->
                requestTransmitter
                    .newRequest()
                    .endpointId(endpointId)
                    .methodName("textDocument/publishDiagnostics")
                    .paramsAsDto(new ExtendedPublishDiagnosticsParamsDto(event))
                    .sendAndSkipResult());
      },
      ExtendedPublishDiagnosticsParams.class);
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:PublishDiagnosticsParamsJsonRpcTransmitter.java


示例6: reportDiagnostics

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
public void reportDiagnostics(final List<Diagnostic> diagnostics,
    final String documentUri) {
  if (diagnostics != null) {
    PublishDiagnosticsParams result = new PublishDiagnosticsParams();
    result.setDiagnostics(diagnostics);
    result.setUri(documentUri);
    client.publishDiagnostics(result);
  }
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:10,代码来源:SomAdapter.java


示例7: publishDiagnostics

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
private void publishDiagnostics(List<IMarker> markers) {
	Map<IResource, List<IMarker>> map = markers.stream().collect(Collectors.groupingBy(IMarker::getResource));
	for (Map.Entry<IResource, List<IMarker>> entry : map.entrySet()) {
		IResource resource = entry.getKey();
		// ignore problems caused by standalone files
		if (JavaLanguageServerPlugin.getProjectsManager().getDefaultProject().equals(resource.getProject())) {
			continue;
		}
		IFile file = resource.getAdapter(IFile.class);
		if (file == null) {
			continue;
		}
		IDocument document = null;
		String uri = JDTUtils.getFileURI(resource);
		if (JavaCore.isJavaLikeFileName(file.getName())) {
			ICompilationUnit cu = JDTUtils.resolveCompilationUnit(uri);
			try {
				document = JsonRpcHelpers.toDocument(cu.getBuffer());
			} catch (JavaModelException e) {
				logException("Failed to publish diagnostics.", e);
			}
		}
		else if (projectsManager.isBuildFile(file)) {
			document = JsonRpcHelpers.toDocument(file);
		}

		if (document != null) {
			List<Diagnostic> diagnostics = WorkspaceDiagnosticsHandler.toDiagnosticsArray(document, entry.getValue().toArray(new IMarker[0]));
			connection.publishDiagnostics(new PublishDiagnosticsParams(ResourceUtils.toClientUri(uri), diagnostics));
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:33,代码来源:BuildWorkspaceHandler.java


示例8: visit

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	// Check if resource is accessible.
	// We do not deal with the markers for deleted files here
	// WorkspaceEventsHandler removes the diagnostics for deleted resources.
	if (resource == null || !resource.isAccessible()) {
		return false;
	}
	if (resource.getType() == IResource.FOLDER || resource.getType() == IResource.ROOT) {
		return true;
	}
	// ignore problems caused by standalone files
	if (resource.getType() == IResource.PROJECT) {
		return !JavaLanguageServerPlugin.getProjectsManager().getDefaultProject().equals(resource.getProject());
	}
	// No marker changes continue to visit
	if ((delta.getFlags() & IResourceDelta.MARKERS) == 0) {
		return false;
	}
	IFile file = (IFile) resource;
	String uri = JDTUtils.getFileURI(resource);
	IDocument document = null;
	IMarker[] markers = null;
	// Check if it is a Java ...
	if (JavaCore.isJavaLikeFileName(file.getName())) {
		markers = resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
		ICompilationUnit cu = (ICompilationUnit) JavaCore.create(file);
		document = JsonRpcHelpers.toDocument(cu.getBuffer());
	} // or a build file
	else if (projectsManager.isBuildFile(file)) {
		//all errors on that build file should be relevant
		markers = file.findMarkers(null, true, 1);
		document = JsonRpcHelpers.toDocument(file);
	}
	if (document != null) {
		this.connection.publishDiagnostics(new PublishDiagnosticsParams(ResourceUtils.toClientUri(uri), toDiagnosticsArray(document, markers)));
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:41,代码来源:WorkspaceDiagnosticsHandler.java


示例9: testDidOpenStandaloneFileWithSyntaxError

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Test
public void testDidOpenStandaloneFileWithSyntaxError() throws Exception {
	IJavaProject javaProject = newDefaultProject();
	IPackageFragmentRoot sourceFolder = javaProject.getPackageFragmentRoot(javaProject.getProject().getFolder("src"));
	IPackageFragment pack1 = sourceFolder.createPackageFragment("java", false, null);

	// @formatter:off
	String standaloneFileContent =
			"package java;\n"+
			"public class Foo extends UnknownType {\n"+
			"	public void method1(){\n"+
			"		super.whatever()\n"+
			"	}\n"+
			"}";
	// @formatter:on

	ICompilationUnit cu1 = pack1.createCompilationUnit("Foo.java", standaloneFileContent, false, null);

	openDocument(cu1, cu1.getSource(), 1);

	List<PublishDiagnosticsParams> diagnosticReports = getClientRequests("publishDiagnostics");
	assertEquals(1, diagnosticReports.size());
	PublishDiagnosticsParams diagParam = diagnosticReports.get(0);
	assertEquals("Unexpected number of errors " + diagParam.getDiagnostics(), 1, diagParam.getDiagnostics().size());
	Diagnostic d = diagParam.getDiagnostics().get(0);
	assertEquals("Syntax error, insert \";\" to complete BlockStatements", d.getMessage());
	assertRange(3, 17, 18, d.getRange());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:29,代码来源:DocumentLifeCycleHandlerTest.java


示例10: testDidOpenStandaloneFileWithNonSyntaxErrors

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Test
public void testDidOpenStandaloneFileWithNonSyntaxErrors() throws Exception {
	IJavaProject javaProject = newDefaultProject();
	IPackageFragmentRoot sourceFolder = javaProject.getPackageFragmentRoot(javaProject.getProject().getFolder("src"));
	IPackageFragment pack1 = sourceFolder.createPackageFragment("java", false, null);

	// @formatter:off
	String standaloneFileContent =
			"package java;\n"+
			"public class Foo {\n"+
			"	public static void notThis(){\n"+
			"		System.out.println(this);\n"+
			"	}\n"+
			"	public void method1(){\n"+
			"	}\n"+
			"	public void method1(){\n"+
			"	}\n"+
			"}";
	// @formatter:on

	ICompilationUnit cu1 = pack1.createCompilationUnit("Foo.java", standaloneFileContent, false, null);

	openDocument(cu1, cu1.getSource(), 1);

	List<PublishDiagnosticsParams> diagnosticReports = getClientRequests("publishDiagnostics");
	assertEquals(1, diagnosticReports.size());
	PublishDiagnosticsParams diagParam = diagnosticReports.get(0);

	assertEquals("Unexpected number of errors " + diagParam.getDiagnostics(), 3, diagParam.getDiagnostics().size());
	Diagnostic d = diagParam.getDiagnostics().get(0);
	assertEquals("Cannot use this in a static context", d.getMessage());
	assertRange(3, 21, 25, d.getRange());

	d = diagParam.getDiagnostics().get(1);
	assertEquals("Duplicate method method1() in type Foo", d.getMessage());
	assertRange(5, 13, 22, d.getRange());

	d = diagParam.getDiagnostics().get(2);
	assertEquals("Duplicate method method1() in type Foo", d.getMessage());
	assertRange(7, 13, 22, d.getRange());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:42,代码来源:DocumentLifeCycleHandlerTest.java


示例11: testMarkerListening

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Test
public void testMarkerListening() throws Exception {
	InitHandler initHandler = new InitHandler(projectsManager, preferenceManager, connection);
	initHandler.addWorkspaceDiagnosticsHandler();
	//import project
	importProjects("maven/broken");

	ArgumentCaptor<PublishDiagnosticsParams> captor = ArgumentCaptor.forClass(PublishDiagnosticsParams.class);
	verify(connection, atLeastOnce()).publishDiagnostics(captor.capture());

	List<PublishDiagnosticsParams> allCalls = captor.getAllValues();
	Collections.reverse(allCalls);
	projectsManager.setConnection(client);

	Optional<PublishDiagnosticsParams> fooDiags = allCalls.stream().filter(p -> p.getUri().endsWith("Foo.java")).findFirst();
	assertTrue("No Foo.java errors were found", fooDiags.isPresent());
	List<Diagnostic> diags = fooDiags.get().getDiagnostics();
	Comparator<Diagnostic> comparator = (Diagnostic d1, Diagnostic d2) -> {
		int diff = d1.getRange().getStart().getLine() - d2.getRange().getStart().getLine();
		if (diff == 0) {
			diff = d1.getMessage().compareTo(d2.getMessage());
		}
		return diff;
	};
	Collections.sort(diags, comparator );
	assertEquals(diags.toString(), 2, diags.size());
	assertEquals("The import org cannot be resolved", diags.get(0).getMessage());
	assertEquals("StringUtils cannot be resolved", diags.get(1).getMessage());

	Optional<PublishDiagnosticsParams> pomDiags = allCalls.stream().filter(p -> p.getUri().endsWith("pom.xml")).findFirst();
	assertTrue("No pom.xml errors were found", pomDiags.isPresent());
	diags = pomDiags.get().getDiagnostics();
	Collections.sort(diags, comparator);
	assertEquals(diags.toString(), 3, diags.size());
	assertTrue(diags.get(0).getMessage()
			.startsWith("For artifact {org.apache.commons:commons-lang3:null:jar}: The version cannot be empty. (org.apache.maven.plugins:maven-resources-plugin:2.6:resources:default-resources:process-resources)"));
	assertTrue(diags.get(1).getMessage()
			.startsWith("For artifact {org.apache.commons:commons-lang3:null:jar}: The version cannot be empty. (org.apache.maven.plugins:maven-resources-plugin:2.6:testResources:default-testResources:process-test-resources)"));
	assertEquals("Project build error: 'dependencies.dependency.version' for org.apache.commons:commons-lang3:jar is missing.", diags.get(2).getMessage());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:41,代码来源:WorkspaceDiagnosticsHandlerTest.java


示例12: reconcilePath

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
public void reconcilePath(String fileLocation, String projectPath) {
  String fileName = new Path(fileLocation).lastSegment();
  if (!POM_FILE_NAME.equals(fileName)) {
    return;
  }

  EditorWorkingCopy workingCopy = editorWorkingCopyManager.getWorkingCopy(fileLocation);
  if (workingCopy == null) {
    return;
  }

  String newPomContent = workingCopy.getContentAsString();
  if (isNullOrEmpty(newPomContent)) {
    return;
  }

  List<Problem> problems;
  try {
    problems = reconcile(fileLocation, projectPath, newPomContent);
    List<Diagnostic> diagnostics = convertProblems(newPomContent, problems);
    client.publishDiagnostics(
        new PublishDiagnosticsParams(LanguageServiceUtils.prefixURI(fileLocation), diagnostics));
  } catch (ServerException | NotFoundException e) {
    LOG.error(e.getMessage(), e);
    client.showMessage(new MessageParams(MessageType.Error, "Error reconciling " + fileLocation));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:PomReconciler.java


示例13: reconcileUri

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
public void reconcileUri(String uri, String text) {
  try {
    String pomPath = LanguageServiceUtils.removePrefixUri(uri);
    List<Problem> problems = reconcile(pomPath, new File(pomPath).getParent(), text);
    List<Diagnostic> diagnostics = convertProblems(text, problems);
    client.publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
  } catch (ServerException | NotFoundException e) {
    LOG.error("Error reconciling content: " + uri, e);
    client.showMessage(new MessageParams(MessageType.Error, "Error reconciling " + uri));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:PomReconciler.java


示例14: publishDiagnostics

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Override
public void publishDiagnostics(PublishDiagnosticsParams diagnostics) {
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:4,代码来源:AbstractCamelLanguageServerTest.java


示例15: endReporting

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Override
public void endReporting() {
	JavaLanguageServerPlugin.logInfo(problems.size() + " problems reported for " + this.uri.substring(this.uri.lastIndexOf('/')));
	PublishDiagnosticsParams $ = new PublishDiagnosticsParams(ResourceUtils.toClientUri(uri), toDiagnosticsArray(problems));
	this.connection.publishDiagnostics($);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:7,代码来源:DiagnosticsHandler.java


示例16: clearDiagnostics

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
public void clearDiagnostics() {
	JavaLanguageServerPlugin.logInfo("Clearing problems for " + this.uri.substring(this.uri.lastIndexOf('/')));
	problems.clear();
	PublishDiagnosticsParams $ = new PublishDiagnosticsParams(ResourceUtils.toClientUri(uri), Collections.emptyList());
	this.connection.publishDiagnostics($);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:7,代码来源:DiagnosticsHandler.java


示例17: cleanUpDiagnostics

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
private void cleanUpDiagnostics(String uri){
	this.connection.publishDiagnostics(new PublishDiagnosticsParams(ResourceUtils.toClientUri(uri), Collections.emptyList()));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:4,代码来源:WorkspaceEventsHandler.java


示例18: publishDiagnostics

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
public void publishDiagnostics(PublishDiagnosticsParams diagnostics){
	client.publishDiagnostics(diagnostics);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:4,代码来源:JavaClientConnection.java


示例19: publishDiagnostics

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
public void publishDiagnostics(final PublishDiagnosticsParams diagnostics) {
  this.noImpl3.publishDiagnostics(diagnostics);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:4,代码来源:CommandRegistryTest.java


示例20: publishDiagnostics

import org.eclipse.lsp4j.PublishDiagnosticsParams; //导入依赖的package包/类
@Override
public void publishDiagnostics(PublishDiagnosticsParams diagnostics) {
  eventService.publish(new ExtendedPublishDiagnosticsParams(serverId, diagnostics));
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:CheLanguageClient.java



注:本文中的org.eclipse.lsp4j.PublishDiagnosticsParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IQuickAssistProcessor类代码示例发布时间:2022-05-23
下一篇:
Java S1CPacketEntityMetadata类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap