当前位置: 首页>>代码示例>>Java>>正文


Java IProblemLocation.getProblemArguments方法代码示例

本文整理汇总了Java中org.eclipse.jdt.ui.text.java.IProblemLocation.getProblemArguments方法的典型用法代码示例。如果您正苦于以下问题:Java IProblemLocation.getProblemArguments方法的具体用法?Java IProblemLocation.getProblemArguments怎么用?Java IProblemLocation.getProblemArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.ui.text.java.IProblemLocation的用法示例。


在下文中一共展示了IProblemLocation.getProblemArguments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCorrections

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
public IJavaCompletionProposal[] getCorrections(IInvocationContext context,
    IProblemLocation[] locations) throws CoreException {
  List<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();

  for (IProblemLocation problem : locations) {
    RemoteServiceProblemType problemType = RemoteServiceProblemType.getProblemType(problem.getProblemId());
    if (problemType == null) {
      continue;
    }

    switch (problemType) {
      case MISSING_ASYNC_TYPE:
        proposals.addAll(CreateAsyncInterfaceProposal.createProposals(
            context, problem));
        break;
      case MISSING_ASYNC_METHOD:
        // Provide different resolutions depending on which type error is on
        if (problem.getProblemArguments()[0].equals("async")) {
          String syncMethodBindingKey = problem.getProblemArguments()[1];
          proposals.addAll(CreateAsyncMethodProposal.createProposalsForProblemOnAsyncType(
              context.getCompilationUnit(), context.getCoveringNode(),
              syncMethodBindingKey));
          proposals.addAll(DeleteMethodProposal.createProposalsForProblemOnAsyncType(
              context.getCoveringNode(), syncMethodBindingKey));
          proposals.addAll(UpdateAsyncSignatureProposal.createProposalsForProblemsOnAsyncType(
              context.getCoveringNode(), syncMethodBindingKey));
        } else { // on sync type
          proposals.addAll(CreateAsyncMethodProposal.createProposalsForProblemOnSyncMethod(context.getCoveringNode()));
          proposals.addAll(DeleteMethodProposal.createProposalsForProblemOnExtraMethod(context.getCoveringNode()));
          proposals.addAll(UpdateAsyncSignatureProposal.createProposalsForProblemsOnSyncMethod(context.getCoveringNode()));
        }
        break;
      case MISSING_SYNC_METHOD:
        if (problem.getProblemArguments()[0].equals("sync")) {
          String asyncMethodBindingKey = problem.getProblemArguments()[1];
          proposals.addAll(CreateSyncMethodProposal.createProposalsForProblemOnSyncType(
              context.getCompilationUnit(), context.getCoveringNode(),
              asyncMethodBindingKey));
          proposals.addAll(DeleteMethodProposal.createProposalsForProblemOnSyncType(
              context.getCoveringNode(), asyncMethodBindingKey));
          proposals.addAll(UpdateSyncSignatureProposal.createProposalsForProblemsOnSyncType(
              context.getCoveringNode(), asyncMethodBindingKey));
        } else { // on async type
          proposals.addAll(CreateSyncMethodProposal.createProposalsForProblemOnAsyncMethod(context.getCoveringNode()));
          proposals.addAll(DeleteMethodProposal.createProposalsForProblemOnExtraMethod(context.getCoveringNode()));
          proposals.addAll(UpdateSyncSignatureProposal.createProposalsForProblemsOnAsyncMethod(context.getCoveringNode()));
        }
        break;
      case INVALID_ASYNC_RETURN_TYPE:
        proposals.addAll(ChangeAsyncMethodReturnTypeProposal.createProposals(context.getCoveringNode()));
        break;
      case ASYNCCALLBACK_TYPE_ARGUMENT_MISMATCH:
        if (problem.getProblemArguments()[0].equals("sync")) {
          proposals.addAll(UpdateAsyncSignatureProposal.createProposalsForProblemsOnSyncMethod(context.getCoveringNode()));
        } else {
          proposals.addAll(UpdateSyncSignatureProposal.createProposalsForProblemsOnAsyncMethod(context.getCoveringNode()));
        }
        break;
      default:
        break;
    }
  }

  return proposals.toArray(new IJavaCompletionProposal[0]);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:66,代码来源:RemoteServiceProblemMarkerResolutionGenerator.java

示例2: createProposals

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
public static List<IJavaCompletionProposal> createProposals(IInvocationContext context, IProblemLocation problem)
    throws JavaModelException {
  String syncTypeName = problem.getProblemArguments()[0];
  IJavaProject javaProject = context.getCompilationUnit().getJavaProject();
  IType syncType = JavaModelSearch.findType(javaProject, syncTypeName);
  if (syncType == null || !syncType.isInterface()) {
    return Collections.emptyList();
  }

  CompilationUnit cu = context.getASTRoot();
  ASTNode coveredNode = problem.getCoveredNode(cu);
  TypeDeclaration syncTypeDecl = (TypeDeclaration) coveredNode.getParent();
  assert (cu.getAST().hasResolvedBindings());

  ITypeBinding syncTypeBinding = syncTypeDecl.resolveBinding();
  assert (syncTypeBinding != null);

  String asyncName = RemoteServiceUtilities.computeAsyncTypeName(problem.getProblemArguments()[0]);
  AST ast = context.getASTRoot().getAST();
  Name name = ast.newName(asyncName);

  /*
   * HACK: NewCUUsingWizardProposal wants a name that has a parent expression so we create an
   * assignment so that the name has a valid parent
   */
  ast.newAssignment().setLeftHandSide(name);

  IJavaElement typeContainer = syncType.getParent();
  if (typeContainer.getElementType() == IJavaElement.COMPILATION_UNIT) {
    typeContainer = syncType.getPackageFragment();
  }

  // Add a create async interface proposal
  CreateAsyncInterfaceProposal createAsyncInterfaceProposal = new CreateAsyncInterfaceProposal(
      context.getCompilationUnit(), name, K_INTERFACE, typeContainer, 2, syncTypeBinding);

  // Add the stock create interface proposal
  NewCompilationUnitUsingWizardProposal fallbackProposal = new NewCompilationUnitUsingWizardProposal(
      context.getCompilationUnit(), name, K_INTERFACE, context.getCompilationUnit().getParent(), 1);

  return Arrays.<IJavaCompletionProposal>asList(createAsyncInterfaceProposal, fallbackProposal);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:43,代码来源:CreateAsyncInterfaceProposal.java


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