public Expression createFieldReadAccess(ParameterInfo pi, String paramName, AST ast, IJavaProject project, boolean useSuper, Expression qualifier) { Expression completeQualifier= generateQualifier(paramName, ast, useSuper, qualifier); if (fCreateGetter) { MethodInvocation mi= ast.newMethodInvocation(); mi.setName(ast.newSimpleName(getGetterName(pi, ast, project))); mi.setExpression(completeQualifier); return mi; } return createFieldAccess(pi, ast, completeQualifier); }
public Expression createFieldReadAccess(ParameterInfo pi, String paramName, AST ast, IJavaProject project, boolean useSuper, Expression qualifier) { Expression completeQualifier= generateQualifier(paramName, ast, useSuper, qualifier); if (fCreateGetter) { MethodInvocation mi= ast.newMethodInvocation(); mi.setName(ast.newSimpleName(getGetterName(pi, ast, project))); mi.setExpression(completeQualifier); return mi; } return createFieldAccess(pi, ast, completeQualifier); }
public Expression createFieldReadAccess(ParameterInfo pi, String paramName, AST ast) { if (!fCreateGetter) { return ast.newName(new String[] { paramName, pi.getNewName() }); } else { MethodInvocation method= ast.newMethodInvocation(); method.setName(ast.newSimpleName(getGetterName(pi, ast))); method.setExpression(ast.newSimpleName(paramName)); return method; } }
private ASTNode createGetter(ParameterInfo pi, String declaringType, ICompilationUnit cu, CompilationUnitRewrite cuRewrite) throws CoreException { AST ast= cuRewrite.getAST(); MethodDeclaration methodDeclaration= ast.newMethodDeclaration(); String fieldName= pi.getNewName(); String getterName= getGetterName(pi, ast); String lineDelim= StubUtility.getLineDelimiterUsed(cu); String bareFieldname= NamingConventions.removePrefixAndSuffixForFieldName(cu.getJavaProject(), fieldName, Flags.AccPrivate); if (fCreateComments) { String comment= CodeGeneration.getGetterComment(cu, declaringType, getterName, fieldName, pi.getNewTypeName(), bareFieldname, lineDelim); if (comment != null) methodDeclaration.setJavadoc((Javadoc) cuRewrite.getASTRewrite().createStringPlaceholder(comment, ASTNode.JAVADOC)); } methodDeclaration.setName(ast.newSimpleName(getterName)); methodDeclaration.setReturnType2(importBinding(pi.getNewTypeBinding(), cuRewrite)); methodDeclaration.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD)); Block block= ast.newBlock(); methodDeclaration.setBody(block); boolean useThis= StubUtility.useThisForFieldAccess(cu.getJavaProject()); if (useThis) { fieldName= "this." + fieldName; //$NON-NLS-1$ } String bodyContent= CodeGeneration.getGetterMethodBodyContent(cu, declaringType, getterName, fieldName, lineDelim); ASTNode getterBody= cuRewrite.getASTRewrite().createStringPlaceholder(bodyContent, ASTNode.EXPRESSION_STATEMENT); block.statements().add(getterBody); return methodDeclaration; }
private MethodDeclaration createGetter(ParameterInfo pi, String declaringType, CompilationUnitRewrite cuRewrite) throws CoreException { AST ast= cuRewrite.getAST(); ICompilationUnit cu= cuRewrite.getCu(); IJavaProject project= cu.getJavaProject(); MethodDeclaration methodDeclaration= ast.newMethodDeclaration(); String fieldName= pi.getNewName(); String getterName= getGetterName(pi, ast, project); String lineDelim= StubUtility.getLineDelimiterUsed(cu); String bareFieldname= NamingConventions.getBaseName(NamingConventions.VK_INSTANCE_FIELD, fieldName, project); if (createComments(project)) { String comment= CodeGeneration.getGetterComment(cu, declaringType, getterName, fieldName, pi.getNewTypeName(), bareFieldname, lineDelim); if (comment != null) methodDeclaration.setJavadoc((Javadoc) cuRewrite.getASTRewrite().createStringPlaceholder(comment, ASTNode.JAVADOC)); } methodDeclaration.setName(ast.newSimpleName(getterName)); methodDeclaration.setReturnType2(importBinding(pi.getNewTypeBinding(), cuRewrite)); methodDeclaration.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD)); Block block= ast.newBlock(); methodDeclaration.setBody(block); boolean useThis= StubUtility.useThisForFieldAccess(project); if (useThis) { fieldName= "this." + fieldName; //$NON-NLS-1$ } String bodyContent= CodeGeneration.getGetterMethodBodyContent(cu, declaringType, getterName, fieldName, lineDelim); ASTNode getterBody= cuRewrite.getASTRewrite().createStringPlaceholder(bodyContent, ASTNode.EXPRESSION_STATEMENT); block.statements().add(getterBody); return methodDeclaration; }
private MethodDeclaration createGetter(ParameterInfo pi, String declaringType, CompilationUnitRewrite cuRewrite, ImportRewriteContext context) throws CoreException { AST ast= cuRewrite.getAST(); ICompilationUnit cu= cuRewrite.getCu(); IJavaProject project= cu.getJavaProject(); MethodDeclaration methodDeclaration= ast.newMethodDeclaration(); String fieldName= pi.getNewName(); String getterName= getGetterName(pi, ast, project); String lineDelim= StubUtility.getLineDelimiterUsed(cu); String bareFieldname= NamingConventions.getBaseName(NamingConventions.VK_INSTANCE_FIELD, fieldName, project); if (createComments(project)) { String comment= CodeGeneration.getGetterComment(cu, declaringType, getterName, fieldName, pi.getNewTypeName(), bareFieldname, lineDelim); if (comment != null) methodDeclaration.setJavadoc((Javadoc) cuRewrite.getASTRewrite().createStringPlaceholder(comment, ASTNode.JAVADOC)); } methodDeclaration.setName(ast.newSimpleName(getterName)); methodDeclaration.setReturnType2(importBinding(pi.getNewTypeBinding(), cuRewrite, context, TypeLocation.RETURN_TYPE)); methodDeclaration.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD)); Block block= ast.newBlock(); methodDeclaration.setBody(block); boolean useThis= StubUtility.useThisForFieldAccess(project); if (useThis) { fieldName= "this." + fieldName; //$NON-NLS-1$ } String bodyContent= CodeGeneration.getGetterMethodBodyContent(cu, declaringType, getterName, fieldName, lineDelim); ASTNode getterBody= cuRewrite.getASTRewrite().createStringPlaceholder(bodyContent, ASTNode.EXPRESSION_STATEMENT); block.statements().add(getterBody); return methodDeclaration; }