List of usage examples for org.eclipse.jdt.internal.compiler.ast BreakStatement BreakStatement
public BreakStatement(char[] label, int sourceStart, int e)
From source file:lombok.eclipse.handlers.ast.EclipseASTMaker.java
License:Open Source License
@Override public ASTNode visitBreak(final lombok.ast.Break node, final Void p) { final BreakStatement breakStatement = new BreakStatement( node.getLabel() == null ? null : node.getLabel().toCharArray(), 0, 0); setGeneratedByAndCopyPos(breakStatement, source, posHintOf(node)); return breakStatement; }
From source file:lombok.eclipse.handlers.singulars.EclipseJavaUtilListSingularizer.java
License:Open Source License
@Override public void appendBuildCode(SingularData data, EclipseNode builderType, List<Statement> statements, char[] targetVariableName) { if (useGuavaInstead(builderType)) { guavaListSetSingularizer.appendBuildCode(data, builderType, statements, targetVariableName); return;// w ww .j av a 2s .com } List<Statement> switchContents = new ArrayList<Statement>(); /* case 0: (empty) break; */ { switchContents.add(new CaseStatement(makeIntLiteral(new char[] { '0' }, null), 0, 0)); MessageSend invoke = new MessageSend(); invoke.receiver = new QualifiedNameReference(JAVA_UTIL_COLLECTIONS, NULL_POSS, 0, 0); invoke.selector = "emptyList".toCharArray(); switchContents.add(new Assignment(new SingleNameReference(data.getPluralName(), 0), invoke, 0)); switchContents.add(new BreakStatement(null, 0, 0)); } /* case 1: (singleton) break; */ { switchContents.add(new CaseStatement(makeIntLiteral(new char[] { '1' }, null), 0, 0)); FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L); thisDotField.receiver = new ThisReference(0, 0); MessageSend thisDotFieldGet0 = new MessageSend(); thisDotFieldGet0.receiver = thisDotField; thisDotFieldGet0.selector = new char[] { 'g', 'e', 't' }; thisDotFieldGet0.arguments = new Expression[] { makeIntLiteral(new char[] { '0' }, null) }; Expression[] args = new Expression[] { thisDotFieldGet0 }; MessageSend invoke = new MessageSend(); invoke.receiver = new QualifiedNameReference(JAVA_UTIL_COLLECTIONS, NULL_POSS, 0, 0); invoke.selector = "singletonList".toCharArray(); invoke.arguments = args; switchContents.add(new Assignment(new SingleNameReference(data.getPluralName(), 0), invoke, 0)); switchContents.add(new BreakStatement(null, 0, 0)); } /* default: Create by passing builder field to constructor. */ { switchContents.add(new CaseStatement(null, 0, 0)); Expression argToUnmodifiable; /* new j.u.ArrayList<Generics>(this.pluralName); */ { FieldReference thisDotPluralName = new FieldReference(data.getPluralName(), 0L); thisDotPluralName.receiver = new ThisReference(0, 0); TypeReference targetTypeExpr = new QualifiedTypeReference(JAVA_UTIL_ARRAYLIST, NULL_POSS); targetTypeExpr = addTypeArgs(1, false, builderType, targetTypeExpr, data.getTypeArgs()); AllocationExpression constructorCall = new AllocationExpression(); constructorCall.type = targetTypeExpr; constructorCall.arguments = new Expression[] { thisDotPluralName }; argToUnmodifiable = constructorCall; } /* pluralname = Collections.unmodifiableList(-newlist-); */ { MessageSend unmodInvoke = new MessageSend(); unmodInvoke.receiver = new QualifiedNameReference(JAVA_UTIL_COLLECTIONS, NULL_POSS, 0, 0); unmodInvoke.selector = "unmodifiableList".toCharArray(); unmodInvoke.arguments = new Expression[] { argToUnmodifiable }; switchContents .add(new Assignment(new SingleNameReference(data.getPluralName(), 0), unmodInvoke, 0)); } } SwitchStatement switchStat = new SwitchStatement(); switchStat.statements = switchContents.toArray(new Statement[switchContents.size()]); switchStat.expression = getSize(builderType, data.getPluralName(), true); TypeReference localShadowerType = new QualifiedTypeReference(Eclipse.fromQualifiedName(data.getTargetFqn()), NULL_POSS); localShadowerType = addTypeArgs(1, false, builderType, localShadowerType, data.getTypeArgs()); LocalDeclaration varDefStat = new LocalDeclaration(data.getPluralName(), 0, 0); varDefStat.type = localShadowerType; statements.add(varDefStat); statements.add(switchStat); }
From source file:lombok.eclipse.handlers.singulars.EclipseJavaUtilSingularizer.java
License:Open Source License
protected List<Statement> createJavaUtilSetMapInitialCapacitySwitchStatements(SingularData data, EclipseNode builderType, boolean mapMode, String emptyCollectionMethod, String singletonCollectionMethod, String targetType) { List<Statement> switchContents = new ArrayList<Statement>(); char[] keyName = mapMode ? (new String(data.getPluralName()) + "$key").toCharArray() : data.getPluralName(); if (emptyCollectionMethod != null) { // case 0: (empty); break; switchContents.add(new CaseStatement(makeIntLiteral(new char[] { '0' }, null), 0, 0)); /* pluralName = java.util.Collections.emptyCollectionMethod(); */ { MessageSend invoke = new MessageSend(); invoke.receiver = new QualifiedNameReference(JAVA_UTIL_COLLECTIONS, NULL_POSS, 0, 0); invoke.selector = emptyCollectionMethod.toCharArray(); switchContents.add(new Assignment(new SingleNameReference(data.getPluralName(), 0), invoke, 0)); }/*w w w . j a v a 2s.c o m*/ switchContents.add(new BreakStatement(null, 0, 0)); } if (singletonCollectionMethod != null) { // case 1: (singleton); break; switchContents.add(new CaseStatement(makeIntLiteral(new char[] { '1' }, null), 0, 0)); /* !mapMode: pluralName = java.util.Collections.singletonCollectionMethod(this.pluralName.get(0)); mapMode: pluralName = java.util.Collections.singletonCollectionMethod(this.pluralName$key.get(0), this.pluralName$value.get(0)); */ { FieldReference thisDotKey = new FieldReference(keyName, 0L); thisDotKey.receiver = new ThisReference(0, 0); MessageSend thisDotKeyGet0 = new MessageSend(); thisDotKeyGet0.receiver = thisDotKey; thisDotKeyGet0.selector = new char[] { 'g', 'e', 't' }; thisDotKeyGet0.arguments = new Expression[] { makeIntLiteral(new char[] { '0' }, null) }; Expression[] args; if (mapMode) { char[] valueName = (new String(data.getPluralName()) + "$value").toCharArray(); FieldReference thisDotValue = new FieldReference(valueName, 0L); thisDotValue.receiver = new ThisReference(0, 0); MessageSend thisDotValueGet0 = new MessageSend(); thisDotValueGet0.receiver = thisDotValue; thisDotValueGet0.selector = new char[] { 'g', 'e', 't' }; thisDotValueGet0.arguments = new Expression[] { makeIntLiteral(new char[] { '0' }, null) }; args = new Expression[] { thisDotKeyGet0, thisDotValueGet0 }; } else { args = new Expression[] { thisDotKeyGet0 }; } MessageSend invoke = new MessageSend(); invoke.receiver = new QualifiedNameReference(JAVA_UTIL_COLLECTIONS, NULL_POSS, 0, 0); invoke.selector = singletonCollectionMethod.toCharArray(); invoke.arguments = args; switchContents.add(new Assignment(new SingleNameReference(data.getPluralName(), 0), invoke, 0)); } switchContents.add(new BreakStatement(null, 0, 0)); } { // default: switchContents.add(new CaseStatement(null, 0, 0)); switchContents.addAll(createJavaUtilSimpleCreationAndFillStatements(data, builderType, mapMode, false, true, emptyCollectionMethod == null, targetType)); } SwitchStatement switchStat = new SwitchStatement(); switchStat.statements = switchContents.toArray(new Statement[switchContents.size()]); switchStat.expression = getSize(builderType, keyName, true); TypeReference localShadowerType = new QualifiedTypeReference(fromQualifiedName(data.getTargetFqn()), NULL_POSS); localShadowerType = addTypeArgs(mapMode ? 2 : 1, false, builderType, localShadowerType, data.getTypeArgs()); LocalDeclaration varDefStat = new LocalDeclaration(data.getPluralName(), 0, 0); varDefStat.type = localShadowerType; return Arrays.asList(varDefStat, switchStat); }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeStatementBreak() { // BreakStatement ::= 'break' ';' // break pushs a position on this.intStack in case there is no label pushOnAstStack(new BreakStatement(null, this.intStack[this.intPtr--], this.endStatementPosition)); if (this.pendingRecoveredType != null) { // Used only in statements recovery. // This is not a real break statement but a placeholder for an existing local type. // The break statement must be replace by the local type. if (this.pendingRecoveredType.allocation == null && this.endPosition <= this.pendingRecoveredType.declarationSourceEnd) { this.astStack[this.astPtr] = this.pendingRecoveredType; this.pendingRecoveredType = null; return; }//from w w w . ja v a2 s . co m this.pendingRecoveredType = null; } }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeStatementBreakWithLabel() { // BreakStatement ::= 'break' Identifier ';' // break pushs a position on this.intStack in case there is no label pushOnAstStack(new BreakStatement(this.identifierStack[this.identifierPtr--], this.intStack[this.intPtr--], this.endStatementPosition)); this.identifierLengthPtr--; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.AstGenerator.java
License:Open Source License
public BreakStatement breakStatement() { return new BreakStatement(null, this.sourceStart, this.sourceEnd); }
From source file:org.nabucco.framework.mda.model.java.ast.produce.JavaAstModelProducer.java
License:Open Source License
/** * Create a <code>break</b> statement. * /*from ww w . ja v a 2s . co m*/ * @return the break statement * * @throws JavaModelException */ public BreakStatement createBreakStatement() throws JavaModelException { return new BreakStatement(null, 0, 0); }
From source file:org.nabucco.framework.mda.template.java.extract.statement.JavaAstStatementExtractorVisitor.java
License:Open Source License
@Override public boolean visit(BreakStatement breakStatement, BlockScope scope) { BreakStatement breakCopy = new BreakStatement(breakStatement.label.clone(), breakStatement.sourceStart, breakStatement.sourceEnd);/*from ww w .jav a 2 s . co m*/ this.statement = breakCopy; return false; }