1 11 package org.eclipse.jdt.internal.corext.fix; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jdt.core.ICompilationUnit; 16 import org.eclipse.jdt.core.dom.ASTNode; 17 import org.eclipse.jdt.core.dom.Expression; 18 import org.eclipse.jdt.core.dom.VariableDeclarationFragment; 19 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; 20 21 22 27 public final class SerialVersionDefaultOperation extends AbstractSerialVersionOperation { 28 29 30 private static final String GROUP_INITIALIZER= "initializer"; 32 40 public SerialVersionDefaultOperation(ICompilationUnit unit, ASTNode[] nodes) { 41 super(unit, nodes); 42 } 43 44 45 48 protected boolean addInitializer(final VariableDeclarationFragment fragment, final ASTNode declarationNode) { 49 Assert.isNotNull(fragment); 50 51 final Expression expression= fragment.getAST().newNumberLiteral(DEFAULT_EXPRESSION); 52 if (expression != null) 53 fragment.setInitializer(expression); 54 return true; 55 } 56 57 60 protected void addLinkedPositions(final ASTRewrite rewrite, final VariableDeclarationFragment fragment, final LinkedProposalModel positionGroups) { 61 62 Assert.isNotNull(rewrite); 63 Assert.isNotNull(fragment); 64 65 final Expression initializer= fragment.getInitializer(); 66 if (initializer != null) { 67 LinkedProposalPositionGroup group= new LinkedProposalPositionGroup(GROUP_INITIALIZER); 68 group.addPosition(rewrite.track(initializer), true); 69 positionGroups.addPositionGroup(group); 70 } 71 } 72 73 } 74 | Popular Tags |