Java 类org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression 实例源码

项目:che    文件:SourceTypeConverter.java   
private QualifiedAllocationExpression convert(
    IJavaElement localType, FieldDeclaration enumConstant, CompilationResult compilationResult)
    throws JavaModelException {
  TypeDeclaration anonymousLocalTypeDeclaration =
      convert((SourceType) localType, compilationResult);
  QualifiedAllocationExpression expression =
      new QualifiedAllocationExpression(anonymousLocalTypeDeclaration);
  expression.type = anonymousLocalTypeDeclaration.superclass;
  anonymousLocalTypeDeclaration.superclass = null;
  anonymousLocalTypeDeclaration.superInterfaces = null;
  anonymousLocalTypeDeclaration.allocation = expression;
  if (enumConstant != null) {
    anonymousLocalTypeDeclaration.modifiers &= ~ClassFileConstants.AccEnum;
    expression.enumConstant = enumConstant;
    expression.type = null;
  }
  return expression;
}
项目:Eclipse-Postfix-Code-Completion    文件:SourceElementNotifier.java   
protected char[][] getInterfaceNames(TypeDeclaration typeDeclaration) {
    char[][] interfaceNames = null;
    int superInterfacesLength = 0;
    TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
    if (superInterfaces != null) {
        superInterfacesLength = superInterfaces.length;
        interfaceNames = new char[superInterfacesLength][];
    } else {
        if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
            // see PR 3442
            QualifiedAllocationExpression alloc = typeDeclaration.allocation;
            if (alloc != null && alloc.type != null) {
                superInterfaces = new TypeReference[] { alloc.type};
                superInterfacesLength = 1;
                interfaceNames = new char[1][];
            }
        }
    }
    if (superInterfaces != null) {
        for (int i = 0; i < superInterfacesLength; i++) {
            interfaceNames[i] =
                CharOperation.concatWith(superInterfaces[i].getParameterizedTypeName(), '.');
        }
    }
    return interfaceNames;
}
项目:Eclipse-Postfix-Code-Completion    文件:RecoveredType.java   
public Statement updatedStatement(int depth, Set knownTypes){

    // ignore closed anonymous type
    if ((this.typeDeclaration.bits & ASTNode.IsAnonymousType) != 0 && !this.preserveContent){
        return null;
    }

    TypeDeclaration updatedType = updatedTypeDeclaration(depth + 1, knownTypes);
    if (updatedType != null && (updatedType.bits & ASTNode.IsAnonymousType) != 0){
        /* in presence of an anonymous type, we want the full allocation expression */
        QualifiedAllocationExpression allocation = updatedType.allocation;

        if (allocation.statementEnd == -1) {
            allocation.statementEnd = updatedType.declarationSourceEnd;
        }
        return allocation;
    }
    return updatedType;
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeClassInstanceCreationExpressionQualified() {
    // ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
    // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
    classInstanceCreation(true);

    QualifiedAllocationExpression qae =
        (QualifiedAllocationExpression) this.expressionStack[this.expressionPtr];

    if (qae.anonymousType == null) {
        this.expressionLengthPtr--;
        this.expressionPtr--;
        qae.enclosingInstance = this.expressionStack[this.expressionPtr];
        this.expressionStack[this.expressionPtr] = qae;
    }
    qae.sourceStart = qae.enclosingInstance.sourceStart;
    consumeInvocationExpression();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SourceElementNotifier.java   
protected char[][] getInterfaceNames(TypeDeclaration typeDeclaration) {
    char[][] interfaceNames = null;
    int superInterfacesLength = 0;
    TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
    if (superInterfaces != null) {
        superInterfacesLength = superInterfaces.length;
        interfaceNames = new char[superInterfacesLength][];
    } else {
        if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
            // see PR 3442
            QualifiedAllocationExpression alloc = typeDeclaration.allocation;
            if (alloc != null && alloc.type != null) {
                superInterfaces = new TypeReference[] { alloc.type};
                superInterfacesLength = 1;
                interfaceNames = new char[1][];
            }
        }
    }
    if (superInterfaces != null) {
        for (int i = 0; i < superInterfacesLength; i++) {
            interfaceNames[i] =
                CharOperation.concatWith(superInterfaces[i].getParameterizedTypeName(), '.');
        }
    }
    return interfaceNames;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:RecoveredType.java   
public Statement updatedStatement(int depth, Set knownTypes){

    // ignore closed anonymous type
    if ((this.typeDeclaration.bits & ASTNode.IsAnonymousType) != 0 && !this.preserveContent){
        return null;
    }

    TypeDeclaration updatedType = updatedTypeDeclaration(depth + 1, knownTypes);
    if (updatedType != null && (updatedType.bits & ASTNode.IsAnonymousType) != 0){
        /* in presence of an anonymous type, we want the full allocation expression */
        QualifiedAllocationExpression allocation = updatedType.allocation;

        if (allocation.statementEnd == -1) {
            allocation.statementEnd = updatedType.declarationSourceEnd;
        }
        return allocation;
    }
    return updatedType;
}
项目:che    文件:SourceTypeConverter.java   
private Initializer convert(
    InitializerElementInfo initializerInfo, CompilationResult compilationResult)
    throws JavaModelException {

  Block block = new Block(0);
  Initializer initializer = new Initializer(block, ClassFileConstants.AccDefault);

  int start = initializerInfo.getDeclarationSourceStart();
  int end = initializerInfo.getDeclarationSourceEnd();

  initializer.sourceStart = initializer.declarationSourceStart = start;
  initializer.sourceEnd = initializer.declarationSourceEnd = end;
  initializer.modifiers = initializerInfo.getModifiers();

  /* convert local and anonymous types */
  IJavaElement[] children = initializerInfo.getChildren();
  int typesLength = children.length;
  if (typesLength > 0) {
    Statement[] statements = new Statement[typesLength];
    for (int i = 0; i < typesLength; i++) {
      SourceType type = (SourceType) children[i];
      TypeDeclaration localType = convert(type, compilationResult);
      if ((localType.bits & ASTNode.IsAnonymousType) != 0) {
        QualifiedAllocationExpression expression = new QualifiedAllocationExpression(localType);
        expression.type = localType.superclass;
        localType.superclass = null;
        localType.superInterfaces = null;
        localType.allocation = expression;
        statements[i] = expression;
      } else {
        statements[i] = localType;
      }
    }
    block.statements = statements;
  }

  return initializer;
}
项目:Eclipse-Postfix-Code-Completion    文件:CompletionElementNotifier.java   
protected char[][] getInterfaceNames(TypeDeclaration typeDeclaration) {
    char[][] interfaceNames = null;
    int superInterfacesLength = 0;
    TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
    if (superInterfaces != null) {
        superInterfacesLength = superInterfaces.length;
        interfaceNames = new char[superInterfacesLength][];
    } else {
        if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
            // see PR 3442
            QualifiedAllocationExpression alloc = typeDeclaration.allocation;
            if (alloc != null && alloc.type != null) {
                superInterfaces = new TypeReference[] { alloc.type};
                superInterfacesLength = 1;
                interfaceNames = new char[1][];
            }
        }
    }
    if (superInterfaces != null) {
        int superInterfaceCount = 0;
        next: for (int i = 0; i < superInterfacesLength; i++) {
            TypeReference superInterface = superInterfaces[i];

            if (superInterface instanceof CompletionOnKeyword) continue next;
            if (CompletionUnitStructureRequestor.hasEmptyName(superInterface, this.assistNode)) continue next;

            interfaceNames[superInterfaceCount++] = CharOperation.concatWith(superInterface.getParameterizedTypeName(), '.');
        }

        if (superInterfaceCount == 0) return null;
        if (superInterfaceCount < superInterfacesLength) {
            System.arraycopy(interfaceNames, 0, interfaceNames = new char[superInterfaceCount][], 0, superInterfaceCount);
        }
    }
    return interfaceNames;
}
项目:Eclipse-Postfix-Code-Completion    文件:SourceElementNotifier.java   
private int sourceEnd(TypeDeclaration typeDeclaration) {
    if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
        QualifiedAllocationExpression allocation = typeDeclaration.allocation;
        if (allocation.enumConstant != null) // case of enum constant body
            return allocation.enumConstant.sourceEnd;
        return allocation.type.sourceEnd;
    } else {
        return typeDeclaration.sourceEnd;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeAllocationHeader() {
    // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt

    // ClassBodyopt produces a null item on the astStak if it produces NO class body
    // An empty class body produces a 0 on the length stack.....

    if (this.currentElement == null){
        return; // should never occur, this consumeRule is only used in recovery mode
    }
    if (this.currentToken == TokenNameLBRACE){
        // beginning of an anonymous type
        TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
        anonymousType.name = CharOperation.NO_CHAR;
        anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType);
        anonymousType.sourceStart = this.intStack[this.intPtr--];
        anonymousType.declarationSourceStart = anonymousType.sourceStart;
        anonymousType.sourceEnd = this.rParenPos; // closing parenthesis
        QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType);
        alloc.type = getTypeReference(0);
        alloc.sourceStart = anonymousType.sourceStart;
        alloc.sourceEnd = anonymousType.sourceEnd ;
        this.lastCheckPoint = anonymousType.bodyStart = this.scanner.currentPosition;
        this.currentElement = this.currentElement.add(anonymousType, 0);
        this.lastIgnoredToken = -1;
        if (!isIndirectlyInsideLambdaExpression())
            this.currentToken = 0; // opening brace already taken into account
        return;
    }
    this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
    this.restartRecovery = true; // request to restart from here on
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void missingTypeInConstructor(ASTNode location, MethodBinding constructor) {
    List missingTypes = constructor.collectMissingTypes(null);
    if (missingTypes == null) {
        System.err.println("The constructor " + constructor + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
        return;
    }
    TypeBinding missingType = (TypeBinding) missingTypes.get(0);
    int start = location.sourceStart;
    int end = location.sourceEnd;
    if (location instanceof QualifiedAllocationExpression) {
        QualifiedAllocationExpression qualifiedAllocation = (QualifiedAllocationExpression) location;
        if (qualifiedAllocation.anonymousType != null) {
            start = qualifiedAllocation.anonymousType.sourceStart;
            end = qualifiedAllocation.anonymousType.sourceEnd;
        }
    }
    this.handle(
            IProblem.MissingTypeInConstructor,
            new String[] {
                    new String(constructor.declaringClass.readableName()),
                    typesAsString(constructor, false),
                    new String(missingType.readableName()),
            },
            new String[] {
                    new String(constructor.declaringClass.shortReadableName()),
                    typesAsString(constructor, true),
                    new String(missingType.shortReadableName()),
            },
            start,
            end);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompletionElementNotifier.java   
protected char[][] getInterfaceNames(TypeDeclaration typeDeclaration) {
    char[][] interfaceNames = null;
    int superInterfacesLength = 0;
    TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
    if (superInterfaces != null) {
        superInterfacesLength = superInterfaces.length;
        interfaceNames = new char[superInterfacesLength][];
    } else {
        if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
            // see PR 3442
            QualifiedAllocationExpression alloc = typeDeclaration.allocation;
            if (alloc != null && alloc.type != null) {
                superInterfaces = new TypeReference[] { alloc.type};
                superInterfacesLength = 1;
                interfaceNames = new char[1][];
            }
        }
    }
    if (superInterfaces != null) {
        int superInterfaceCount = 0;
        next: for (int i = 0; i < superInterfacesLength; i++) {
            TypeReference superInterface = superInterfaces[i];

            if (superInterface instanceof CompletionOnKeyword) continue next;
            if (CompletionUnitStructureRequestor.hasEmptyName(superInterface, this.assistNode)) continue next;

            interfaceNames[superInterfaceCount++] = CharOperation.concatWith(superInterface.getParameterizedTypeName(), '.');
        }

        if (superInterfaceCount == 0) return null;
        if (superInterfaceCount < superInterfacesLength) {
            System.arraycopy(interfaceNames, 0, interfaceNames = new char[superInterfaceCount][], 0, superInterfaceCount);
        }
    }
    return interfaceNames;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SourceElementNotifier.java   
private int sourceEnd(TypeDeclaration typeDeclaration) {
    if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
        QualifiedAllocationExpression allocation = typeDeclaration.allocation;
        if (allocation.enumConstant != null) // case of enum constant body
            return allocation.enumConstant.sourceEnd;
        return allocation.type.sourceEnd;
    } else {
        return typeDeclaration.sourceEnd;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void missingTypeInConstructor(ASTNode location, MethodBinding constructor) {
    List missingTypes = constructor.collectMissingTypes(null);
    if (missingTypes == null) {
        System.err.println("The constructor " + constructor + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
        return;
    }
    TypeBinding missingType = (TypeBinding) missingTypes.get(0);
    int start = location.sourceStart;
    int end = location.sourceEnd;
    if (location instanceof QualifiedAllocationExpression) {
        QualifiedAllocationExpression qualifiedAllocation = (QualifiedAllocationExpression) location;
        if (qualifiedAllocation.anonymousType != null) {
            start = qualifiedAllocation.anonymousType.sourceStart;
            end = qualifiedAllocation.anonymousType.sourceEnd;
        }
    }
    this.handle(
            IProblem.MissingTypeInConstructor,
            new String[] {
                    new String(constructor.declaringClass.readableName()),
                    typesAsString(constructor, false),
                    new String(missingType.readableName()),
            },
            new String[] {
                    new String(constructor.declaringClass.shortReadableName()),
                    typesAsString(constructor, true),
                    new String(missingType.shortReadableName()),
            },
            start,
            end);
}
项目:xapi    文件:GwtAstBuilder.java   
@Override
public void endVisit(QualifiedAllocationExpression x, BlockScope scope) {
  try {
    SourceInfo info = makeSourceInfo(x);
    List<JExpression> arguments = popCallArgs(info, x.arguments, x.binding);
    pushNewExpression(info, x, x.enclosingInstance(), arguments, scope);
  } catch (Throwable e) {
    throw translateException(x, e);
  }
}
项目:lombok-ianchiu    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(QualifiedAllocationExpression node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:EasyMPermission    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(QualifiedAllocationExpression node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:Eclipse-Postfix-Code-Completion    文件:SelectionParser.java   
protected void classInstanceCreation(boolean hasClassBody) {

    // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt

    // ClassBodyopt produces a null item on the astStak if it produces NO class body
    // An empty class body produces a 0 on the length stack.....


    if ((this.astLengthStack[this.astLengthPtr] == 1)
        && (this.astStack[this.astPtr] == null)) {


        int index;
        if ((index = this.indexOfAssistIdentifier()) < 0) {
            super.classInstanceCreation(hasClassBody);
            return;
        } else if(this.identifierLengthPtr > -1 &&
                    (this.identifierLengthStack[this.identifierLengthPtr] - 1) != index) {
            super.classInstanceCreation(hasClassBody);
            return;
        }
        QualifiedAllocationExpression alloc;
        this.astPtr--;
        this.astLengthPtr--;
        alloc = new SelectionOnQualifiedAllocationExpression();
        alloc.sourceEnd = this.endPosition; //the position has been stored explicitly

        int length;
        if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
            this.expressionPtr -= length;
            System.arraycopy(
                this.expressionStack,
                this.expressionPtr + 1,
                alloc.arguments = new Expression[length],
                0,
                length);
        }
        // trick to avoid creating a selection on type reference
        char [] oldIdent = assistIdentifier();
        setAssistIdentifier(null);
        alloc.type = getTypeReference(0);
        checkForDiamond(alloc.type);

        setAssistIdentifier(oldIdent);

        //the default constructor with the correct number of argument
        //will be created and added by the TC (see createsInternalConstructorWithBinding)
        alloc.sourceStart = this.intStack[this.intPtr--];
        pushOnExpressionStack(alloc);

        this.assistNode = alloc;
        this.lastCheckPoint = alloc.sourceEnd + 1;
        if (!this.diet){
            this.restartRecovery    = true; // force to restart in recovery mode
            this.lastIgnoredToken = -1;
        }
        this.isOrphanCompletionNode = true;
    } else {
        super.classInstanceCreation(hasClassBody);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:SelectionParser.java   
protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() {
    // ClassInstanceCreationExpression ::= Primary '.' 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt
    // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt

    QualifiedAllocationExpression alloc;
    int length;
    if (((length = this.astLengthStack[this.astLengthPtr]) == 1) && (this.astStack[this.astPtr] == null)) {

        if (this.indexOfAssistIdentifier() < 0) {
            super.consumeClassInstanceCreationExpressionQualifiedWithTypeArguments();
            return;
        }

        //NO ClassBody
        this.astPtr--;
        this.astLengthPtr--;
        alloc = new SelectionOnQualifiedAllocationExpression();
        alloc.sourceEnd = this.endPosition; //the position has been stored explicitly

        if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
            this.expressionPtr -= length;
            System.arraycopy(
                this.expressionStack,
                this.expressionPtr + 1,
                alloc.arguments = new Expression[length],
                0,
                length);
        }

        // trick to avoid creating a selection on type reference
        char [] oldIdent = assistIdentifier();
        setAssistIdentifier(null);
        alloc.type = getTypeReference(0);
        checkForDiamond(alloc.type);

        setAssistIdentifier(oldIdent);

        length = this.genericsLengthStack[this.genericsLengthPtr--];
        this.genericsPtr -= length;
        System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length);
        this.intPtr--; // remove the position of the '<'

        //the default constructor with the correct number of argument
        //will be created and added by the TC (see createsInternalConstructorWithBinding)
        alloc.sourceStart = this.intStack[this.intPtr--];
        pushOnExpressionStack(alloc);

        this.assistNode = alloc;
        this.lastCheckPoint = alloc.sourceEnd + 1;
        if (!this.diet){
            this.restartRecovery    = true; // force to restart in recovery mode
            this.lastIgnoredToken = -1;
        }
        this.isOrphanCompletionNode = true;
    } else {
        super.consumeClassInstanceCreationExpressionQualifiedWithTypeArguments();
    }

    this.expressionLengthPtr--;
    QualifiedAllocationExpression qae =
        (QualifiedAllocationExpression) this.expressionStack[this.expressionPtr--];
    qae.enclosingInstance = this.expressionStack[this.expressionPtr];
    this.expressionStack[this.expressionPtr] = qae;
    qae.sourceStart = qae.enclosingInstance.sourceStart;
}
项目:Eclipse-Postfix-Code-Completion    文件:SelectionParser.java   
protected void consumeEnterAnonymousClassBody(boolean qualified) {
    // EnterAnonymousClassBody ::= $empty

    if (this.indexOfAssistIdentifier() < 0) {
        super.consumeEnterAnonymousClassBody(qualified);
        return;
    }

    // trick to avoid creating a selection on type reference
    char [] oldIdent = assistIdentifier();
    setAssistIdentifier(null);
    TypeReference typeReference = getTypeReference(0);
    setAssistIdentifier(oldIdent);

    TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
    anonymousType.name = CharOperation.NO_CHAR;
    anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType);
    QualifiedAllocationExpression alloc = new SelectionOnQualifiedAllocationExpression(anonymousType);
    markEnclosingMemberWithLocalType();
    pushOnAstStack(anonymousType);

    alloc.sourceEnd = this.rParenPos; //the position has been stored explicitly
    int argumentLength;
    if ((argumentLength = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
        this.expressionPtr -= argumentLength;
        System.arraycopy(
            this.expressionStack,
            this.expressionPtr + 1,
            alloc.arguments = new Expression[argumentLength],
            0,
            argumentLength);
    }

    if (qualified) {
        this.expressionLengthPtr--;
        alloc.enclosingInstance = this.expressionStack[this.expressionPtr--];
    }

    alloc.type = typeReference;

    anonymousType.sourceEnd = alloc.sourceEnd;
    //position at the type while it impacts the anonymous declaration
    anonymousType.sourceStart = anonymousType.declarationSourceStart = alloc.type.sourceStart;
    alloc.sourceStart = this.intStack[this.intPtr--];
    pushOnExpressionStack(alloc);

    this.assistNode = alloc;
    this.lastCheckPoint = alloc.sourceEnd + 1;
    if (!this.diet){
        this.restartRecovery    = true; // force to restart in recovery mode
        this.lastIgnoredToken = -1;
        if (!isIndirectlyInsideLambdaExpression())
            this.currentToken = 0; // opening brace already taken into account
        this.hasReportedError = true;
    }

    anonymousType.bodyStart = this.scanner.currentPosition;
    this.listLength = 0; // will be updated when reading super-interfaces
    // recovery
    if (this.currentElement != null){
        this.lastCheckPoint = anonymousType.bodyStart;
        this.currentElement = this.currentElement.add(anonymousType, 0);
        if (!isIndirectlyInsideLambdaExpression())
            this.currentToken = 0; // opening brace already taken into account
        this.lastIgnoredToken = -1;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:BinaryExpressionFragmentBuilder.java   
public boolean visit(
    QualifiedAllocationExpression qualifiedAllocationExpression,
    BlockScope scope) {
        addRealFragment(qualifiedAllocationExpression);
        return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
public boolean visit(FieldDeclaration enumConstant, MethodScope scope) {
       /*
        * Print comments to get proper line number
        */
       this.scribe.printComment();
       final int line = this.scribe.line;
       this.scribe.printModifiers(enumConstant.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_FIELD);
    this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false);
    formatEnumConstantArguments(
        enumConstant,
        this.preferences.insert_space_before_opening_paren_in_enum_constant,
        this.preferences.insert_space_between_empty_parens_in_enum_constant,
        this.preferences.insert_space_before_closing_paren_in_enum_constant,
        this.preferences.insert_space_after_opening_paren_in_enum_constant,
        this.preferences.insert_space_before_comma_in_enum_constant_arguments,
        this.preferences.insert_space_after_comma_in_enum_constant_arguments,
        this.preferences.alignment_for_arguments_in_enum_constant);

    Expression initialization = enumConstant.initialization;
    if (initialization instanceof QualifiedAllocationExpression) {
        TypeDeclaration typeDeclaration = ((QualifiedAllocationExpression) initialization).anonymousType;
        int fieldsCount = typeDeclaration.fields == null ? 0 : typeDeclaration.fields.length;
        int methodsCount = typeDeclaration.methods == null ? 0 : typeDeclaration.methods.length;
        int membersCount = typeDeclaration.memberTypes == null ? 0 : typeDeclaration.memberTypes.length;

        /*
         * Type body
         */
        String enum_constant_brace = this.preferences.brace_position_for_enum_constant;

        formatLeftCurlyBrace(line, enum_constant_brace);
        formatTypeOpeningBraceForEnumConstant(enum_constant_brace, this.preferences.insert_space_before_opening_brace_in_enum_constant, typeDeclaration);

        if (this.preferences.indent_body_declarations_compare_to_enum_constant_header) {
            this.scribe.indent();
        }

        if (fieldsCount != 0 || methodsCount != 0 || membersCount != 0) {
            formatTypeMembers(typeDeclaration);
        }

        if (this.preferences.indent_body_declarations_compare_to_enum_constant_header) {
            this.scribe.unIndent();
        }

        if (this.preferences.insert_new_line_in_empty_enum_constant) {
            this.scribe.printNewLine();
        }
        this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
        this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
        if (enum_constant_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
            this.scribe.unIndent();
        }
        if (hasComments()) {
            this.scribe.printNewLine();
        }
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:ASTConverter.java   
public EnumConstantDeclaration convert(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration enumConstant) {
    checkCanceled();
    EnumConstantDeclaration enumConstantDeclaration = new EnumConstantDeclaration(this.ast);
    final SimpleName typeName = new SimpleName(this.ast);
    typeName.internalSetIdentifier(new String(enumConstant.name));
    typeName.setSourceRange(enumConstant.sourceStart, enumConstant.sourceEnd - enumConstant.sourceStart + 1);
    enumConstantDeclaration.setName(typeName);
    int declarationSourceStart = enumConstant.declarationSourceStart;
    int declarationSourceEnd = enumConstant.declarationSourceEnd;
    final org.eclipse.jdt.internal.compiler.ast.Expression initialization = enumConstant.initialization;
    if (initialization != null) {
        if (initialization instanceof QualifiedAllocationExpression) {
            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration anonymousType = ((QualifiedAllocationExpression) initialization).anonymousType;
            if (anonymousType != null) {
                AnonymousClassDeclaration anonymousClassDeclaration = new AnonymousClassDeclaration(this.ast);
                int start = retrieveStartBlockPosition(anonymousType.sourceEnd, anonymousType.bodyEnd);
                int end = retrieveRightBrace(anonymousType.bodyEnd, declarationSourceEnd);
                if (end == -1) end = anonymousType.bodyEnd;
                anonymousClassDeclaration.setSourceRange(start, end - start + 1);
                enumConstantDeclaration.setAnonymousClassDeclaration(anonymousClassDeclaration);
                buildBodyDeclarations(anonymousType, anonymousClassDeclaration);
                if (this.resolveBindings) {
                    recordNodes(anonymousClassDeclaration, anonymousType);
                    anonymousClassDeclaration.resolveBinding();
                }
                enumConstantDeclaration.setSourceRange(declarationSourceStart, end - declarationSourceStart + 1);
            }
        } else {
            enumConstantDeclaration.setSourceRange(declarationSourceStart, declarationSourceEnd - declarationSourceStart + 1);
        }
        final org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = ((org.eclipse.jdt.internal.compiler.ast.AllocationExpression) initialization).arguments;
        if (arguments != null) {
            for (int i = 0, max = arguments.length; i < max; i++) {
                enumConstantDeclaration.arguments().add(convert(arguments[i]));
            }
        }
    } else {
        enumConstantDeclaration.setSourceRange(declarationSourceStart, declarationSourceEnd - declarationSourceStart + 1);
    }
    setModifiers(enumConstantDeclaration, enumConstant);
    if (this.resolveBindings) {
        recordNodes(enumConstantDeclaration, enumConstant);
        recordNodes(typeName, enumConstant);
        enumConstantDeclaration.resolveVariable();
    }
    convert(enumConstant.javadoc, enumConstantDeclaration);
    return enumConstantDeclaration;
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeEnterAnonymousClassBody(boolean qualified) {
    // EnterAnonymousClassBody ::= $empty
    TypeReference typeReference = getTypeReference(0);

    TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
    anonymousType.name = CharOperation.NO_CHAR;
    anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType);
    anonymousType.bits |= (typeReference.bits & ASTNode.HasTypeAnnotations);
    QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType);
    markEnclosingMemberWithLocalType();
    pushOnAstStack(anonymousType);

    alloc.sourceEnd = this.rParenPos; //the position has been stored explicitly
    int argumentLength;
    if ((argumentLength = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
        this.expressionPtr -= argumentLength;
        System.arraycopy(
            this.expressionStack,
            this.expressionPtr + 1,
            alloc.arguments = new Expression[argumentLength],
            0,
            argumentLength);
    }

    if (qualified) {
        this.expressionLengthPtr--;
        alloc.enclosingInstance = this.expressionStack[this.expressionPtr--];
    }

    alloc.type = typeReference;

    anonymousType.sourceEnd = alloc.sourceEnd;
    //position at the type while it impacts the anonymous declaration
    anonymousType.sourceStart = anonymousType.declarationSourceStart = alloc.type.sourceStart;
    alloc.sourceStart = this.intStack[this.intPtr--];
    pushOnExpressionStack(alloc);

    anonymousType.bodyStart = this.scanner.currentPosition;
    this.listLength = 0; // will be updated when reading super-interfaces

    // flush the comments related to the anonymous
    this.scanner.commentPtr = -1;

    // recovery
    if (this.currentElement != null){
        this.lastCheckPoint = anonymousType.bodyStart;
        this.currentElement = this.currentElement.add(anonymousType, 0);
        if (!(this.currentElement instanceof RecoveredAnnotation)) {
            if (!isIndirectlyInsideLambdaExpression())
                this.currentToken = 0; // opening brace already taken into account
        } else {
            this.ignoreNextOpeningBrace = true;
            this.currentElement.bracketBalance++;
        }
        this.lastIgnoredToken = -1;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BinaryExpressionFragmentBuilder.java   
public boolean visit(
    QualifiedAllocationExpression qualifiedAllocationExpression,
    BlockScope scope) {
        addRealFragment(qualifiedAllocationExpression);
        return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
public boolean visit(FieldDeclaration enumConstant, MethodScope scope) {
       /*
        * Print comments to get proper line number
        */
       this.scribe.printComment();
       final int line = this.scribe.line;
       this.scribe.printModifiers(enumConstant.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_FIELD);
    this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false);
    formatEnumConstantArguments(
        enumConstant,
        this.preferences.insert_space_before_opening_paren_in_enum_constant,
        this.preferences.insert_space_between_empty_parens_in_enum_constant,
        this.preferences.insert_space_before_closing_paren_in_enum_constant,
        this.preferences.insert_space_after_opening_paren_in_enum_constant,
        this.preferences.insert_space_before_comma_in_enum_constant_arguments,
        this.preferences.insert_space_after_comma_in_enum_constant_arguments,
        this.preferences.alignment_for_arguments_in_enum_constant);

    Expression initialization = enumConstant.initialization;
    if (initialization instanceof QualifiedAllocationExpression) {
        TypeDeclaration typeDeclaration = ((QualifiedAllocationExpression) initialization).anonymousType;
        int fieldsCount = typeDeclaration.fields == null ? 0 : typeDeclaration.fields.length;
        int methodsCount = typeDeclaration.methods == null ? 0 : typeDeclaration.methods.length;
        int membersCount = typeDeclaration.memberTypes == null ? 0 : typeDeclaration.memberTypes.length;

        /*
         * Type body
         */
        String enum_constant_brace = this.preferences.brace_position_for_enum_constant;

        formatLeftCurlyBrace(line, enum_constant_brace);
        formatTypeOpeningBraceForEnumConstant(enum_constant_brace, this.preferences.insert_space_before_opening_brace_in_enum_constant, typeDeclaration);

        if (this.preferences.indent_body_declarations_compare_to_enum_constant_header) {
            this.scribe.indent();
        }

        if (fieldsCount != 0 || methodsCount != 0 || membersCount != 0) {
            formatTypeMembers(typeDeclaration);
        }

        if (this.preferences.indent_body_declarations_compare_to_enum_constant_header) {
            this.scribe.unIndent();
        }

        if (this.preferences.insert_new_line_in_empty_enum_constant) {
            this.scribe.printNewLine();
        }
        this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
        this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
        if (enum_constant_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
            this.scribe.unIndent();
        }
        if (hasComments()) {
            this.scribe.printNewLine();
        }
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTConverter.java   
public EnumConstantDeclaration convert(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration enumConstant) {
    checkCanceled();
    EnumConstantDeclaration enumConstantDeclaration = new EnumConstantDeclaration(this.ast);
    final SimpleName typeName = new SimpleName(this.ast);
    typeName.internalSetIdentifier(new String(enumConstant.name));
    typeName.setSourceRange(enumConstant.sourceStart, enumConstant.sourceEnd - enumConstant.sourceStart + 1);
    enumConstantDeclaration.setName(typeName);
    int declarationSourceStart = enumConstant.declarationSourceStart;
    int declarationSourceEnd = enumConstant.declarationSourceEnd;
    final org.eclipse.jdt.internal.compiler.ast.Expression initialization = enumConstant.initialization;
    if (initialization != null) {
        if (initialization instanceof QualifiedAllocationExpression) {
            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration anonymousType = ((QualifiedAllocationExpression) initialization).anonymousType;
            if (anonymousType != null) {
                AnonymousClassDeclaration anonymousClassDeclaration = new AnonymousClassDeclaration(this.ast);
                int start = retrieveStartBlockPosition(anonymousType.sourceEnd, anonymousType.bodyEnd);
                int end = retrieveRightBrace(anonymousType.bodyEnd, declarationSourceEnd);
                if (end == -1) end = anonymousType.bodyEnd;
                anonymousClassDeclaration.setSourceRange(start, end - start + 1);
                enumConstantDeclaration.setAnonymousClassDeclaration(anonymousClassDeclaration);
                buildBodyDeclarations(anonymousType, anonymousClassDeclaration);
                if (this.resolveBindings) {
                    recordNodes(anonymousClassDeclaration, anonymousType);
                    anonymousClassDeclaration.resolveBinding();
                }
                enumConstantDeclaration.setSourceRange(declarationSourceStart, end - declarationSourceStart + 1);
            }
        } else {
            enumConstantDeclaration.setSourceRange(declarationSourceStart, declarationSourceEnd - declarationSourceStart + 1);
        }
        final org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = ((org.eclipse.jdt.internal.compiler.ast.AllocationExpression) initialization).arguments;
        if (arguments != null) {
            for (int i = 0, max = arguments.length; i < max; i++) {
                enumConstantDeclaration.arguments().add(convert(arguments[i]));
            }
        }
    } else {
        enumConstantDeclaration.setSourceRange(declarationSourceStart, declarationSourceEnd - declarationSourceStart + 1);
    }
    setModifiers(enumConstantDeclaration, enumConstant);
    if (this.resolveBindings) {
        recordNodes(enumConstantDeclaration, enumConstant);
        recordNodes(typeName, enumConstant);
        enumConstantDeclaration.resolveVariable();
    }
    convert(enumConstant.javadoc, enumConstantDeclaration);
    return enumConstantDeclaration;
}
项目:lombok    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(QualifiedAllocationExpression node, BlockScope scope) {
    setGeneratedBy(node, source);
    applyOffsetExpression(node);
    return super.visit(node, scope);
}