本文整理汇总了Java中org.eclipse.jdt.internal.corext.dom.DimensionRewrite类的典型用法代码示例。如果您正苦于以下问题:Java DimensionRewrite类的具体用法?Java DimensionRewrite怎么用?Java DimensionRewrite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DimensionRewrite类属于org.eclipse.jdt.internal.corext.dom包,在下文中一共展示了DimensionRewrite类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNewFieldDeclaration
import org.eclipse.jdt.internal.corext.dom.DimensionRewrite; //导入依赖的package包/类
private FieldDeclaration createNewFieldDeclaration(ASTRewrite rewrite) {
AST ast = getAST();
VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment();
SimpleName variableName = ast.newSimpleName(fFieldName);
fragment.setName(variableName);
addLinkedName(rewrite, variableName, false);
List<Dimension> extraDimensions =
DimensionRewrite.copyDimensions(fTempDeclarationNode.extraDimensions(), rewrite);
fragment.extraDimensions().addAll(extraDimensions);
if (fInitializeIn == INITIALIZE_IN_FIELD && tempHasInitializer()) {
Expression initializer = (Expression) rewrite.createCopyTarget(getTempInitializer());
fragment.setInitializer(initializer);
}
FieldDeclaration fieldDeclaration = ast.newFieldDeclaration(fragment);
VariableDeclarationStatement vds = getTempDeclarationStatement();
Type type = (Type) rewrite.createCopyTarget(vds.getType());
fieldDeclaration.setType(type);
fieldDeclaration.modifiers().addAll(ASTNodeFactory.newModifiers(ast, getModifiers()));
return fieldDeclaration;
}
示例2: createNewFieldDeclaration
import org.eclipse.jdt.internal.corext.dom.DimensionRewrite; //导入依赖的package包/类
private FieldDeclaration createNewFieldDeclaration(ASTRewrite rewrite) {
AST ast= getAST();
VariableDeclarationFragment fragment= ast.newVariableDeclarationFragment();
SimpleName variableName= ast.newSimpleName(fFieldName);
fragment.setName(variableName);
addLinkedName(rewrite, variableName, false);
List<Dimension> extraDimensions= DimensionRewrite.copyDimensions(fTempDeclarationNode.extraDimensions(), rewrite);
fragment.extraDimensions().addAll(extraDimensions);
if (fInitializeIn == INITIALIZE_IN_FIELD && tempHasInitializer()){
Expression initializer= (Expression)rewrite.createCopyTarget(getTempInitializer());
fragment.setInitializer(initializer);
}
FieldDeclaration fieldDeclaration= ast.newFieldDeclaration(fragment);
VariableDeclarationStatement vds= getTempDeclarationStatement();
Type type= (Type)rewrite.createCopyTarget(vds.getType());
fieldDeclaration.setType(type);
fieldDeclaration.modifiers().addAll(ASTNodeFactory.newModifiers(ast, getModifiers()));
return fieldDeclaration;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:PromoteTempToFieldRefactoring.java
示例3: createGetterMethod
import org.eclipse.jdt.internal.corext.dom.DimensionRewrite; //导入依赖的package包/类
private MethodDeclaration createGetterMethod(AST ast, ASTRewrite rewriter, String lineDelimiter) throws CoreException {
FieldDeclaration field= (FieldDeclaration)ASTNodes.getParent(fFieldDeclaration, FieldDeclaration.class);
Type type= field.getType();
MethodDeclaration result= ast.newMethodDeclaration();
result.setName(ast.newSimpleName(fGetterName));
result.modifiers().addAll(ASTNodeFactory.newModifiers(ast, createModifiers()));
Type returnType= DimensionRewrite.copyTypeAndAddDimensions(type, fFieldDeclaration.extraDimensions(), rewriter);
result.setReturnType2(returnType);
Block block= ast.newBlock();
result.setBody(block);
String body= CodeGeneration.getGetterMethodBodyContent(fField.getCompilationUnit(), getTypeName(field.getParent()), fGetterName, fField.getElementName(), lineDelimiter);
if (body != null) {
ASTNode getterNode= rewriter.createStringPlaceholder(body, ASTNode.BLOCK);
block.statements().add(getterNode);
} else {
ReturnStatement rs= ast.newReturnStatement();
rs.setExpression(ast.newSimpleName(fField.getElementName()));
block.statements().add(rs);
}
if (fGenerateJavadoc) {
String string= CodeGeneration.getGetterComment(
fField.getCompilationUnit() , getTypeName(field.getParent()), fGetterName,
fField.getElementName(), ASTNodes.asString(type),
StubUtility.getBaseName(fField),
lineDelimiter);
if (string != null) {
Javadoc javadoc= (Javadoc)fRewriter.createStringPlaceholder(string, ASTNode.JAVADOC);
result.setJavadoc(javadoc);
}
}
return result;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:SelfEncapsulateFieldRefactoring.java
示例4: createSetterMethod
import org.eclipse.jdt.internal.corext.dom.DimensionRewrite; //导入依赖的package包/类
private MethodDeclaration createSetterMethod(AST ast, ASTRewrite rewriter, String lineDelimiter)
throws CoreException {
FieldDeclaration field =
(FieldDeclaration) ASTNodes.getParent(fFieldDeclaration, FieldDeclaration.class);
Type type = field.getType();
MethodDeclaration result = ast.newMethodDeclaration();
result.setName(ast.newSimpleName(fSetterName));
result.modifiers().addAll(ASTNodeFactory.newModifiers(ast, createModifiers()));
if (fSetterMustReturnValue) {
result.setReturnType2((Type) rewriter.createCopyTarget(type));
}
SingleVariableDeclaration param = ast.newSingleVariableDeclaration();
result.parameters().add(param);
param.setName(ast.newSimpleName(fArgName));
param.setType((Type) rewriter.createCopyTarget(type));
List<Dimension> extraDimensions =
DimensionRewrite.copyDimensions(fFieldDeclaration.extraDimensions(), rewriter);
param.extraDimensions().addAll(extraDimensions);
Block block = ast.newBlock();
result.setBody(block);
String fieldAccess = createFieldAccess();
String body =
CodeGeneration.getSetterMethodBodyContent(
fField.getCompilationUnit(),
getTypeName(field.getParent()),
fSetterName,
fieldAccess,
fArgName,
lineDelimiter);
if (body != null) {
ASTNode setterNode = rewriter.createStringPlaceholder(body, ASTNode.BLOCK);
block.statements().add(setterNode);
} else {
Assignment ass = ast.newAssignment();
ass.setLeftHandSide(
(Expression) rewriter.createStringPlaceholder(fieldAccess, ASTNode.QUALIFIED_NAME));
ass.setRightHandSide(ast.newSimpleName(fArgName));
block.statements().add(ass);
}
if (fSetterMustReturnValue) {
ReturnStatement rs = ast.newReturnStatement();
rs.setExpression(ast.newSimpleName(fArgName));
block.statements().add(rs);
}
if (fGenerateJavadoc) {
String string =
CodeGeneration.getSetterComment(
fField.getCompilationUnit(),
getTypeName(field.getParent()),
fSetterName,
fField.getElementName(),
ASTNodes.asString(type),
fArgName,
StubUtility.getBaseName(fField),
lineDelimiter);
if (string != null) {
Javadoc javadoc = (Javadoc) fRewriter.createStringPlaceholder(string, ASTNode.JAVADOC);
result.setJavadoc(javadoc);
}
}
return result;
}
示例5: createGetterMethod
import org.eclipse.jdt.internal.corext.dom.DimensionRewrite; //导入依赖的package包/类
private MethodDeclaration createGetterMethod(AST ast, ASTRewrite rewriter, String lineDelimiter)
throws CoreException {
FieldDeclaration field =
(FieldDeclaration) ASTNodes.getParent(fFieldDeclaration, FieldDeclaration.class);
Type type = field.getType();
MethodDeclaration result = ast.newMethodDeclaration();
result.setName(ast.newSimpleName(fGetterName));
result.modifiers().addAll(ASTNodeFactory.newModifiers(ast, createModifiers()));
Type returnType =
DimensionRewrite.copyTypeAndAddDimensions(
type, fFieldDeclaration.extraDimensions(), rewriter);
result.setReturnType2(returnType);
Block block = ast.newBlock();
result.setBody(block);
String body =
CodeGeneration.getGetterMethodBodyContent(
fField.getCompilationUnit(),
getTypeName(field.getParent()),
fGetterName,
fField.getElementName(),
lineDelimiter);
if (body != null) {
ASTNode getterNode = rewriter.createStringPlaceholder(body, ASTNode.BLOCK);
block.statements().add(getterNode);
} else {
ReturnStatement rs = ast.newReturnStatement();
rs.setExpression(ast.newSimpleName(fField.getElementName()));
block.statements().add(rs);
}
if (fGenerateJavadoc) {
String string =
CodeGeneration.getGetterComment(
fField.getCompilationUnit(),
getTypeName(field.getParent()),
fGetterName,
fField.getElementName(),
ASTNodes.asString(type),
StubUtility.getBaseName(fField),
lineDelimiter);
if (string != null) {
Javadoc javadoc = (Javadoc) fRewriter.createStringPlaceholder(string, ASTNode.JAVADOC);
result.setJavadoc(javadoc);
}
}
return result;
}
示例6: createSetterMethod
import org.eclipse.jdt.internal.corext.dom.DimensionRewrite; //导入依赖的package包/类
private MethodDeclaration createSetterMethod(AST ast, ASTRewrite rewriter, String lineDelimiter) throws CoreException {
FieldDeclaration field= (FieldDeclaration)ASTNodes.getParent(fFieldDeclaration, FieldDeclaration.class);
Type type= field.getType();
MethodDeclaration result= ast.newMethodDeclaration();
result.setName(ast.newSimpleName(fSetterName));
result.modifiers().addAll(ASTNodeFactory.newModifiers(ast, createModifiers()));
if (fSetterMustReturnValue) {
result.setReturnType2((Type)rewriter.createCopyTarget(type));
}
SingleVariableDeclaration param= ast.newSingleVariableDeclaration();
result.parameters().add(param);
param.setName(ast.newSimpleName(fArgName));
param.setType((Type)rewriter.createCopyTarget(type));
List<Dimension> extraDimensions= DimensionRewrite.copyDimensions(fFieldDeclaration.extraDimensions(), rewriter);
param.extraDimensions().addAll(extraDimensions);
Block block= ast.newBlock();
result.setBody(block);
String fieldAccess= createFieldAccess();
String body= CodeGeneration.getSetterMethodBodyContent(fField.getCompilationUnit(), getTypeName(field.getParent()), fSetterName, fieldAccess, fArgName, lineDelimiter);
if (body != null) {
ASTNode setterNode= rewriter.createStringPlaceholder(body, ASTNode.BLOCK);
block.statements().add(setterNode);
} else {
Assignment ass= ast.newAssignment();
ass.setLeftHandSide((Expression) rewriter.createStringPlaceholder(fieldAccess, ASTNode.QUALIFIED_NAME));
ass.setRightHandSide(ast.newSimpleName(fArgName));
block.statements().add(ass);
}
if (fSetterMustReturnValue) {
ReturnStatement rs= ast.newReturnStatement();
rs.setExpression(ast.newSimpleName(fArgName));
block.statements().add(rs);
}
if (fGenerateJavadoc) {
String string= CodeGeneration.getSetterComment(
fField.getCompilationUnit() , getTypeName(field.getParent()), fSetterName,
fField.getElementName(), ASTNodes.asString(type), fArgName,
StubUtility.getBaseName(fField),
lineDelimiter);
if (string != null) {
Javadoc javadoc= (Javadoc)fRewriter.createStringPlaceholder(string, ASTNode.JAVADOC);
result.setJavadoc(javadoc);
}
}
return result;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:49,代码来源:SelfEncapsulateFieldRefactoring.java