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

Java CodeLens类代码示例

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

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



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

示例1: resolveCodeLens

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Override
public CompletableFuture<ICodeLens> resolveCodeLens(ICodeLensContext context, ICodeLens codeLens,
		IProgressMonitor monitor) {
	ITextEditor textEditor = ((IEditorCodeLensContext) context).getTextEditor();

	LSPDocumentInfo info = null;
	Collection<LSPDocumentInfo> infos = LanguageServiceAccessor.getLSPDocumentInfosFor(
			LSPEclipseUtils.getDocument((ITextEditor) textEditor),
			capabilities -> capabilities.getCodeLensProvider() != null
					&& capabilities.getCodeLensProvider().isResolveProvider());
	if (!infos.isEmpty()) {
		info = infos.iterator().next();
	} else {
		info = null;
	}
	if (info != null) {
		LSPCodeLens lscl = ((LSPCodeLens) codeLens);
		CodeLens unresolved = lscl.getCl();
		return info.getLanguageClient().getTextDocumentService().resolveCodeLens(unresolved).thenApply(resolved -> {
			lscl.update(resolved);
			return lscl;
		});
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:26,代码来源:LSPCodeLensProvider.java


示例2: codeLens

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends CodeLens>> codeLens(CodeLensParams params) {
	LOGGER.info("codeLens: " + params.getTextDocument());
	return CompletableFuture.completedFuture(Collections.emptyList());
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:6,代码来源:CamelTextDocumentService.java


示例3: addTestMethod

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
private static CodeLens addTestMethod(final MixinDefinition def, final String documentUri,
    final SInvokable i) {
  CodeLens lens = new CodeLens();
  Command cmd = new Command();
  cmd.setCommand(COMMAND);
  cmd.setTitle("Run test");
  Range r = SomAdapter.toRange(i.getSourceSection());
  cmd.setArguments(Lists.newArrayList(documentUri,
      def.getName().getString() + "." + i.getSignature().getString(),
      r.getStart().getLine(), r.getStart().getCharacter(), r.getEnd().getLine(),
      r.getEnd().getCharacter()));

  lens.setCommand(cmd);
  lens.setRange(r);
  return lens;
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:17,代码来源:SomMinitest.java


示例4: getCodeLenses

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
public void getCodeLenses(final List<CodeLens> codeLenses,
    final String documentUri) {
  String path;
  try {
    path = docUriToNormalizedPath(documentUri);
  } catch (URISyntaxException e) {
    return;
  }

  SomStructures probe;
  synchronized (path) {
    probe = structuralProbes.get(path);
  }

  if (probe != null) {
    for (MixinDefinition c : probe.getClasses()) {
      SomMinitest.checkForTests(c, codeLenses, documentUri);
    }
  }
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:21,代码来源:SomAdapter.java


示例5: codeLens

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends CodeLens>> codeLens(CodeLensParams params) {
	logInfo(">> document/codeLens");
	CodeLensHandler handler = new CodeLensHandler(preferenceManager);
	return computeAsync((cc) -> {
		IProgressMonitor monitor = toMonitor(cc);
		try {
			Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
		} catch (OperationCanceledException ignorable) {
			// No need to pollute logs when query is cancelled
		} catch (InterruptedException e) {
			JavaLanguageServerPlugin.logException(e.getMessage(), e);
		}
		return handler.getCodeLensSymbols(params.getTextDocument().getUri(), monitor);
	});
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:JDTLanguageServer.java


示例6: resolveCodeLens

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Override
public CompletableFuture<CodeLens> resolveCodeLens(CodeLens unresolved) {
	logInfo(">> codeLens/resolve");
	CodeLensHandler handler = new CodeLensHandler(preferenceManager);
	return computeAsync((cc) -> {
		IProgressMonitor monitor = toMonitor(cc);
		try {
			Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
		} catch (OperationCanceledException ignorable) {
			// No need to pollute logs when query is cancelled
		} catch (InterruptedException e) {
			JavaLanguageServerPlugin.logException(e.getMessage(), e);
		}
		return handler.resolve(unresolved, monitor);
	});
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:JDTLanguageServer.java


示例7: testGetCodeLensSymbols

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Test
public void testGetCodeLensSymbols() throws Exception {
	String payload = createCodeLensSymbolsRequest("src/java/Foo.java");
	CodeLensParams codeLensParams = getParams(payload);
	String uri = codeLensParams.getTextDocument().getUri();
	assertFalse(uri.isEmpty());
	//when
	List<CodeLens> result = handler.getCodeLensSymbols(uri, monitor);

	//then
	assertEquals("Found " + result, 3, result.size());

	CodeLens cl = result.get(0);
	Range r = cl.getRange();
	//CodeLens on main method
	assertRange(7, 20, 24, r);

	cl = result.get(1);
	r = cl.getRange();
	// CodeLens on foo method
	assertRange(14, 13, 16, r);

	cl = result.get(2);
	r = cl.getRange();
	//CodeLens on Foo type
	assertRange(5, 13, 16, r);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:28,代码来源:CodeLensHandlerTest.java


示例8: testDisableCodeLensSymbols

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Test
public void testDisableCodeLensSymbols() throws Exception {
	Preferences noCodeLenses = Preferences.createFrom(Collections.singletonMap(Preferences.REFERENCES_CODE_LENS_ENABLED_KEY, "false"));
	Mockito.reset(preferenceManager);
	when(preferenceManager.getPreferences()).thenReturn(noCodeLenses);
	handler = new CodeLensHandler(preferenceManager);

	String payload = createCodeLensSymbolsRequest("src/java/IFoo.java");
	CodeLensParams codeLensParams = getParams(payload);
	String uri = codeLensParams.getTextDocument().getUri();
	assertFalse(uri.isEmpty());

	//when
	List<CodeLens> result = handler.getCodeLensSymbols(uri, monitor);

	//then
	assertEquals(0, result.size());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:CodeLensHandlerTest.java


示例9: testEnableImplementationsCodeLensSymbols

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Test
public void testEnableImplementationsCodeLensSymbols() throws Exception {
	Preferences implementationsCodeLenses = Preferences.createFrom(Collections.singletonMap(Preferences.IMPLEMENTATIONS_CODE_LENS_ENABLED_KEY, "true"));
	Mockito.reset(preferenceManager);
	when(preferenceManager.getPreferences()).thenReturn(implementationsCodeLenses);
	handler = new CodeLensHandler(preferenceManager);

	String payload = createCodeLensSymbolsRequest("src/java/IFoo.java");
	CodeLensParams codeLensParams = getParams(payload);
	String uri = codeLensParams.getTextDocument().getUri();
	assertFalse(uri.isEmpty());

	//when
	List<CodeLens> result = handler.getCodeLensSymbols(uri, monitor);

	//then
	assertEquals(2, result.size());
	CodeLens lens = result.get(1);
	@SuppressWarnings("unchecked")
	List<Object> data = (List<Object>) lens.getData();
	String type = (String) data.get(2);
	assertEquals(type, "implementations");
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:24,代码来源:CodeLensHandlerTest.java


示例10: testDisableImplementationsCodeLensSymbols

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Test
public void testDisableImplementationsCodeLensSymbols() throws Exception {
	Preferences noImplementationsCodeLenses = Preferences.createFrom(Collections.singletonMap(Preferences.IMPLEMENTATIONS_CODE_LENS_ENABLED_KEY, "false"));
	Mockito.reset(preferenceManager);
	when(preferenceManager.getPreferences()).thenReturn(noImplementationsCodeLenses);
	Preferences noReferencesCodeLenses = Preferences.createFrom(Collections.singletonMap(Preferences.REFERENCES_CODE_LENS_ENABLED_KEY, "false"));
	Mockito.reset(preferenceManager);
	when(preferenceManager.getPreferences()).thenReturn(noReferencesCodeLenses);
	handler = new CodeLensHandler(preferenceManager);

	String payload = createCodeLensSymbolsRequest("src/java/IFoo.java");
	CodeLensParams codeLensParams = getParams(payload);
	String uri = codeLensParams.getTextDocument().getUri();
	assertFalse(uri.isEmpty());

	//when
	List<CodeLens> result = handler.getCodeLensSymbols(uri, monitor);

	//then
	assertEquals(0, result.size());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:CodeLensHandlerTest.java


示例11: testResolveImplementationsCodeLense

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testResolveImplementationsCodeLense() {
	String source = "src/java/IFoo.java";
	String payload = createCodeLensImplementationsRequest(source, 5, 17, 21);

	CodeLens lens = getParams(payload);
	Range range = lens.getRange();
	assertRange(5, 17, 21, range);

	CodeLens result = handler.resolve(lens, monitor);
	assertNotNull(result);

	//Check if command found
	Command command = result.getCommand();
	assertNotNull(command);
	assertEquals("2 implementations", command.getTitle());
	assertEquals("java.show.implementations", command.getCommand());

	//Check codelens args
	List<Object> args = command.getArguments();
	assertEquals(3, args.size());

	//Check we point to the Bar class
	String sourceUri = args.get(0).toString();
	assertTrue(sourceUri.endsWith("IFoo.java"));

	//CodeLens position
	Map<String, Object> map = (Map<String, Object>) args.get(1);
	assertEquals(5.0, map.get("line"));
	assertEquals(17.0, map.get("character"));

	//Reference location
	List<Location> locations = (List<Location>) args.get(2);
	assertEquals(2, locations.size());
	Location loc = locations.get(0);
	assertTrue(loc.getUri().endsWith("src/java/Foo2.java"));
	assertRange(5, 13, 17, loc.getRange());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:40,代码来源:CodeLensHandlerTest.java


示例12: testCodeLens

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Test
public void testCodeLens() {
  final Procedure1<AbstractLanguageServerTest.TestCodeLensConfiguration> _function = (AbstractLanguageServerTest.TestCodeLensConfiguration it) -> {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("type Foo {}");
    _builder.newLine();
    _builder.append("type Bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Foo foo");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    it.setModel(_builder.toString());
    final Procedure1<List<? extends CodeLens>> _function_1 = (List<? extends CodeLens> it_1) -> {
      this.assertEquals("Do Awesome Stuff(RESOLVED)", IterableExtensions.head(it_1).getCommand().getTitle());
      Object _data = IterableExtensions.head(it_1).getData();
      Assert.assertEquals(1, ((Position) _data).getLine());
    };
    it.setAssertCodeLenses(_function_1);
  };
  this.testCodeLens(_function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:CodeLensTest.java


示例13: uninstallURI

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
private URI uninstallURI(final CodeLens lens) {
  URI result = null;
  Object _data = lens.getData();
  if ((_data instanceof String)) {
    result = URI.createURI(lens.getData().toString());
    lens.setData(null);
  } else {
    Object _data_1 = lens.getData();
    if ((_data_1 instanceof List<?>)) {
      Object _data_2 = lens.getData();
      final List<?> l = ((List<?>) _data_2);
      result = URI.createURI(IterableExtensions.head(l).toString());
      lens.setData(l.get(1));
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:LanguageServerImpl.java


示例14: codeLens

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends CodeLens>> codeLens(final CodeLensParams params) {
  final Function1<CancelIndicator, List<? extends CodeLens>> _function = (CancelIndicator cancelIndicator) -> {
    final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
    final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    ICodeLensService _get = null;
    if (resourceServiceProvider!=null) {
      _get=resourceServiceProvider.<ICodeLensService>get(ICodeLensService.class);
    }
    final ICodeLensService codeLensService = _get;
    if ((codeLensService == null)) {
      return CollectionLiterals.<CodeLens>emptyList();
    }
    final Function2<Document, XtextResource, List<? extends CodeLens>> _function_1 = (Document document, XtextResource resource) -> {
      final List<? extends CodeLens> result = codeLensService.computeCodeLenses(document, resource, params, cancelIndicator);
      this.installURI(result, uri.toString());
      return result;
    };
    return this.workspaceManager.<List<? extends CodeLens>>doRead(uri, _function_1);
  };
  return this.requestManager.<List<? extends CodeLens>>runRead(_function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:LanguageServerImpl.java


示例15: resolveCodeLens

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
@Override
public CompletableFuture<CodeLens> resolveCodeLens(final CodeLens unresolved) {
  final URI uri = this.uninstallURI(unresolved);
  if ((uri == null)) {
    return CompletableFuture.<CodeLens>completedFuture(unresolved);
  }
  final Function1<CancelIndicator, CodeLens> _function = (CancelIndicator cancelIndicator) -> {
    final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    ICodeLensResolver _get = null;
    if (resourceServiceProvider!=null) {
      _get=resourceServiceProvider.<ICodeLensResolver>get(ICodeLensResolver.class);
    }
    final ICodeLensResolver resolver = _get;
    if ((resolver == null)) {
      return unresolved;
    }
    final Function2<Document, XtextResource, CodeLens> _function_1 = (Document document, XtextResource resource) -> {
      final CodeLens result = resolver.resolveCodeLens(document, resource, unresolved, cancelIndicator);
      return result;
    };
    return this.workspaceManager.<CodeLens>doRead(uri, _function_1);
  };
  return this.requestManager.<CodeLens>runRead(_function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:LanguageServerImpl.java


示例16: checkForTests

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
public static void checkForTests(final MixinDefinition def,
    final List<CodeLens> codeLenses, final String documentUri) {
  for (SSymbol s : def.getFactoryMethods().keySet()) {
    if (s == TEST_CONTEXT) {
      CodeLens lens = createTestLense(def, documentUri);

      codeLenses.add(lens);

      addTestMethods(def, codeLenses, documentUri);
      return;
    }
  }
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:14,代码来源:SomMinitest.java


示例17: createTestLense

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
private static CodeLens createTestLense(final MixinDefinition def,
    final String documentUri) {
  CodeLens lens = new CodeLens();
  Command cmd = new Command();
  cmd.setCommand(COMMAND);
  cmd.setTitle("Run tests");
  Range r = SomAdapter.toRange(def.getNameSourceSection());
  cmd.setArguments(Lists.newArrayList(documentUri, def.getName().getString(),
      r.getStart().getLine(), r.getStart().getCharacter(), r.getEnd().getLine(),
      r.getEnd().getCharacter()));

  lens.setCommand(cmd);
  lens.setRange(r);
  return lens;
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:16,代码来源:SomMinitest.java


示例18: addTestMethods

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
private static void addTestMethods(final MixinDefinition def,
    final List<CodeLens> codeLenses, final String documentUri) {
  for (Dispatchable d : def.getInstanceDispatchables().values()) {
    if (d instanceof SInvokable) {
      SInvokable i = (SInvokable) d;
      if (i.getSignature().getString().startsWith(TEST_PREFIX)) {
        CodeLens lens = addTestMethod(def, documentUri, i);
        codeLenses.add(lens);
      }
    }
  }
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:13,代码来源:SomMinitest.java


示例19: getCodeLensSymbols

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
public List<CodeLens> getCodeLensSymbols(String uri, IProgressMonitor monitor) {
	if (!preferenceManager.getPreferences().isCodeLensEnabled()) {
		return Collections.emptyList();
	}
	final ICompilationUnit unit = JDTUtils.resolveCompilationUnit(uri);
	IClassFile classFile = null;
	if (unit == null) {
		classFile = JDTUtils.resolveClassFile(uri);
		if (classFile == null) {
			return Collections.emptyList();
		}
	} else {
		if (!unit.getResource().exists() || monitor.isCanceled()) {
			return Collections.emptyList();
		}
	}
	try {
		ITypeRoot typeRoot = unit != null ? unit : classFile;
		IJavaElement[] elements = typeRoot.getChildren();
		ArrayList<CodeLens> lenses = new ArrayList<>(elements.length);
		collectCodeLenses(typeRoot, elements, lenses, monitor);
		if (monitor.isCanceled()) {
			lenses.clear();
		}
		return lenses;
	} catch (JavaModelException e) {
		JavaLanguageServerPlugin.logException("Problem getting code lenses for" + unit.getElementName(), e);
	}
	return Collections.emptyList();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:31,代码来源:CodeLensHandler.java


示例20: getCodeLens

import org.eclipse.lsp4j.CodeLens; //导入依赖的package包/类
private CodeLens getCodeLens(String type, IJavaElement element, ITypeRoot typeRoot) throws JavaModelException {
	CodeLens lens = new CodeLens();
	ISourceRange r = ((ISourceReference) element).getNameRange();
	final Range range = JDTUtils.toRange(typeRoot, r.getOffset(), r.getLength());
	lens.setRange(range);
	String uri = ResourceUtils.toClientUri(JDTUtils.toUri(typeRoot));
	lens.setData(Arrays.asList(uri, range.getStart(), type));
	return lens;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:10,代码来源:CodeLensHandler.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java PyType类代码示例发布时间:2022-05-23
下一篇:
Java Archive类代码示例发布时间: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