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

Java TextEditGroup类代码示例

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

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



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

示例1: rewriteAST

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel positionGroups) throws CoreException {
	final ASTRewrite rewrite = cuRewrite.getASTRewrite();
	VariableDeclarationFragment fragment = null;
	for (int i = 0; i < fNodes.length; i++) {
		final ASTNode node = fNodes[i];

		final AST ast = node.getAST();

		fragment = ast.newVariableDeclarationFragment();
		fragment.setName(ast.newSimpleName(NAME_FIELD));

		final FieldDeclaration declaration = ast.newFieldDeclaration(fragment);
		declaration.setType(ast.newPrimitiveType(PrimitiveType.LONG));
		declaration.modifiers().addAll(ASTNodeFactory.newModifiers(ast, Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL));

		if (!addInitializer(fragment, node)) {
			continue;
		}

		if (fragment.getInitializer() != null) {

			final TextEditGroup editGroup = createTextEditGroup(FixMessages.SerialVersion_group_description, cuRewrite);
			if (node instanceof AbstractTypeDeclaration) {
				rewrite.getListRewrite(node, ((AbstractTypeDeclaration) node).getBodyDeclarationsProperty()).insertAt(declaration, 0, editGroup);
			} else if (node instanceof AnonymousClassDeclaration) {
				rewrite.getListRewrite(node, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY).insertAt(declaration, 0, editGroup);
			} else if (node instanceof ParameterizedType) {
				final ParameterizedType type = (ParameterizedType) node;
				final ASTNode parent = type.getParent();
				if (parent instanceof ClassInstanceCreation) {
					final ClassInstanceCreation creation = (ClassInstanceCreation) parent;
					final AnonymousClassDeclaration anonymous = creation.getAnonymousClassDeclaration();
					if (anonymous != null) {
						rewrite.getListRewrite(anonymous, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY).insertAt(declaration, 0, editGroup);
					}
				}
			} else {
				Assert.isTrue(false);
			}

			addLinkedPositions(rewrite, fragment, positionGroups);
		}

		final String comment = CodeGeneration.getFieldComment(fUnit, declaration.getType().toString(), NAME_FIELD, "\n" /* StubUtility.getLineDelimiterUsed(fUnit) */);
		if (comment != null && comment.length() > 0 && !"/**\n *\n */\n".equals(comment)) {
			final Javadoc doc = (Javadoc) rewrite.createStringPlaceholder(comment, ASTNode.JAVADOC);
			declaration.setJavadoc(doc);
		}
	}
	if (fragment == null) {
		return;
	}

	positionGroups.setEndPosition(rewrite.track(fragment));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:57,代码来源:AbstractSerialVersionOperation.java


示例2: handleManyMany

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
protected void handleManyMany(ASTNode[] replacements, TextEditGroup description) {
	ListRewrite container= fRewrite.getListRewrite(fToReplace[0].getParent(), (ChildListPropertyDescriptor)fDescriptor);
	if (fToReplace.length == replacements.length) {
		for (int i= 0; i < fToReplace.length; i++) {
			container.replace(fToReplace[i], replacements[i], description);
		}
	} else if (fToReplace.length < replacements.length) {
		for (int i= 0; i < fToReplace.length; i++) {
			container.replace(fToReplace[i], replacements[i], description);
		}
		for (int i= fToReplace.length; i < replacements.length; i++) {
			container.insertAfter(replacements[i], replacements[i - 1], description);
		}
	} else if (fToReplace.length > replacements.length) {
		int delta= fToReplace.length - replacements.length;
		for(int i= 0; i < delta; i++) {
			container.remove(fToReplace[i], description);
		}
		for (int i= delta, r= 0; i < fToReplace.length; i++, r++) {
			container.replace(fToReplace[i], replacements[r], description);
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:24,代码来源:ReplaceRewrite.java


示例3: handleOneMany

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
@Override
protected void handleOneMany(ASTNode[] replacements, TextEditGroup description) {
	AST ast= fToReplace[0].getAST();
	// to replace == 1, but more than one replacement. Have to check if we
	// need to insert a block to not change structure
	if (ASTNodes.isControlStatementBody(fDescriptor)) {
		Block block= ast.newBlock();
		ListRewrite statements= fRewrite.getListRewrite(block, Block.STATEMENTS_PROPERTY);
		for (int i= 0; i < replacements.length; i++) {
			statements.insertLast(replacements[i], description);
		}
		fRewrite.replace(fToReplace[0], block, description);
	} else {
		ListRewrite container= fRewrite.getListRewrite(fToReplace[0].getParent(), (ChildListPropertyDescriptor)fDescriptor);
		container.replace(fToReplace[0], replacements[0], description);
		for (int i= 1; i < replacements.length; i++) {
			container.insertAfter(replacements[i], replacements[i - 1], description);
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:StatementRewrite.java


示例4: removePureTypeAnnotations

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
/**
 * Removes all {@link Annotation} whose only {@link Target} is {@link ElementType#TYPE_USE} from
 * <code>node</code>'s <code>childListProperty</code>.
 * <p>
 * In a combination of {@link ElementType#TYPE_USE} and {@link ElementType#TYPE_PARAMETER}
 * the latter is ignored, because this is implied by the former and creates no ambiguity.</p>
 *
 * @param node ASTNode
 * @param childListProperty child list property
 * @param rewrite rewrite that removes the nodes
 * @param editGroup the edit group in which to collect the corresponding text edits, or null if
 *            ungrouped
 */
public static void removePureTypeAnnotations(ASTNode node, ChildListPropertyDescriptor childListProperty, ASTRewrite rewrite, TextEditGroup editGroup) {
	CompilationUnit root= (CompilationUnit) node.getRoot();
	if (!JavaModelUtil.is18OrHigher(root.getJavaElement().getJavaProject())) {
		return;
	}
	ListRewrite listRewrite= rewrite.getListRewrite(node, childListProperty);
	@SuppressWarnings("unchecked")
	List<? extends ASTNode> children= (List<? extends ASTNode>) node.getStructuralProperty(childListProperty);
	for (ASTNode child : children) {
		if (child instanceof Annotation) {
			Annotation annotation= (Annotation) child;
			if (isPureTypeAnnotation(annotation)) {
				listRewrite.remove(child, editGroup);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:31,代码来源:TypeAnnotationRewrite.java


示例5: addOverrideAnnotation

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
/**
 * Adds <code>@Override</code> annotation to <code>methodDecl</code> if not already present and
 * if requested by code style settings or compiler errors/warnings settings.
 *
 * @param settings the code generation style settings, may be <code>null</code>
 * @param project the Java project used to access the compiler settings
 * @param rewrite the ASTRewrite
 * @param imports the ImportRewrite
 * @param methodDecl the method declaration to add the annotation to
 * @param isDeclaringTypeInterface <code>true</code> if the type declaring the method overridden
 *            by <code>methodDecl</code> is an interface
 * @param group the text edit group, may be <code>null</code>
 */
public static void addOverrideAnnotation(CodeGenerationSettings settings, IJavaProject project, ASTRewrite rewrite, ImportRewrite imports, MethodDeclaration methodDecl,
		boolean isDeclaringTypeInterface, TextEditGroup group) {
	if (!JavaModelUtil.is50OrHigher(project)) {
		return;
	}
	if (isDeclaringTypeInterface) {
		String version= project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
		if (JavaModelUtil.isVersionLessThan(version, JavaCore.VERSION_1_6))
		{
			return; // not allowed in 1.5
		}
		if (JavaCore.DISABLED.equals(project.getOption(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION_FOR_INTERFACE_METHOD_IMPLEMENTATION, true)))
		{
			return; // user doesn't want to use 1.6 style
		}
	}
	if ((settings != null && settings.overrideAnnotation) || !JavaCore.IGNORE.equals(project.getOption(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION, true))) {
		createOverrideAnnotation(rewrite, imports, methodDecl, group);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:34,代码来源:StubUtility2.java


示例6: rewriteAST

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel linkedModel) throws CoreException {
	ASTRewrite rewrite= cuRewrite.getASTRewrite();
	IBinding binding= fUnusedName.resolveBinding();
	CompilationUnit root= (CompilationUnit) fUnusedName.getRoot();
	String displayString= FixMessages.UnusedCodeFix_RemoveUnusedTypeParameter_description;
	TextEditGroup group= createTextEditGroup(displayString, cuRewrite);

	if (binding.getKind() == IBinding.TYPE) {
		ITypeBinding decl= ((ITypeBinding) binding).getTypeDeclaration();
		ASTNode declaration= root.findDeclaringNode(decl);
		if (declaration.getParent() instanceof TypeDeclarationStatement) {
			declaration= declaration.getParent();
		}
		rewrite.remove(declaration, group);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:UnusedCodeFix.java


示例7: splitUpDeclarations

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
private void splitUpDeclarations(ASTRewrite rewrite, TextEditGroup group, VariableDeclarationFragment frag, VariableDeclarationStatement originalStatement, List<Expression> sideEffects) {
	if (sideEffects.size() > 0) {
		ListRewrite statementRewrite= rewrite.getListRewrite(originalStatement.getParent(), (ChildListPropertyDescriptor) originalStatement.getLocationInParent());

		Statement previousStatement= originalStatement;
		for (int i= 0; i < sideEffects.size(); i++) {
			Expression sideEffect= sideEffects.get(i);
			Expression movedInit= (Expression) rewrite.createMoveTarget(sideEffect);
			ExpressionStatement wrapped= rewrite.getAST().newExpressionStatement(movedInit);
			statementRewrite.insertAfter(wrapped, previousStatement, group);
			previousStatement= wrapped;
		}

		VariableDeclarationStatement newDeclaration= null;
		List<VariableDeclarationFragment> fragments= originalStatement.fragments();
		int fragIndex= fragments.indexOf(frag);
		ListIterator<VariableDeclarationFragment> fragmentIterator= fragments.listIterator(fragIndex+1);
		while (fragmentIterator.hasNext()) {
			VariableDeclarationFragment currentFragment= fragmentIterator.next();
			VariableDeclarationFragment movedFragment= (VariableDeclarationFragment) rewrite.createMoveTarget(currentFragment);
			if (newDeclaration == null) {
				newDeclaration= rewrite.getAST().newVariableDeclarationStatement(movedFragment);
				Type copiedType= (Type) rewrite.createCopyTarget(originalStatement.getType());
				newDeclaration.setType(copiedType);
			} else {
				newDeclaration.fragments().add(movedFragment);
			}
		}
		if (newDeclaration != null){
			statementRewrite.insertAfter(newDeclaration, previousStatement, group);
			if (originalStatement.fragments().size() == newDeclaration.fragments().size() + 1){
				rewrite.remove(originalStatement, group);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:37,代码来源:UnusedCodeFix.java


示例8: removeVariableWithInitializer

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
private void removeVariableWithInitializer(ASTRewrite rewrite, ASTNode initializerNode, ASTNode statementNode, TextEditGroup group) {
	boolean performRemove= fForceRemove;
	if (!performRemove) {
		ArrayList<Expression> sideEffectNodes= new ArrayList<>();
		initializerNode.accept(new SideEffectFinder(sideEffectNodes));
		performRemove= sideEffectNodes.isEmpty();
	}
	if (performRemove) {
		removeStatement(rewrite, statementNode, group);
		fRemovedAssignmentsCount++;
	} else {
		ASTNode initNode = rewrite.createMoveTarget(initializerNode);
		ExpressionStatement statement = rewrite.getAST().newExpressionStatement((Expression) initNode);
		rewrite.replace(statementNode, statement, null);
		fAlteredAssignmentsCount++;
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:UnusedCodeFix.java


示例9: replaceCast

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
private static void replaceCast(CastExpression castExpression, Expression replacement, ASTRewrite rewrite, TextEditGroup group) {
	boolean castEnclosedInNecessaryParentheses= castExpression.getParent() instanceof ParenthesizedExpression
			&& NecessaryParenthesesChecker.needsParentheses(castExpression, castExpression.getParent().getParent(), castExpression.getParent().getLocationInParent());

	ASTNode toReplace= castEnclosedInNecessaryParentheses ? castExpression.getParent() : castExpression;
	ASTNode move;
	if (NecessaryParenthesesChecker.needsParentheses(replacement, toReplace.getParent(), toReplace.getLocationInParent())) {
		if (replacement.getParent() instanceof ParenthesizedExpression) {
			move= rewrite.createMoveTarget(replacement.getParent());
		} else if (castEnclosedInNecessaryParentheses) {
			toReplace= castExpression;
			move= rewrite.createMoveTarget(replacement);
		} else {
			ParenthesizedExpression parentheses= replacement.getAST().newParenthesizedExpression();
			parentheses.setExpression((Expression) rewrite.createMoveTarget(replacement));
			move= parentheses;
		}
	} else {
		move= rewrite.createMoveTarget(replacement);
	}
	rewrite.replace(toReplace, move, group);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:UnusedCodeFix.java


示例10: handleManyMany

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
protected void handleManyMany(ASTNode[] replacements, TextEditGroup description) {
  ListRewrite container =
      fRewrite.getListRewrite(
          fToReplace[0].getParent(), (ChildListPropertyDescriptor) fDescriptor);
  if (fToReplace.length == replacements.length) {
    for (int i = 0; i < fToReplace.length; i++) {
      container.replace(fToReplace[i], replacements[i], description);
    }
  } else if (fToReplace.length < replacements.length) {
    for (int i = 0; i < fToReplace.length; i++) {
      container.replace(fToReplace[i], replacements[i], description);
    }
    for (int i = fToReplace.length; i < replacements.length; i++) {
      container.insertAfter(replacements[i], replacements[i - 1], description);
    }
  } else if (fToReplace.length > replacements.length) {
    int delta = fToReplace.length - replacements.length;
    for (int i = 0; i < delta; i++) {
      container.remove(fToReplace[i], description);
    }
    for (int i = delta, r = 0; i < fToReplace.length; i++, r++) {
      container.replace(fToReplace[i], replacements[r], description);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:ReplaceRewrite.java


示例11: replace

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
public void replace(ASTRewrite rewrite, ASTNode replacement, TextEditGroup textEditGroup) {
  ASTNode groupNode = getGroupRoot();

  List<Expression> allOperands = findGroupMembersInOrderFor(getGroupRoot());
  if (allOperands.size() == fOperands.size()) {
    if (replacement instanceof Name && groupNode.getParent() instanceof ParenthesizedExpression) {
      // replace including the parenthesized expression around it
      rewrite.replace(groupNode.getParent(), replacement, textEditGroup);
    } else {
      rewrite.replace(groupNode, replacement, textEditGroup);
    }
    return;
  }

  rewrite.replace(fOperands.get(0), replacement, textEditGroup);
  int first = allOperands.indexOf(fOperands.get(0));
  int after = first + fOperands.size();
  for (int i = first + 1; i < after; i++) {
    rewrite.remove(allOperands.get(i), textEditGroup);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:AssociativeInfixExpressionFragment.java


示例12: handleOneMany

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
@Override
protected void handleOneMany(ASTNode[] replacements, TextEditGroup description) {
  AST ast = fToReplace[0].getAST();
  // to replace == 1, but more than one replacement. Have to check if we
  // need to insert a block to not change structure
  if (ASTNodes.isControlStatementBody(fDescriptor)) {
    Block block = ast.newBlock();
    ListRewrite statements = fRewrite.getListRewrite(block, Block.STATEMENTS_PROPERTY);
    for (int i = 0; i < replacements.length; i++) {
      statements.insertLast(replacements[i], description);
    }
    fRewrite.replace(fToReplace[0], block, description);
  } else {
    ListRewrite container =
        fRewrite.getListRewrite(
            fToReplace[0].getParent(), (ChildListPropertyDescriptor) fDescriptor);
    container.replace(fToReplace[0], replacements[0], description);
    for (int i = 1; i < replacements.length; i++) {
      container.insertAfter(replacements[i], replacements[i - 1], description);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:StatementRewrite.java


示例13: rewriteAST

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model)
    throws CoreException {
  ASTRewrite rewrite = cuRewrite.getASTRewrite();
  TextEditGroup group = createTextEditGroup(getDescription(), cuRewrite);
  AST ast = rewrite.getAST();

  FieldAccess fieldAccess = ast.newFieldAccess();

  ThisExpression thisExpression = ast.newThisExpression();
  if (fQualifier != null) thisExpression.setQualifier(ast.newName(fQualifier));

  fieldAccess.setExpression(thisExpression);
  fieldAccess.setName((SimpleName) rewrite.createMoveTarget(fName));

  rewrite.replace(fName, fieldAccess, group);
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:CodeStyleFix.java


示例14: rewriteAST

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model)
    throws CoreException {
  ASTRewrite rewrite = cuRewrite.getASTRewrite();
  String label;
  if (fBodyProperty == IfStatement.THEN_STATEMENT_PROPERTY) {
    label = FixMessages.CodeStyleFix_ChangeIfToBlock_desription;
  } else if (fBodyProperty == IfStatement.ELSE_STATEMENT_PROPERTY) {
    label = FixMessages.CodeStyleFix_ChangeElseToBlock_description;
  } else {
    label = FixMessages.CodeStyleFix_ChangeControlToBlock_description;
  }

  TextEditGroup group = createTextEditGroup(label, cuRewrite);
  ASTNode moveTarget = rewrite.createMoveTarget(fBody);
  Block replacingBody = cuRewrite.getRoot().getAST().newBlock();
  replacingBody.statements().add(moveTarget);
  rewrite.set(fControlStatement, fBodyProperty, replacingBody, group);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:ControlStatementsFix.java


示例15: rewriteAST

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void rewriteAST(
    CompilationUnitRewrite cuRewrite, LinkedProposalModel linkedProposalPositions)
    throws CoreException {
  AST ast = cuRewrite.getAST();
  ASTRewrite rewrite = cuRewrite.getASTRewrite();
  Modifier newModifier = ast.newModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
  TextEditGroup textEditGroup =
      createTextEditGroup(
          CorrectionMessages.UnimplementedCodeFix_TextEditGroup_label, cuRewrite);
  rewrite
      .getListRewrite(fTypeDeclaration, TypeDeclaration.MODIFIERS2_PROPERTY)
      .insertLast(newModifier, textEditGroup);

  LinkedProposalPositionGroup group =
      new LinkedProposalPositionGroup("modifier"); // $NON-NLS-1$
  group.addPosition(rewrite.track(newModifier), !linkedProposalPositions.hasLinkedPositions());
  linkedProposalPositions.addPositionGroup(group);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:UnimplementedCodeFix.java


示例16: rewriteAST

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model)
    throws CoreException {
  AST ast = cuRewrite.getRoot().getAST();
  ListRewrite listRewrite =
      cuRewrite
          .getASTRewrite()
          .getListRewrite(fBodyDeclaration, fBodyDeclaration.getModifiersProperty());
  Annotation newAnnotation = ast.newMarkerAnnotation();
  newAnnotation.setTypeName(ast.newSimpleName(fAnnotation));
  TextEditGroup group =
      createTextEditGroup(
          Messages.format(
              FixMessages.Java50Fix_AddMissingAnnotation_description,
              BasicElementLabels.getJavaElementName(fAnnotation)),
          cuRewrite);
  listRewrite.insertFirst(newAnnotation, group);
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:Java50Fix.java


示例17: checkExisting

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
boolean checkExisting(
    List<IExtendedModifier> existingModifiers,
    ListRewrite listRewrite,
    TextEditGroup editGroup) {
  for (Object mod : existingModifiers) {
    if (mod instanceof MarkerAnnotation) {
      MarkerAnnotation annotation = (MarkerAnnotation) mod;
      String existingName = annotation.getTypeName().getFullyQualifiedName();
      int lastDot = fAnnotationToRemove.lastIndexOf('.');
      if (existingName.equals(fAnnotationToRemove)
          || (lastDot != -1
              && fAnnotationToRemove.substring(lastDot + 1).equals(existingName))) {
        if (!fAllowRemove) return false; // veto this change
        listRewrite.remove(annotation, editGroup);
        return true;
      }
      // paranoia: check if by accident the annotation is already present (shouldn't happen):
      lastDot = fAnnotationToAdd.lastIndexOf('.');
      if (existingName.equals(fAnnotationToAdd)
          || (lastDot != -1 && fAnnotationToAdd.substring(lastDot + 1).equals(existingName))) {
        return false; // already present
      }
    }
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:NullAnnotationsRewriteOperations.java


示例18: rewriteAST

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model)
    throws CoreException {
  AST ast = cuRewrite.getRoot().getAST();
  ListRewrite listRewrite =
      cuRewrite
          .getASTRewrite()
          .getListRewrite(fBodyDeclaration, fBodyDeclaration.getModifiersProperty());
  TextEditGroup group = createTextEditGroup(fMessage, cuRewrite);
  if (!checkExisting(fBodyDeclaration.modifiers(), listRewrite, group)) return;
  if (hasNonNullDefault(fBodyDeclaration.resolveBinding()))
    return; // should be safe, as in this case checkExisting() should've already produced a
  // change (remove existing
  // annotation).
  Annotation newAnnotation = ast.newMarkerAnnotation();
  ImportRewrite importRewrite = cuRewrite.getImportRewrite();
  String resolvableName = importRewrite.addImport(fAnnotationToAdd);
  newAnnotation.setTypeName(ast.newName(resolvableName));
  listRewrite.insertLast(
      newAnnotation,
      group); // null annotation is last modifier, directly preceding the return type
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:NullAnnotationsRewriteOperations.java


示例19: rewriteAST

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel linkedModel)
    throws CoreException {
  ASTRewrite rewrite = cuRewrite.getASTRewrite();
  IBinding binding = fUnusedName.resolveBinding();
  CompilationUnit root = (CompilationUnit) fUnusedName.getRoot();
  String displayString = FixMessages.UnusedCodeFix_RemoveUnusedTypeParameter_description;
  TextEditGroup group = createTextEditGroup(displayString, cuRewrite);

  if (binding.getKind() == IBinding.TYPE) {
    ITypeBinding decl = ((ITypeBinding) binding).getTypeDeclaration();
    ASTNode declaration = root.findDeclaringNode(decl);
    if (declaration.getParent() instanceof TypeDeclarationStatement) {
      declaration = declaration.getParent();
    }
    rewrite.remove(declaration, group);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:UnusedCodeFix.java


示例20: removeVariableWithInitializer

import org.eclipse.text.edits.TextEditGroup; //导入依赖的package包/类
private void removeVariableWithInitializer(
    ASTRewrite rewrite, ASTNode initializerNode, ASTNode statementNode, TextEditGroup group) {
  boolean performRemove = fForceRemove;
  if (!performRemove) {
    ArrayList<Expression> sideEffectNodes = new ArrayList<Expression>();
    initializerNode.accept(new SideEffectFinder(sideEffectNodes));
    performRemove = sideEffectNodes.isEmpty();
  }
  if (performRemove) {
    removeStatement(rewrite, statementNode, group);
    fRemovedAssignmentsCount++;
  } else {
    ASTNode initNode = rewrite.createMoveTarget(initializerNode);
    ExpressionStatement statement =
        rewrite.getAST().newExpressionStatement((Expression) initNode);
    rewrite.replace(statementNode, statement, null);
    fAlteredAssignmentsCount++;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:UnusedCodeFix.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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