private CAstEntity createDefaultConstructor(ITypeBinding classBinding, WalkContext oldContext, ArrayList<ASTNode> inits, ASTNode positioningNode) { MethodDeclaration fakeCtor = ast.newMethodDeclaration(); fakeCtor.setConstructor(true); // fakeCtor.setName(ast.newSimpleName(className)); will crash on anonymous types... fakeCtor.setSourceRange(positioningNode.getStartPosition(), positioningNode.getLength()); fakeCtor.setBody(ast.newBlock()); return visit(fakeCtor, classBinding, oldContext, inits); }
private CAstEntity createEnumValuesMethod(ITypeBinding enumType, ArrayList<IVariableBinding> constants, WalkContext oldContext) { IMethodBinding met = null; for (IMethodBinding m : enumType.getDeclaredMethods()) if (m.getName().equals("values") && m.getParameterTypes().length == 0) met = m; assert met != null : "Couldn't find enum values() function in JDT bindings!"; Map<CAstNode, CAstEntity> memberEntities = new LinkedHashMap<>(); final MethodContext context = new MethodContext(oldContext, memberEntities); MethodDeclaration fakeMet = ast.newMethodDeclaration(); fakeMet.setName(ast.newSimpleName("values")); fakeMet.setSourceRange(-1, 0); fakeMet.setBody(ast.newBlock()); // make enum constant values array: new MyEnum() { MYENUMCST1, MYENUMCST2, ... } CAstNode[] eltNodes = new CAstNode[constants.size() + 1]; int idx = 0; TypeReference arrayTypeRef = fIdentityMapper.getTypeRef(enumType.createArrayType(1)); eltNodes[idx++] = makeNode(context, fFactory, fakeMet, CAstNode.NEW, fFactory.makeConstant(arrayTypeRef), fFactory .makeConstant(constants.size())); for (IVariableBinding cst : constants) eltNodes[idx++] = createFieldAccess(makeNode(context, fFactory, fakeMet, CAstNode.VOID), cst.getName(), cst, fakeMet, context); CAstNode bodyNode = makeNode(context, fFactory, fakeMet, CAstNode.LOCAL_SCOPE, makeNode(context, fFactory, fakeMet, CAstNode.BLOCK_STMT, makeNode(context, fFactory, fakeMet, CAstNode.RETURN, makeNode(context, fFactory, fakeMet, CAstNode.ARRAY_LITERAL, eltNodes)))); ArrayList<CAstType> paramTypes = new ArrayList<>(0); return new ProcedureEntity(bodyNode, fakeMet, enumType, memberEntities, context, paramTypes, enumType.createArrayType(1), met .getModifiers(), handleAnnotations(enumType)); }
MethodDeclaration fakeCtor = ast.newMethodDeclaration(); fakeCtor.setConstructor(true); fakeCtor.setSourceRange(n.getStartPosition(), n.getLength()); fakeCtor.setBody(ast.newBlock());
fakeMet.setSourceRange(-1, 0); fakeMet.setBody(ast.newBlock()); SingleVariableDeclaration stringS = ast.newSingleVariableDeclaration();
MethodDeclaration fakeCtor = ast.newMethodDeclaration(); fakeCtor.setConstructor(true); fakeCtor.setSourceRange(n.getStartPosition(), n.getLength()); fakeCtor.setBody(ast.newBlock());
ASTNode clone0(AST target) { MethodDeclaration result = new MethodDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc())); if (this.ast.apiLevel == AST.JLS2_INTERNAL) { result.internalSetModifiers(getModifiers()); result.setReturnType( (Type) ASTNode.copySubtree(target, getReturnType())); } if (this.ast.apiLevel >= AST.JLS3) { result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); result.typeParameters().addAll( ASTNode.copySubtrees(target, typeParameters())); result.setReturnType2( (Type) ASTNode.copySubtree(target, getReturnType2())); } result.setConstructor(isConstructor()); result.setExtraDimensions(getExtraDimensions()); result.setName((SimpleName) getName().clone(target)); result.parameters().addAll( ASTNode.copySubtrees(target, parameters())); result.thrownExceptions().addAll( ASTNode.copySubtrees(target, thrownExceptions())); result.setBody( (Block) ASTNode.copySubtree(target, getBody())); return result; }
ASTNode clone0(AST target) { MethodDeclaration result = new MethodDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
ASTNode clone0(AST target) { MethodDeclaration result = new MethodDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
ASTNode clone0(AST target) { MethodDeclaration result = new MethodDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
@Override ASTNode clone0(AST target) { MethodDeclaration result = new MethodDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
ASTNode clone0(AST target) { MethodDeclaration result = new MethodDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
methodDecl.setSourceRange(declarationSourceStart, bodyEnd - declarationSourceStart + 1); int declarationSourceEnd = methodDeclaration.declarationSourceEnd; int rightBraceOrSemiColonPositionStart = bodyEnd == declarationSourceEnd ? bodyEnd : bodyEnd + 1; if (closingPosition != -1) { int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1); methodDecl.setSourceRange(startPosition, end - startPosition + 1); if (start != -1 && end != -1) {
methodDecl.setSourceRange(declarationSourceStart, checkLength(declarationSourceStart, bodyEnd)); int declarationSourceEnd = methodDeclaration.declarationSourceEnd; int rightBraceOrSemiColonPositionStart = bodyEnd == declarationSourceEnd ? bodyEnd : bodyEnd + 1; if (closingPosition != -1) { int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1); methodDecl.setSourceRange(startPosition, checkLength(startPosition, end)); if (start != -1 && end != -1) {
methodDecl.setSourceRange(declarationSourceStart, bodyEnd - declarationSourceStart + 1); int declarationSourceEnd = methodDeclaration.declarationSourceEnd; int rightBraceOrSemiColonPositionStart = bodyEnd == declarationSourceEnd ? bodyEnd : bodyEnd + 1; if (closingPosition != -1) { int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1); methodDecl.setSourceRange(startPosition, end - startPosition + 1); if (start != -1 && end != -1) {
methodDecl.setSourceRange(declarationSourceStart, bodyEnd - declarationSourceStart + 1); int declarationSourceEnd = methodDeclaration.declarationSourceEnd; int rightBraceOrSemiColonPositionStart = bodyEnd == declarationSourceEnd ? bodyEnd : bodyEnd + 1; if (closingPosition != -1) { int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1); methodDecl.setSourceRange(startPosition, end - startPosition + 1); if (start != -1 && end != -1) {
methodDecl.setSourceRange(declarationSourceStart, checkLength(declarationSourceStart, bodyEnd)); int declarationSourceEnd = methodDeclaration.declarationSourceEnd; int rightBraceOrSemiColonPositionStart = bodyEnd == declarationSourceEnd ? bodyEnd : bodyEnd + 1; if (closingPosition != -1) { int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1); methodDecl.setSourceRange(startPosition, checkLength(startPosition, end)); if (start != -1 && end != -1) {
methodDecl.setSourceRange(declarationSourceStart, checkLength(declarationSourceStart, bodyEnd)); int declarationSourceEnd = methodDeclaration.declarationSourceEnd; int rightBraceOrSemiColonPositionStart = bodyEnd == declarationSourceEnd ? bodyEnd : bodyEnd + 1; if (closingPosition != -1) { int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1); methodDecl.setSourceRange(startPosition, checkLength(startPosition, end)); if (start != -1 && end != -1) {