List of usage examples for org.eclipse.jdt.internal.compiler.ast StringLiteralConcatenation source
@Override public char[] source()
From source file:org.eclipse.ajdt.core.parserbridge.AJCompilationUnitStructureRequestor.java
License:Open Source License
/** * Only handle certain kinds of expressions * all others will be returned as null/*from www. ja va 2s. c o m*/ * * String constants * int constants * arrays * ClassRefs * Enum ref * Annotation ref * * @param ajExpr * @return jdtExpr */ private Expression convertToJDTExpression(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression ajExpr) { if (ajExpr == null) { return null; } Expression jdtExpr = null; if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation) ajExpr; StringLiteralConcatenation castedJDT = new StringLiteralConcatenation( (StringLiteral) convertToJDTExpression(castedAJ.literals[0]), (StringLiteral) convertToJDTExpression(castedAJ.literals[1])); for (int i = 2; i < castedAJ.literals.length; i++) { // may not be able to handle non-string constants here castedJDT.extendsWith((StringLiteral) convertToJDTExpression(castedAJ.literals[i])); } jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) ajExpr; CharLiteral castedJDT = new CharLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd); jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) ajExpr; DoubleLiteral castedJDT = new DoubleLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd); jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) ajExpr; FloatLiteral castedJDT = new FloatLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd); jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) { // ECLIPSE 3.7.1 --- must use reflection since constructors have changed // ORIG // IntLiteralMinValue castedJDT = new IntLiteralMinValue(); org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) ajExpr; IntLiteral castedJDT = null; try { castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTIntLiteralMinValue(castedAJ); } catch (Exception e) { } jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) { // ECLIPSE 3.7.1 --- must use reflection since constructors have changed // ORIG // IntLiteralMinValue castedJDT = new IntLiteralMinValue(); org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) ajExpr; IntLiteral castedJDT = null; try { castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTIntLiteral(castedAJ); } catch (Exception e) { } jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) ajExpr; FalseLiteral castedJDT = null; try { castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTFalseLiteral(castedAJ); } catch (Exception e) { } jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) ajExpr; NullLiteral castedJDT = null; try { castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTNullLiteral(castedAJ); } catch (Exception e) { } jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) ajExpr; TrueLiteral castedJDT = null; try { castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTTrueLiteral(castedAJ); } catch (Exception e) { } jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) { // ECLIPSE 3.7.1 --- must use reflection since constructors have changed // ORIG // IntLiteralMinValue castedJDT = new IntLiteralMinValue(); org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) ajExpr; LongLiteral castedJDT = null; try { castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTLongLiteralMinValue(castedAJ); } catch (Exception e) { } jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) { // ECLIPSE 3.7.1 --- must use reflection since constructors have changed // ORIG // IntLiteralMinValue castedJDT = new IntLiteralMinValue(); org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) ajExpr; LongLiteral castedJDT = null; try { castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTLongLiteral(castedAJ); } catch (Exception e) { } jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) { // note that here we capture both StringLiteral and ExtendedStringLiteral org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) ajExpr; // can we get away with no line number? StringLiteral castedJDT = new StringLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd, 0); jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) ajExpr; ArrayInitializer castedJDT = new ArrayInitializer(); if (castedAJ.expressions != null) { castedJDT.expressions = new Expression[castedAJ.expressions.length]; for (int i = 0; i < castedJDT.expressions.length; i++) { castedJDT.expressions[i] = convertToJDTExpression(castedAJ.expressions[i]); } } jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) ajExpr; ArrayAllocationExpression castedJDT = new ArrayAllocationExpression(); castedJDT.type = convertToJDTTypeReference(castedAJ.type); if (castedAJ.dimensions != null) { castedJDT.dimensions = new Expression[castedAJ.dimensions.length]; for (int i = 0; i < castedJDT.dimensions.length; i++) { castedJDT.dimensions[i] = convertToJDTExpression(castedAJ.dimensions[i]); } } castedJDT.initializer = (ArrayInitializer) convertToJDTExpression(castedAJ.initializer); jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference) ajExpr; FieldReference castedJDT = new FieldReference(castedAJ.token, toPos(castedAJ.sourceStart, castedAJ.sourceEnd)); castedJDT.nameSourcePosition = castedAJ.nameSourcePosition; castedJDT.receiver = convertToJDTExpression(castedAJ.receiver); jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference) ajExpr; ArrayReference castedJDT = new ArrayReference(convertToJDTExpression(castedAJ.receiver), convertToJDTExpression(castedAJ.position)); jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference) ajExpr; QualifiedNameReference castedJDT = new QualifiedNameReference(castedAJ.tokens, castedAJ.sourcePositions, castedAJ.sourceStart, castedAJ.sourceEnd); castedJDT.indexOfFirstFieldBinding = castedAJ.indexOfFirstFieldBinding; jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference) ajExpr; SingleNameReference castedJDT = new SingleNameReference(castedAJ.token, toPos(castedAJ.sourceStart, castedAJ.sourceEnd)); jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) { jdtExpr = convertToJDTTypeReference( (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) ajExpr); } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) ajExpr; ClassLiteralAccess castedJDT = new ClassLiteralAccess(castedAJ.sourceEnd, convertToJDTTypeReference(castedAJ.type)); jdtExpr = castedJDT; } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) { jdtExpr = convertToJDTAnnotation((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) ajExpr); } if (jdtExpr != null) { // now fill in other fields jdtExpr.bits = ajExpr.bits; jdtExpr.implicitConversion = ajExpr.implicitConversion; jdtExpr.sourceStart = ajExpr.sourceStart; jdtExpr.sourceEnd = ajExpr.sourceEnd; jdtExpr.statementEnd = ajExpr.statementEnd; } return jdtExpr; }