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

项目:Eclipse-Postfix-Code-Completion    文件:LocalTypeBinding.java   
public LocalTypeBinding(ClassScope scope, SourceTypeBinding enclosingType, CaseStatement switchCase) {
    super(
        new char[][] {CharOperation.concat(LocalTypeBinding.LocalTypePrefix, scope.referenceContext.name)},
        scope,
        enclosingType);
    TypeDeclaration typeDeclaration = scope.referenceContext;
    if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
        this.tagBits |= TagBits.AnonymousTypeMask;
    } else {
        this.tagBits |= TagBits.LocalTypeMask;
    }
    this.enclosingCase = switchCase;
    this.sourceStart = typeDeclaration.sourceStart;
    MethodScope methodScope = scope.enclosingMethodScope();
    MethodBinding methodBinding = methodScope.referenceMethodBinding();
    if (methodBinding != null) {
        this.enclosingMethod = methodBinding;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LocalTypeBinding.java   
public LocalTypeBinding(ClassScope scope, SourceTypeBinding enclosingType, CaseStatement switchCase) {
    super(
        new char[][] {CharOperation.concat(LocalTypeBinding.LocalTypePrefix, scope.referenceContext.name)},
        scope,
        enclosingType);
    TypeDeclaration typeDeclaration = scope.referenceContext;
    if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
        this.tagBits |= TagBits.AnonymousTypeMask;
    } else {
        this.tagBits |= TagBits.LocalTypeMask;
    }
    this.enclosingCase = switchCase;
    this.sourceStart = typeDeclaration.sourceStart;
    MethodScope methodScope = scope.enclosingMethodScope();
    AbstractMethodDeclaration methodDeclaration = methodScope.referenceMethod();
    if (methodDeclaration != null) {
        this.enclosingMethod = methodDeclaration.binding;
    }
}
项目:xapi    文件:GwtAstBuilder.java   
@Override
public void endVisit(CaseStatement x, BlockScope scope) {
  try {
    SourceInfo info = makeSourceInfo(x);
    JExpression constantExpression = pop(x.constantExpression);
    JLiteral caseLiteral;
    if (constantExpression == null) {
      caseLiteral = null;
    } else if (constantExpression instanceof JLiteral) {
      caseLiteral = (JLiteral) constantExpression;
    } else {
      // Adapted from CaseStatement.resolveCase().
      assert x.constantExpression.resolvedType.isEnum();
      NameReference reference = (NameReference) x.constantExpression;
      FieldBinding field = reference.fieldBinding();
      caseLiteral = JIntLiteral.get(field.original().id);
    }
    push(new JCaseStatement(info, caseLiteral));
  } catch (Throwable e) {
    throw translateException(x, e);
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.CaseStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(CaseStatement caseStatement, BlockScope scope) {
    if (caseStatement.constantExpression == null) {
        this.scribe.printNextToken(TerminalTokens.TokenNamedefault);
        this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_default);
    } else {
        this.scribe.printNextToken(TerminalTokens.TokenNamecase);
        this.scribe.space();
        caseStatement.constantExpression.traverse(this, scope);
        this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_case);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeCaseLabel() {
    // SwitchLabel ::= 'case' ConstantExpression ':'
    this.expressionLengthPtr--;
    Expression expression = this.expressionStack[this.expressionPtr--];
    CaseStatement caseStatement = new CaseStatement(expression, expression.sourceEnd, this.intStack[this.intPtr--]);
    // Look for $fall-through$ tag in leading comment for case statement
    if (hasLeadingTagComment(FALL_THROUGH_TAG, caseStatement.sourceStart)) {
        caseStatement.bits |= ASTNode.DocumentedFallthrough;
    }
    pushOnAstStack(caseStatement);
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeDefaultLabel() {
    // SwitchLabel ::= 'default' ':'
    CaseStatement defaultStatement = new CaseStatement(null, this.intStack[this.intPtr--], this.intStack[this.intPtr--]);
    // Look for $fall-through$ and $CASES-OMITTED$ tags in leading comment for case statement
    if (hasLeadingTagComment(FALL_THROUGH_TAG, defaultStatement.sourceStart)) {
        defaultStatement.bits |= ASTNode.DocumentedFallthrough;
    }
    if (hasLeadingTagComment(CASES_OMITTED_TAG, defaultStatement.sourceStart)) {
        defaultStatement.bits |= ASTNode.DocumentedCasesOmitted;
    }
    pushOnAstStack(defaultStatement);
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void duplicateCase(CaseStatement caseStatement) {
    this.handle(
        IProblem.DuplicateCase,
        NoArgument,
        NoArgument,
        caseStatement.sourceStart,
        caseStatement.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void possibleFallThroughCase(CaseStatement caseStatement) {
    // as long as we consider fake reachable as reachable, better keep 'possible' in the name
    this.handle(
        IProblem.FallthroughCase,
        NoArgument,
        NoArgument,
        caseStatement.sourceStart,
        caseStatement.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.CaseStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(CaseStatement caseStatement, BlockScope scope) {
    if (caseStatement.constantExpression == null) {
        this.scribe.printNextToken(TerminalTokens.TokenNamedefault);
        this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_default);
    } else {
        this.scribe.printNextToken(TerminalTokens.TokenNamecase);
        this.scribe.space();
        caseStatement.constantExpression.traverse(this, scope);
        this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_case);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void duplicateCase(CaseStatement caseStatement) {
    this.handle(
        IProblem.DuplicateCase,
        NoArgument,
        NoArgument,
        caseStatement.sourceStart,
        caseStatement.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void possibleFallThroughCase(CaseStatement caseStatement) {
    // as long as we consider fake reachable as reachable, better keep 'possible' in the name
    this.handle(
        IProblem.FallthroughCase,
        NoArgument,
        NoArgument,
        caseStatement.sourceStart,
        caseStatement.sourceEnd);
}
项目:lombok-ianchiu    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(CaseStatement node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:EasyMPermission    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(CaseStatement node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:Eclipse-Postfix-Code-Completion    文件:SelectionParser.java   
private void buildMoreCompletionContext(Expression expression) {
    ASTNode parentNode = null;

    int kind = topKnownElementKind(SELECTION_OR_ASSIST_PARSER);
    if(kind != 0) {
        int info = topKnownElementInfo(SELECTION_OR_ASSIST_PARSER);
        nextElement : switch (kind) {
            case K_BETWEEN_CASE_AND_COLON :
                if(this.expressionPtr > 0) {
                    SwitchStatement switchStatement = new SwitchStatement();
                    switchStatement.expression = this.expressionStack[this.expressionPtr - 1];
                    if(this.astLengthPtr > -1 && this.astPtr > -1) {
                        int length = this.astLengthStack[this.astLengthPtr];
                        int newAstPtr = this.astPtr - length;
                        ASTNode firstNode = this.astStack[newAstPtr + 1];
                        if(length != 0 && firstNode.sourceStart > switchStatement.expression.sourceEnd) {
                            switchStatement.statements = new Statement[length + 1];
                            System.arraycopy(
                                this.astStack,
                                newAstPtr + 1,
                                switchStatement.statements,
                                0,
                                length);
                        }
                    }
                    CaseStatement caseStatement = new CaseStatement(expression, expression.sourceStart, expression.sourceEnd);
                    if(switchStatement.statements == null) {
                        switchStatement.statements = new Statement[]{caseStatement};
                    } else {
                        switchStatement.statements[switchStatement.statements.length - 1] = caseStatement;
                    }
                    parentNode = switchStatement;
                    this.assistNodeParent = parentNode;
                }
                break nextElement;
            case K_INSIDE_RETURN_STATEMENT :
                if(info == this.bracketDepth) {
                    ReturnStatement returnStatement = new ReturnStatement(expression, expression.sourceStart, expression.sourceEnd);
                    parentNode = returnStatement;
                    this.assistNodeParent = parentNode;
                }
                break nextElement;
            case K_CAST_STATEMENT :
                Expression castType;
                if(this.expressionPtr > 0
                    && ((castType = this.expressionStack[this.expressionPtr-1]) instanceof TypeReference)) {
                    CastExpression cast = new CastExpression(expression, (TypeReference) castType);
                    cast.sourceStart = castType.sourceStart;
                    cast.sourceEnd= expression.sourceEnd;
                    parentNode = cast;
                    this.assistNodeParent = parentNode;
                }
                break nextElement;
        }
    }
    // Do not add assist node/parent into the recovery system if we are inside a lambda. The lambda will be fully recovered including the containing statement and added.
    if (lastIndexOfElement(K_LAMBDA_EXPRESSION_DELIMITER) < 0) {
        if(parentNode != null) {
            this.currentElement = this.currentElement.add((Statement)parentNode, 0);
        } else {
            this.currentElement = this.currentElement.add((Statement)wrapWithExplicitConstructorCallIfNeeded(expression), 0);
            if(this.lastCheckPoint < expression.sourceEnd) {
                this.lastCheckPoint = expression.sourceEnd + 1;
            }
        }
    }
}
项目:lombok    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(CaseStatement node, BlockScope scope) {
    setGeneratedBy(node, source);
    applyOffsetASTNode(node);
    return super.visit(node, scope);
}