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

Java CodeActionParams类代码示例

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

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



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

示例1: testCodeAction_exception

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Test
public void testCodeAction_exception() throws JavaModelException {
	URI uri = project.getFile("nopackage/Test.java").getRawLocationURI();
	ICompilationUnit cu = JDTUtils.resolveCompilationUnit(uri);
	try {
		cu.becomeWorkingCopy(new NullProgressMonitor());
		CodeActionParams params = new CodeActionParams();
		params.setTextDocument(new TextDocumentIdentifier(uri.toString()));
		final Range range = new Range();
		range.setStart(new Position(0, 17));
		range.setEnd(new Position(0, 17));
		params.setRange(range);
		CodeActionContext context = new CodeActionContext();
		context.setDiagnostics(Collections.emptyList());
		params.setContext(context);
		List<? extends Command> commands = server.codeAction(params).join();
		Assert.assertNotNull(commands);
		Assert.assertEquals(0, commands.size());
	} finally {
		cu.discardWorkingCopy();
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:CodeActionHandlerTest.java


示例2: codeAction

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends Command>> codeAction(CodeActionParams params) {
	logInfo(">> document/codeAction");
	CodeActionHandler handler = new CodeActionHandler();
	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.getCodeActionCommands(params, toMonitor(cc));
	});
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:JDTLanguageServer.java


示例3: testCodeAction_removeUnusedImport

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Test
public void testCodeAction_removeUnusedImport() throws Exception{
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"import java.sql.*; \n" +
					"public class Foo {\n"+
					"	void foo() {\n"+
					"	}\n"+
			"}\n");

	CodeActionParams params = new CodeActionParams();
	params.setTextDocument(new TextDocumentIdentifier(JDTUtils.toURI(unit)));
	final Range range = getRange(unit, "java.sql");
	params.setRange(range);
	params.setContext(new CodeActionContext(Arrays.asList(getDiagnostic(Integer.toString(IProblem.UnusedImport), range))));
	List<? extends Command> commands = server.codeAction(params).join();
	Assert.assertNotNull(commands);
	Assert.assertEquals(2, commands.size());
	Command c = commands.get(0);
	Assert.assertEquals(CodeActionHandler.COMMAND_ID_APPLY_EDIT, c.getCommand());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:CodeActionHandlerTest.java


示例4: testCodeAction_removeUnterminatedString

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Test
public void testCodeAction_removeUnterminatedString() throws Exception{
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"	void foo() {\n"+
					"String s = \"some str\n" +
					"	}\n"+
			"}\n");

	CodeActionParams params = new CodeActionParams();
	params.setTextDocument(new TextDocumentIdentifier(JDTUtils.toURI(unit)));
	final Range range = getRange(unit, "some str");
	params.setRange(range);
	params.setContext(new CodeActionContext(Arrays.asList(getDiagnostic(Integer.toString(IProblem.UnterminatedString), range))));
	List<? extends Command> commands = server.codeAction(params).join();
	Assert.assertNotNull(commands);
	Assert.assertEquals(1, commands.size());
	Command c = commands.get(0);
	Assert.assertEquals(CodeActionHandler.COMMAND_ID_APPLY_EDIT, c.getCommand());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:CodeActionHandlerTest.java


示例5: evaluateCodeActions

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
protected List<Command> evaluateCodeActions(ICompilationUnit cu) throws JavaModelException {

		CompilationUnit astRoot = SharedASTProvider.getInstance().getAST(cu, null);
		IProblem[] problems = astRoot.getProblems();

		Range range = getRange(cu, problems);

		CodeActionParams parms = new CodeActionParams();

		TextDocumentIdentifier textDocument = new TextDocumentIdentifier();
		textDocument.setUri(JDTUtils.toURI(cu));
		parms.setTextDocument(textDocument);
		parms.setRange(range);
		CodeActionContext context = new CodeActionContext();
		context.setDiagnostics(DiagnosticsHandler.toDiagnosticsArray(Arrays.asList(problems)));
		parms.setContext(context);

		return new CodeActionHandler().getCodeActionCommands(parms, new NullProgressMonitor());
	}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:AbstractQuickFixTest.java


示例6: getCodeActions

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Override
public List<? extends Command> getCodeActions(final Document document, final XtextResource resource, final CodeActionParams params, final CancelIndicator indicator) {
  final ArrayList<Command> commands = CollectionLiterals.<Command>newArrayList();
  List<Diagnostic> _diagnostics = params.getContext().getDiagnostics();
  for (final Diagnostic d : _diagnostics) {
    String _code = d.getCode();
    if (_code != null) {
      switch (_code) {
        case TestLanguageValidator.INVALID_NAME:
          Command _fixInvalidName = this.fixInvalidName(d, document, resource, params);
          commands.add(_fixInvalidName);
          break;
        case TestLanguageValidator.UNSORTED_MEMBERS:
          Command _fixUnsortedMembers = this.fixUnsortedMembers(d, document, resource, params);
          commands.add(_fixUnsortedMembers);
          break;
      }
    }
  }
  return commands;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:CodeActionService.java


示例7: codeAction

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


示例8: find

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
public List<Command> find(CodeActionParams params) {
    return params.getContext()
            .getDiagnostics()
            .stream()
            .flatMap(diagnostic -> findCodeActionsForDiagnostic(diagnostic))
            .collect(Collectors.toList());
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:8,代码来源:CodeActions.java


示例9: codeAction

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends Command>> codeAction(final CodeActionParams params) {
  // TODO Auto-generated method stub
  return null;
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:6,代码来源:SomLanguageServer.java


示例10: testCodeAction_superfluousSemicolon

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Test
@Ignore
public void testCodeAction_superfluousSemicolon() throws Exception{
	ICompilationUnit unit = getWorkingCopy(
			"src/java/Foo.java",
			"public class Foo {\n"+
					"	void foo() {\n"+
					";" +
					"	}\n"+
			"}\n");

	CodeActionParams params = new CodeActionParams();
	params.setTextDocument(new TextDocumentIdentifier(JDTUtils.toURI(unit)));
	final Range range = getRange(unit, ";");
	params.setRange(range);
	params.setContext(new CodeActionContext(Arrays.asList(getDiagnostic(Integer.toString(IProblem.SuperfluousSemicolon), range))));
	List<? extends Command> commands = server.codeAction(params).join();
	Assert.assertNotNull(commands);
	Assert.assertEquals(1, commands.size());
	Command c = commands.get(0);
	Assert.assertEquals(CodeActionHandler.COMMAND_ID_APPLY_EDIT, c.getCommand());
	Assert.assertNotNull(c.getArguments());
	Assert.assertTrue(c.getArguments().get(0) instanceof WorkspaceEdit);
	WorkspaceEdit we = (WorkspaceEdit) c.getArguments().get(0);
	List<org.eclipse.lsp4j.TextEdit> edits = we.getChanges().get(JDTUtils.toURI(unit));
	Assert.assertEquals(1, edits.size());
	Assert.assertEquals("", edits.get(0).getNewText());
	Assert.assertEquals(range, edits.get(0).getRange());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:30,代码来源:CodeActionHandlerTest.java


示例11: codeAction

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


示例12: codeAction

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends Command>> codeAction(CodeActionParams params) {
	throw new UnsupportedOperationException();
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:5,代码来源:MockLanguageServer.java


示例13: codeAction

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
public Promise<List<Command>> codeAction(CodeActionParams params) {
  return transmitDtoAndReceiveDtoList(params, "textDocument/codeAction", Command.class);
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:TextDocumentServiceClient.java


示例14: computeQuickAssistProposals

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Override
public void computeQuickAssistProposals(
    QuickAssistInvocationContext invocationContext, CodeAssistCallback callback) {
  LinearRange range = invocationContext.getTextEditor().getSelectedLinearRange();
  Document document = invocationContext.getTextEditor().getDocument();
  QueryAnnotationsEvent.QueryCallback annotationCallback =
      new QueryAnnotationsEvent.QueryCallback() {

        @SuppressWarnings("ReturnValueIgnored")
        @Override
        public void respond(
            Map<Annotation, org.eclipse.che.ide.api.editor.text.Position> annotations) {
          // iteration with range never returns anything; need to filter ourselves.
          // https://github.com/eclipse/che/issues/4338
          List<Diagnostic> diagnostics =
              annotations
                  .entrySet()
                  .stream()
                  .filter(
                      (e) -> e.getValue().overlapsWith(range.getStartOffset(), range.getLength()))
                  .map(Entry::getKey)
                  .map(a -> (DiagnosticAnnotation) a)
                  .map(DiagnosticAnnotation::getDiagnostic)
                  .collect(Collectors.toList());

          CodeActionContext context = new CodeActionContext(diagnostics);

          TextPosition start = document.getPositionFromIndex(range.getStartOffset());
          TextPosition end =
              document.getPositionFromIndex(range.getStartOffset() + range.getLength());
          Position rangeStart = new Position(start.getLine(), start.getCharacter());
          Position rangeEnd = new Position(end.getLine(), end.getCharacter());
          Range rangeParam = new Range(rangeStart, rangeEnd);
          rangeParam.setEnd(rangeEnd);

          TextDocumentIdentifier textDocumentIdentifier =
              new TextDocumentIdentifier(document.getFile().getLocation().toString());
          CodeActionParams params =
              new CodeActionParams(textDocumentIdentifier, rangeParam, context);

          Promise<List<Command>> codeAction =
              textDocumentService.codeAction(new CodeActionParamsDto(params));
          List<CompletionProposal> proposals = new ArrayList<>();
          codeAction.then(
              (commands) -> {
                for (Command command : commands) {
                  Action action = actionManager.getAction(command.getCommand());
                  if (action != null) {
                    proposals.add(new ActionCompletionProposal(command, action));
                  }
                }
                ;
                callback.proposalComputed(proposals);
              });
        }
      };
  QueryAnnotationsEvent event =
      new QueryAnnotationsEvent.Builder()
          .withFilter(a -> a instanceof DiagnosticAnnotation)
          .withCallback(annotationCallback)
          .build();
  document.getDocumentHandle().getDocEventBus().fireEvent(event);
}
 
开发者ID:eclipse,项目名称:che,代码行数:64,代码来源:LanguageServerQuickAssistProcessor.java


示例15: codeAction

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends Command>> codeAction(CodeActionParams params) {
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:MavenTextDocumentService.java


示例16: configureMethods

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
@PostConstruct
public void configureMethods() {
  dtoToDtoList(
      "definition", TextDocumentPositionParams.class, LocationDto.class, this::definition);
  dtoToDtoList("codeAction", CodeActionParams.class, CommandDto.class, this::codeAction);
  dtoToDtoList(
      "documentSymbol",
      DocumentSymbolParams.class,
      SymbolInformationDto.class,
      this::documentSymbol);
  dtoToDtoList("formatting", DocumentFormattingParams.class, TextEditDto.class, this::formatting);
  dtoToDtoList(
      "rangeFormatting",
      DocumentRangeFormattingParams.class,
      TextEditDto.class,
      this::rangeFormatting);
  dtoToDtoList("references", ReferenceParams.class, LocationDto.class, this::references);
  dtoToDtoList(
      "onTypeFormatting",
      DocumentOnTypeFormattingParams.class,
      TextEditDto.class,
      this::onTypeFormatting);

  dtoToDto(
      "completionItem/resolve",
      ExtendedCompletionItem.class,
      ExtendedCompletionItemDto.class,
      this::completionItemResolve);
  dtoToDto(
      "documentHighlight",
      TextDocumentPositionParams.class,
      DocumentHighlight.class,
      this::documentHighlight);
  dtoToDto(
      "completion",
      TextDocumentPositionParams.class,
      ExtendedCompletionListDto.class,
      this::completion);
  dtoToDto("hover", TextDocumentPositionParams.class, HoverDto.class, this::hover);
  dtoToDto(
      "signatureHelp",
      TextDocumentPositionParams.class,
      SignatureHelpDto.class,
      this::signatureHelp);

  dtoToDto("rename", RenameParams.class, RenameResultDto.class, this::rename);

  dtoToNothing("didChange", DidChangeTextDocumentParams.class, this::didChange);
  dtoToNothing("didClose", DidCloseTextDocumentParams.class, this::didClose);
  dtoToNothing("didOpen", DidOpenTextDocumentParams.class, this::didOpen);
  dtoToNothing("didSave", DidSaveTextDocumentParams.class, this::didSave);
}
 
开发者ID:eclipse,项目名称:che,代码行数:53,代码来源:TextDocumentService.java


示例17: codeAction

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
/**
 * The code action request is sent from the client to the server to compute
 * commands for a given text document and range. These commands are
 * typically code fixes to either fix problems or to beautify/refactor code.
 * 
 * Registration Options: TextDocumentRegistrationOptions
 */
@JsonRequest
CompletableFuture<List<? extends Command>> codeAction(CodeActionParams params);
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:10,代码来源:TextDocumentService.java


示例18: getCodeActions

import org.eclipse.lsp4j.CodeActionParams; //导入依赖的package包/类
public abstract List<? extends Command> getCodeActions(final Document document, final XtextResource resource, final CodeActionParams params, final CancelIndicator indicator); 
开发者ID:eclipse,项目名称:xtext-core,代码行数:2,代码来源:ICodeActionService.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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