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

Java ASTRewriteCorrectionProposal类代码示例

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

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



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

示例1: addRedundantSuperInterfaceProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void addRedundantSuperInterfaceProposal(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
  ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
  if (!(selectedNode instanceof Name)) {
    return;
  }
  ASTNode node = ASTNodes.getNormalizedNode(selectedNode);

  ASTRewrite rewrite = ASTRewrite.create(node.getAST());
  rewrite.remove(node, null);

  String label = CorrectionMessages.LocalCorrectionsSubProcessor_remove_redundant_superinterface;
  Image image =
      JavaPluginImages.get(
          JavaPluginImages
              .IMG_TOOL_DELETE); // JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);

  ASTRewriteCorrectionProposal proposal =
      new ASTRewriteCorrectionProposal(
          label,
          context.getCompilationUnit(),
          rewrite,
          IProposalRelevance.REMOVE_REDUNDANT_SUPER_INTERFACE,
          image);
  proposals.add(proposal);
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:LocalCorrectionsSubProcessor.java


示例2: createNoSideEffectProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
private static ASTRewriteCorrectionProposal createNoSideEffectProposal(
    IInvocationContext context,
    SimpleName nodeToQualify,
    IVariableBinding fieldBinding,
    String label,
    int relevance) {
  AST ast = nodeToQualify.getAST();

  Expression qualifier;
  if (Modifier.isStatic(fieldBinding.getModifiers())) {
    ITypeBinding declaringClass = fieldBinding.getDeclaringClass();
    qualifier = ast.newSimpleName(declaringClass.getTypeDeclaration().getName());
  } else {
    qualifier = ast.newThisExpression();
  }

  ASTRewrite rewrite = ASTRewrite.create(ast);
  FieldAccess access = ast.newFieldAccess();
  access.setName((SimpleName) rewrite.createCopyTarget(nodeToQualify));
  access.setExpression(qualifier);
  rewrite.replace(nodeToQualify, access, null);

  Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
  return new ASTRewriteCorrectionProposal(
      label, context.getCompilationUnit(), rewrite, relevance, image);
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:LocalCorrectionsSubProcessor.java


示例3: createMissingDefaultProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
private static void createMissingDefaultProposal(
    IInvocationContext context,
    SwitchStatement switchStatement,
    Image image,
    Collection<ICommandAccess> proposals) {
  AST ast = switchStatement.getAST();
  ASTRewrite astRewrite = ASTRewrite.create(ast);
  ListRewrite listRewrite =
      astRewrite.getListRewrite(switchStatement, SwitchStatement.STATEMENTS_PROPERTY);

  SwitchCase newSwitchCase = ast.newSwitchCase();
  newSwitchCase.setExpression(null);
  listRewrite.insertLast(newSwitchCase, null);
  listRewrite.insertLast(ast.newBreakStatement(), null);

  String label = CorrectionMessages.LocalCorrectionsSubProcessor_add_default_case_description;
  proposals.add(
      new ASTRewriteCorrectionProposal(
          label,
          context.getCompilationUnit(),
          astRewrite,
          IProposalRelevance.ADD_MISSING_DEFAULT_CASE,
          image));
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:LocalCorrectionsSubProcessor.java


示例4: createCastProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static ASTRewriteCorrectionProposal createCastProposal(
    IInvocationContext context,
    ITypeBinding castTypeBinding,
    Expression nodeToCast,
    int relevance) {
  ICompilationUnit cu = context.getCompilationUnit();

  String label;
  String castType =
      BindingLabelProvider.getBindingLabel(castTypeBinding, JavaElementLabels.ALL_DEFAULT);
  if (nodeToCast.getNodeType() == ASTNode.CAST_EXPRESSION) {
    label =
        Messages.format(
            CorrectionMessages.TypeMismatchSubProcessor_changecast_description, castType);
  } else {
    label =
        Messages.format(
            CorrectionMessages.TypeMismatchSubProcessor_addcast_description, castType);
  }
  return new CastCorrectionProposal(label, cu, nodeToCast, castTypeBinding, relevance);
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:TypeMismatchSubProcessor.java


示例5: removeOverrideAnnotationProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void removeOverrideAnnotationProposal(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals)
    throws CoreException {
  ICompilationUnit cu = context.getCompilationUnit();

  ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
  if (!(selectedNode instanceof MethodDeclaration)) {
    return;
  }
  MethodDeclaration methodDecl = (MethodDeclaration) selectedNode;
  Annotation annot = findAnnotation("java.lang.Override", methodDecl.modifiers()); // $NON-NLS-1$
  if (annot != null) {
    ASTRewrite rewrite = ASTRewrite.create(annot.getAST());
    rewrite.remove(annot, null);
    String label = CorrectionMessages.ModifierCorrectionSubProcessor_remove_override;
    Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
    ASTRewriteCorrectionProposal proposal =
        new ASTRewriteCorrectionProposal(
            label, cu, rewrite, IProposalRelevance.REMOVE_OVERRIDE, image);
    proposals.add(proposal);

    QuickAssistProcessor.getCreateInSuperClassProposals(context, methodDecl.getName(), proposals);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:ModifierCorrectionSubProcessor.java


示例6: removeMismatchedArguments

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void removeMismatchedArguments(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
  ICompilationUnit cu = context.getCompilationUnit();
  ASTNode selectedNode = problem.getCoveredNode(context.getASTRoot());
  if (!(selectedNode instanceof SimpleName)) {
    return;
  }

  ASTNode normalizedNode = ASTNodes.getNormalizedNode(selectedNode);
  if (normalizedNode instanceof ParameterizedType) {
    ASTRewrite rewrite = ASTRewrite.create(normalizedNode.getAST());
    ParameterizedType pt = (ParameterizedType) normalizedNode;
    ASTNode mt = rewrite.createMoveTarget(pt.getType());
    rewrite.replace(pt, mt, null);
    String label = CorrectionMessages.TypeArgumentMismatchSubProcessor_removeTypeArguments;
    Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
    ASTRewriteCorrectionProposal proposal =
        new ASTRewriteCorrectionProposal(
            label, cu, rewrite, IProposalRelevance.REMOVE_TYPE_ARGUMENTS, image);
    proposals.add(proposal);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:TypeArgumentMismatchSubProcessor.java


示例7: addMethodWithConstrNameProposals

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void addMethodWithConstrNameProposals(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
  ICompilationUnit cu = context.getCompilationUnit();

  ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
  if (selectedNode instanceof MethodDeclaration) {
    MethodDeclaration declaration = (MethodDeclaration) selectedNode;

    ASTRewrite rewrite = ASTRewrite.create(declaration.getAST());
    rewrite.set(declaration, MethodDeclaration.CONSTRUCTOR_PROPERTY, Boolean.TRUE, null);

    String label = CorrectionMessages.ReturnTypeSubProcessor_constrnamemethod_description;
    Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
    ASTRewriteCorrectionProposal proposal =
        new ASTRewriteCorrectionProposal(
            label, cu, rewrite, IProposalRelevance.CHANGE_TO_CONSTRUCTOR, image);
    proposals.add(proposal);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:ReturnTypeSubProcessor.java


示例8: createTypeRefChangeFullProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
static CUCorrectionProposal createTypeRefChangeFullProposal(
    ICompilationUnit cu, ITypeBinding binding, ASTNode node, int relevance) {
  ASTRewrite rewrite = ASTRewrite.create(node.getAST());
  String label =
      Messages.format(
          CorrectionMessages.UnresolvedElementsSubProcessor_change_full_type_description,
          BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_DEFAULT));
  Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);

  ASTRewriteCorrectionProposal proposal =
      new ASTRewriteCorrectionProposal(label, cu, rewrite, relevance, image);

  ImportRewrite imports = proposal.createImportRewrite((CompilationUnit) node.getRoot());
  Type type = imports.addImport(binding, node.getAST());

  rewrite.replace(node, type, null);
  return proposal;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:UnresolvedElementsSubProcessor.java


示例9: getRemoveJavadocTagProposals

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void getRemoveJavadocTagProposals(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
  ASTNode node = problem.getCoveringNode(context.getASTRoot());
  while (node != null && !(node instanceof TagElement)) {
    node = node.getParent();
  }
  if (node == null) {
    return;
  }
  ASTRewrite rewrite = ASTRewrite.create(node.getAST());
  rewrite.remove(node, null);

  String label = CorrectionMessages.JavadocTagsSubProcessor_removetag_description;
  Image image =
      JavaPluginImages.get(
          JavaPluginImages
              .IMG_TOOL_DELETE); // JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
  proposals.add(
      new ASTRewriteCorrectionProposal(
          label, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_TAG, image));
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:JavadocTagsSubProcessor.java


示例10: addRedundantSuperInterfaceProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void addRedundantSuperInterfaceProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
	ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
	if (!(selectedNode instanceof Name)) {
		return;
	}
	ASTNode node= ASTNodes.getNormalizedNode(selectedNode);

	ASTRewrite rewrite= ASTRewrite.create(node.getAST());
	rewrite.remove(node, null);

	String label= CorrectionMessages.LocalCorrectionsSubProcessor_remove_redundant_superinterface;
	Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);

	ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_REDUNDANT_SUPER_INTERFACE, image);
	proposals.add(proposal);

}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:LocalCorrectionsSubProcessor.java


示例11: createNoSideEffectProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
private static ASTRewriteCorrectionProposal createNoSideEffectProposal(IInvocationContext context, SimpleName nodeToQualify, IVariableBinding fieldBinding, String label, int relevance) {
	AST ast= nodeToQualify.getAST();

	Expression qualifier;
	if (Modifier.isStatic(fieldBinding.getModifiers())) {
		ITypeBinding declaringClass= fieldBinding.getDeclaringClass();
		qualifier= ast.newSimpleName(declaringClass.getTypeDeclaration().getName());
	} else {
		qualifier= ast.newThisExpression();
	}

	ASTRewrite rewrite= ASTRewrite.create(ast);
	FieldAccess access= ast.newFieldAccess();
	access.setName((SimpleName) rewrite.createCopyTarget(nodeToQualify));
	access.setExpression(qualifier);
	rewrite.replace(nodeToQualify, access, null);


	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
	return new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, relevance, image);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:LocalCorrectionsSubProcessor.java


示例12: addCasesOmittedProposals

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void addCasesOmittedProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
	ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
	if (selectedNode instanceof Expression && selectedNode.getLocationInParent() == SwitchStatement.EXPRESSION_PROPERTY) {
		AST ast= selectedNode.getAST();
		SwitchStatement parent= (SwitchStatement) selectedNode.getParent();
		
		for (Statement statement : (List<Statement>) parent.statements()) {
			if (statement instanceof SwitchCase && ((SwitchCase) statement).isDefault()) {
				
				// insert //$CASES-OMITTED$:
				ASTRewrite rewrite= ASTRewrite.create(ast);
				rewrite.setTargetSourceRangeComputer(new NoCommentSourceRangeComputer());
				ListRewrite listRewrite= rewrite.getListRewrite(parent, SwitchStatement.STATEMENTS_PROPERTY);
				ASTNode casesOmittedComment= rewrite.createStringPlaceholder("//$CASES-OMITTED$", ASTNode.EMPTY_STATEMENT); //$NON-NLS-1$
				listRewrite.insertBefore(casesOmittedComment, statement, null);
				
				String label= CorrectionMessages.LocalCorrectionsSubProcessor_insert_cases_omitted;
				Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
				ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.INSERT_CASES_OMITTED, image);
				proposals.add(proposal);
				break;
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:LocalCorrectionsSubProcessor.java


示例13: removeOverrideAnnotationProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void removeOverrideAnnotationProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws CoreException {
	ICompilationUnit cu= context.getCompilationUnit();

	ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
	if (!(selectedNode instanceof MethodDeclaration)) {
		return;
	}
	MethodDeclaration methodDecl= (MethodDeclaration) selectedNode;
	Annotation annot= findAnnotation("java.lang.Override", methodDecl.modifiers()); //$NON-NLS-1$
	if (annot != null) {
		ASTRewrite rewrite= ASTRewrite.create(annot.getAST());
		rewrite.remove(annot, null);
		String label= CorrectionMessages.ModifierCorrectionSubProcessor_remove_override;
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
		ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, IProposalRelevance.REMOVE_OVERRIDE, image);
		proposals.add(proposal);

		QuickAssistProcessor.getCreateInSuperClassProposals(context, methodDecl.getName(), proposals);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:ModifierCorrectionSubProcessor.java


示例14: addGetterProposal

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
/**
 * Proposes a getter for this field.
 * 
 * @param context the proposal parameter
 * @param relevance relevance of this proposal
 * @return the proposal if available or null
 */
private static ChangeCorrectionProposal addGetterProposal(ProposalParameter context, int relevance) {
	IMethodBinding method= findGetter(context);
	if (method != null) {
		Expression mi= createMethodInvocation(context, method, null);
		context.astRewrite.replace(context.accessNode, mi, null);

		String label= Messages.format(CorrectionMessages.GetterSetterCorrectionSubProcessor_replacewithgetter_description, BasicElementLabels.getJavaCodeString(ASTNodes.asString(context.accessNode)));
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
		ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.compilationUnit, context.astRewrite, relevance, image);
		return proposal;
	} else {
		IJavaElement element= context.variableBinding.getJavaElement();
		if (element instanceof IField) {
			IField field= (IField) element;
			try {
				if (RefactoringAvailabilityTester.isSelfEncapsulateAvailable(field))
					return new SelfEncapsulateFieldProposal(relevance, field);
			} catch (JavaModelException e) {
				JavaPlugin.log(e);
			}
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:GetterSetterCorrectionSubProcessor.java


示例15: removeMismatchedArguments

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void removeMismatchedArguments(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals){
	ICompilationUnit cu= context.getCompilationUnit();
	ASTNode selectedNode= problem.getCoveredNode(context.getASTRoot());
	if (!(selectedNode instanceof SimpleName)) {
		return;
	}

	ASTNode normalizedNode=ASTNodes.getNormalizedNode(selectedNode);
	if (normalizedNode instanceof ParameterizedType) {
		ASTRewrite rewrite = ASTRewrite.create(normalizedNode.getAST());
		ParameterizedType pt = (ParameterizedType) normalizedNode;
		ASTNode mt = rewrite.createMoveTarget(pt.getType());
		rewrite.replace(pt, mt, null);
		String label= CorrectionMessages.TypeArgumentMismatchSubProcessor_removeTypeArguments;
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
		ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, IProposalRelevance.REMOVE_TYPE_ARGUMENTS, image);
		proposals.add(proposal);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:TypeArgumentMismatchSubProcessor.java


示例16: addMethodWithConstrNameProposals

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void addMethodWithConstrNameProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
	ICompilationUnit cu= context.getCompilationUnit();

	ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
	if (selectedNode instanceof MethodDeclaration) {
		MethodDeclaration declaration= (MethodDeclaration) selectedNode;

		ASTRewrite rewrite= ASTRewrite.create(declaration.getAST());
		rewrite.set(declaration, MethodDeclaration.CONSTRUCTOR_PROPERTY, Boolean.TRUE, null);

		String label= CorrectionMessages.ReturnTypeSubProcessor_constrnamemethod_description;
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
		ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, IProposalRelevance.CHANGE_TO_CONSTRUCTOR, image);
		proposals.add(proposal);
	}

}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:ReturnTypeSubProcessor.java


示例17: getAddFinallyProposals

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
private static boolean getAddFinallyProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
	TryStatement tryStatement= ASTResolving.findParentTryStatement(node);
	if (tryStatement == null || tryStatement.getFinally() != null) {
		return false;
	}
	Statement statement= ASTResolving.findParentStatement(node);
	if (tryStatement != statement && tryStatement.getBody() != statement) {
		return false; // an node inside a catch or finally block
	}

	if (resultingCollections == null) {
		return true;
	}

	AST ast= tryStatement.getAST();
	ASTRewrite rewrite= ASTRewrite.create(ast);
	Block finallyBody= ast.newBlock();

	rewrite.set(tryStatement, TryStatement.FINALLY_PROPERTY, finallyBody, null);

	String label= CorrectionMessages.QuickAssistProcessor_addfinallyblock_description;
	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
	ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.ADD_FINALLY_BLOCK, image);
	resultingCollections.add(proposal);
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:QuickAssistProcessor.java


示例18: getAddElseProposals

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
private static boolean getAddElseProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
	if (!(node instanceof IfStatement)) {
		return false;
	}
	IfStatement ifStatement= (IfStatement) node;
	if (ifStatement.getElseStatement() != null) {
		return false;
	}

	if (resultingCollections == null) {
		return true;
	}

	AST ast= node.getAST();
	ASTRewrite rewrite= ASTRewrite.create(ast);
	Block body= ast.newBlock();

	rewrite.set(ifStatement, IfStatement.ELSE_STATEMENT_PROPERTY, body, null);

	String label= CorrectionMessages.QuickAssistProcessor_addelseblock_description;
	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
	ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.ADD_ELSE_BLOCK, image);
	resultingCollections.add(proposal);
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:QuickAssistProcessor.java


示例19: getAmbiguosTypeReferenceProposals

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void getAmbiguosTypeReferenceProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws CoreException {
	final ICompilationUnit cu= context.getCompilationUnit();
	int offset= problem.getOffset();
	int len= problem.getLength();

	IJavaElement[] elements= cu.codeSelect(offset, len);
	for (int i= 0; i < elements.length; i++) {
		IJavaElement curr= elements[i];
		if (curr instanceof IType && !TypeFilter.isFiltered((IType) curr)) {
			String qualifiedTypeName= ((IType) curr).getFullyQualifiedName('.');

			CompilationUnit root= context.getASTRoot();

			String label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_importexplicit_description, BasicElementLabels.getJavaElementName(qualifiedTypeName));
			Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL);
			ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, ASTRewrite.create(root.getAST()), IProposalRelevance.IMPORT_EXPLICIT, image);

			ImportRewrite imports= proposal.createImportRewrite(root);
			imports.addImport(qualifiedTypeName);

			proposals.add(proposal);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:UnresolvedElementsSubProcessor.java


示例20: getInvalidQualificationProposals

import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; //导入依赖的package包/类
public static void getInvalidQualificationProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
	ASTNode node= problem.getCoveringNode(context.getASTRoot());
	if (!(node instanceof Name)) {
		return;
	}
	Name name= (Name) node;
	IBinding binding= name.resolveBinding();
	if (!(binding instanceof ITypeBinding)) {
		return;
	}
	ITypeBinding typeBinding= (ITypeBinding)binding;

	AST ast= node.getAST();
	ASTRewrite rewrite= ASTRewrite.create(ast);
	rewrite.replace(name, ast.newName(typeBinding.getQualifiedName()), null);

	String label= CorrectionMessages.JavadocTagsSubProcessor_qualifylinktoinner_description;
	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
	ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.QUALIFY_INNER_TYPE_NAME, image);

	proposals.add(proposal);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JavadocTagsSubProcessor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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