diff options
author | aclement <aclement> | 2008-08-28 03:16:52 +0000 |
---|---|---|
committer | aclement <aclement> | 2008-08-28 03:16:52 +0000 |
commit | f56eb37f77b3bd946ef567b2e018bd17b2965f20 (patch) | |
tree | 399b30bdae451d6d800ed1142633ad8520bb34b2 /org.aspectj.ajdt.core | |
parent | 5fd25b258cce531b2f08c8ad39d062a9e51552f9 (diff) | |
download | aspectj-f56eb37f77b3bd946ef567b2e018bd17b2965f20.tar.gz aspectj-f56eb37f77b3bd946ef567b2e018bd17b2965f20.zip |
fixed eclipse warnings
Diffstat (limited to 'org.aspectj.ajdt.core')
21 files changed, 3898 insertions, 3941 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java index e35ae9bc9..1cc4d57d1 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java @@ -41,74 +41,48 @@ import org.aspectj.weaver.bcel.BcelWeaver; import org.aspectj.weaver.bcel.BcelWorld; /** - * Adapts standard JDT Compiler to add in AspectJ specific behaviours. - * This version implements pipelining - where files are compiled and then - * woven immediately, unlike AjCompilerAdapter which compiles everything - * then weaves everything. (One small note: because all aspects have to - * be known before weaving can take place, the weaving pipeline is 'stalled' - * until all aspects have been compiled). + * Adapts standard JDT Compiler to add in AspectJ specific behaviours. This version implements pipelining - where files are compiled + * and then woven immediately, unlike AjCompilerAdapter which compiles everything then weaves everything. (One small note: because + * all aspects have to be known before weaving can take place, the weaving pipeline is 'stalled' until all aspects have been + * compiled). * * The basic strategy is this: * - * 1. diet parse all input source files - * - this is enough for us to implement ITD matching - * - this enables us to determine which are aspects - * 2. sort the input files, aspects first - * - keep a note of how many files contain aspects - * 3. if there are aspects, mark the pipeline as 'stalled' - * 3. repeat - * 3a. compile a file - * 3b. have we now compiled all aspects? - * NO - put file in a weave pending queue - * YES- unstall the 'pipeline' - * 3c. is the pipeline stalled? - * NO - weave all pending files and this one - * YES- do nothing - * - * Complexities arise because of: - * - what does -XterminateAfterCompilation mean? since there is no stage - * where everything is compiled and nothing is woven - * - * + * 1. diet parse all input source files - this is enough for us to implement ITD matching - this enables us to determine which are + * aspects 2. sort the input files, aspects first - keep a note of how many files contain aspects 3. if there are aspects, mark the + * pipeline as 'stalled' 3. repeat 3a. compile a file 3b. have we now compiled all aspects? NO - put file in a weave pending queue + * YES- unstall the 'pipeline' 3c. is the pipeline stalled? NO - weave all pending files and this one YES- do nothing + * + * Complexities arise because of: - what does -XterminateAfterCompilation mean? since there is no stage where everything is compiled + * and nothing is woven + * + * * Here is the compiler loop difference when pipelining. * - * the old way: - * Finished diet parsing [C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java] - * Finished diet parsing [C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java] - * > AjLookupEnvironment.completeTypeBindings() - * < AjLookupEnvironment.completeTypeBindings() - * compiling C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java + * the old way: Finished diet parsing [C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java] Finished diet parsing + * [C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java] > AjLookupEnvironment.completeTypeBindings() < + * AjLookupEnvironment.completeTypeBindings() compiling C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java * >Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) - * <Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) - * compiling C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java + * <Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) compiling + * C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java * >Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) - * <Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) - * >AjCompilerAdapter.weave() - * >BcelWeaver.prepareForWeave - * <BcelWeaver.prepareForWeave - * woven class ClassOne (from C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) - * woven class ClassTwo (from C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) - * <AjCompilerAdapter.weave() + * <Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) >AjCompilerAdapter.weave() + * >BcelWeaver.prepareForWeave <BcelWeaver.prepareForWeave woven class ClassOne (from + * C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) woven class ClassTwo (from + * C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) <AjCompilerAdapter.weave() * - * the new way (see the compiling/weaving mixed up): - * Finished diet parsing [C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java] - * Finished diet parsing [C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java] - * >AjLookupEnvironment.completeTypeBindings() - * <AjLookupEnvironment.completeTypeBindings() - * compiling C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java + * the new way (see the compiling/weaving mixed up): Finished diet parsing + * [C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java] Finished diet parsing + * [C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java] >AjLookupEnvironment.completeTypeBindings() + * <AjLookupEnvironment.completeTypeBindings() compiling C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java * >Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) - * <Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) - * >AjCompilerAdapter.weave() - * >BcelWeaver.prepareForWeave - * <BcelWeaver.prepareForWeave - * woven class ClassOne (from C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) - * <AjCompilerAdapter.weave() - * compiling C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java + * <Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) >AjCompilerAdapter.weave() + * >BcelWeaver.prepareForWeave <BcelWeaver.prepareForWeave woven class ClassOne (from + * C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) <AjCompilerAdapter.weave() compiling + * C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java * >Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) - * <Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) - * >AjCompilerAdapter.weave() - * woven class ClassTwo (from C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) - * <AjCompilerAdapter.weave() + * <Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) >AjCompilerAdapter.weave() woven class ClassTwo + * (from C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) <AjCompilerAdapter.weave() * * */ @@ -128,53 +102,44 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { private IOutputClassFileNameProvider outputFileNameProvider; private IBinarySourceProvider binarySourceProvider; private WeaverMessageHandler weaverMessageHandler; - private Map /* fileName > List<UnwovenClassFile> */ binarySourceSetForFullWeave = new HashMap(); - + private Map /* fileName > List<UnwovenClassFile> */binarySourceSetForFullWeave = new HashMap(); + private ContextToken processingToken = null; private ContextToken resolvingToken = null; private ContextToken analysingToken = null; private ContextToken generatingToken = null; - + private AjState incrementalCompilationState; - + // Maintains a list of whats weaving - whilst the pipeline is stalled, this accumulates aspects. - List /*InterimResult*/ resultsPendingWeave = new ArrayList(); - + List /* InterimResult */resultsPendingWeave = new ArrayList(); + // pipelining info - private boolean pipelineStalled = true; + private boolean pipelineStalled = true; private boolean weaverInitialized = false; private int toWaitFor; - // If we determine we are going to drop back to a full build - don't need to tell the weaver to report adviceDidNotMatch - private boolean droppingBackToFullBuild; - + // If we determine we are going to drop back to a full build - don't need to tell the weaver to report adviceDidNotMatch + private boolean droppingBackToFullBuild; + /** - * Create an adapter, and tell it everything it needs to now to drive the AspectJ - * parts of a compile cycle. - * @param compiler the JDT compiler that produces class files from source - * @param isBatchCompile true if this is a full build (non-incremental) - * @param world the bcelWorld used for type resolution during weaving + * Create an adapter, and tell it everything it needs to now to drive the AspectJ parts of a compile cycle. + * + * @param compiler the JDT compiler that produces class files from source + * @param isBatchCompile true if this is a full build (non-incremental) + * @param world the bcelWorld used for type resolution during weaving * @param weaver the weaver - * @param intRequestor recipient of interim compilation results from compiler (pre-weave) + * @param intRequestor recipient of interim compilation results from compiler (pre-weave) * @param outputFileNameProvider implementor of a strategy providing output file names for results * @param binarySourceEntries binary source that we didn't compile, but that we need to weave - * @param resultSetForFullWeave if we are doing an incremental build, and the weaver determines - * that we need to weave the world, this is the set of intermediate - * results that will be passed to the weaver. + * @param resultSetForFullWeave if we are doing an incremental build, and the weaver determines that we need to weave the world, + * this is the set of intermediate results that will be passed to the weaver. */ - public AjPipeliningCompilerAdapter(Compiler compiler, - boolean isBatchCompile, - BcelWorld world, - BcelWeaver weaver, - EclipseFactory eFactory, - IIntermediateResultsRequestor intRequestor, - IProgressListener progressListener, - IOutputClassFileNameProvider outputFileNameProvider, - IBinarySourceProvider binarySourceProvider, - Map fullBinarySourceEntries, /* fileName |-> List<UnwovenClassFile> */ - boolean isXterminateAfterCompilation, - boolean proceedOnError, - boolean noAtAspectJProcessing, - AjState incrementalCompilationState) { + public AjPipeliningCompilerAdapter(Compiler compiler, boolean isBatchCompile, BcelWorld world, BcelWeaver weaver, + EclipseFactory eFactory, IIntermediateResultsRequestor intRequestor, IProgressListener progressListener, + IOutputClassFileNameProvider outputFileNameProvider, IBinarySourceProvider binarySourceProvider, + Map fullBinarySourceEntries, /* fileName |-> List<UnwovenClassFile> */ + boolean isXterminateAfterCompilation, boolean proceedOnError, boolean noAtAspectJProcessing, + AjState incrementalCompilationState) { this.compiler = compiler; this.isBatchCompile = isBatchCompile; this.weaver = weaver; @@ -190,50 +155,54 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { this.noAtAspectJAnnotationProcessing = noAtAspectJProcessing; this.incrementalCompilationState = incrementalCompilationState; - if (compiler.options.complianceLevel >= ClassFileConstants.JDK1_5) inJava5Mode = true; + if (compiler.options.complianceLevel >= ClassFileConstants.JDK1_5) + inJava5Mode = true; IMessageHandler msgHandler = world.getMessageHandler(); // Do we need to reset the message handler or create a new one? (This saves a ton of memory lost on incremental compiles...) if (msgHandler instanceof WeaverMessageHandler) { - ((WeaverMessageHandler)msgHandler).resetCompiler(compiler); - weaverMessageHandler = (WeaverMessageHandler)msgHandler; + ((WeaverMessageHandler) msgHandler).resetCompiler(compiler); + weaverMessageHandler = (WeaverMessageHandler) msgHandler; } else { weaverMessageHandler = new WeaverMessageHandler(msgHandler, compiler); world.setMessageHandler(weaverMessageHandler); } } - // the compilation lifecycle methods below are called in order as compilation progresses... /** - * In a pipelining compilation system, we need to ensure aspects are through the pipeline first. Only - * when they are all through (and therefore we know about all static/dynamic crosscutting) can be - * proceed to weave anything. Effectively the weaving part of the pipeline stalls until all the - * aspects have been fully compiled. This method sorts the compilation units such that any containing - * aspects are fully compiled first and it keeps a note on how long it should stall the pipeline before - * commencing weaving. + * In a pipelining compilation system, we need to ensure aspects are through the pipeline first. Only when they are all through + * (and therefore we know about all static/dynamic crosscutting) can be proceed to weave anything. Effectively the weaving part + * of the pipeline stalls until all the aspects have been fully compiled. This method sorts the compilation units such that any + * containing aspects are fully compiled first and it keeps a note on how long it should stall the pipeline before commencing + * weaving. */ public void afterDietParsing(CompilationUnitDeclaration[] units) { - if (debugPipeline) System.err.println("> afterDietParsing: there are "+(units==null?0:units.length)+" units to sort"); - - if (!reportedErrors && units!=null) { + if (debugPipeline) + System.err.println("> afterDietParsing: there are " + (units == null ? 0 : units.length) + " units to sort"); + + if (!reportedErrors && units != null) { for (int i = 0; i < units.length; i++) { - if (units[i]!=null && units[i].compilationResult!=null && units[i].compilationResult.hasErrors()) { + if (units[i] != null && units[i].compilationResult != null && units[i].compilationResult.hasErrors()) { reportedErrors = true; break; // TODO break or exit here? } } } - + // Break the units into two lists... List aspects = new ArrayList(); List nonaspects = new ArrayList(); - for (int i=0;i<units.length;i++) { - if (containsAnAspect(units[i])) aspects.add(units[i]); else nonaspects.add(units[i]); + for (int i = 0; i < units.length; i++) { + if (containsAnAspect(units[i])) + aspects.add(units[i]); + else + nonaspects.add(units[i]); } - - if (units == null) return; // what does this mean? - + + if (units == null) + return; // what does this mean? + // ...and put them back together, aspects first int posn = 0; for (Iterator iter = aspects.iterator(); iter.hasNext();) { @@ -242,53 +211,61 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { for (Iterator iter = nonaspects.iterator(); iter.hasNext();) { units[posn++] = (CompilationUnitDeclaration) iter.next(); } - + // Work out how long to stall the pipeline toWaitFor = aspects.size(); - if (debugPipeline) System.err.println("< afterDietParsing: stalling pipeline for "+toWaitFor+" source files"); + if (debugPipeline) + System.err.println("< afterDietParsing: stalling pipeline for " + toWaitFor + " source files"); // TESTING if (pipelineTesting) { - if (pipelineOutput ==null) pipelineOutput = new Hashtable(); + if (pipelineOutput == null) + pipelineOutput = new Hashtable(); pipelineOutput.put("filesContainingAspects", new Integer(toWaitFor).toString()); StringBuffer order = new StringBuffer(); order.append("["); for (int i = 0; i < units.length; i++) { - if (i!=0) order.append(","); + if (i != 0) + order.append(","); CompilationUnitDeclaration declaration = units[i]; String filename = new String(declaration.getFileName()); int idx = filename.lastIndexOf('/'); - if (idx>0) filename=filename.substring(idx+1); + if (idx > 0) + filename = filename.substring(idx + 1); idx = filename.lastIndexOf('\\'); - if (idx>0) filename=filename.substring(idx+1); + if (idx > 0) + filename = filename.substring(idx + 1); order.append(filename); } order.append("]"); pipelineOutput.put("weaveOrder", order.toString()); } } - + public void beforeCompiling(ICompilationUnit[] sourceUnits) { resultsPendingWeave = new ArrayList(); - reportedErrors = false; - droppingBackToFullBuild=false; + reportedErrors = false; + droppingBackToFullBuild = false; } - public void beforeProcessing(CompilationUnitDeclaration unit) { - if (debugPipeline) System.err.println("compiling " + new String(unit.getFileName())); + if (debugPipeline) + System.err.println("compiling " + new String(unit.getFileName())); eWorld.showMessage(IMessage.INFO, "compiling " + new String(unit.getFileName()), null, null); - processingToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_COMPILATION_UNIT,unit.getFileName()); + processingToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_COMPILATION_UNIT, unit + .getFileName()); if (inJava5Mode && !noAtAspectJAnnotationProcessing) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.ADDING_AT_ASPECTJ_ANNOTATIONS, unit.getFileName()); + ContextToken tok = CompilationAndWeavingContext.enteringPhase( + CompilationAndWeavingContext.ADDING_AT_ASPECTJ_ANNOTATIONS, unit.getFileName()); AddAtAspectJAnnotationsVisitor atAspectJVisitor = new AddAtAspectJAnnotationsVisitor(unit); unit.traverse(atAspectJVisitor, unit.scope); CompilationAndWeavingContext.leavingPhase(tok); - } + } } public void beforeResolving(CompilationUnitDeclaration unit) { - resolvingToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.RESOLVING_COMPILATION_UNIT, unit.getFileName()); + resolvingToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.RESOLVING_COMPILATION_UNIT, unit + .getFileName()); } public void afterResolving(CompilationUnitDeclaration unit) { @@ -297,11 +274,12 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { } public void beforeAnalysing(CompilationUnitDeclaration unit) { - analysingToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.ANALYSING_COMPILATION_UNIT, unit.getFileName()); + analysingToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.ANALYSING_COMPILATION_UNIT, unit + .getFileName()); if (inJava5Mode && !noAtAspectJAnnotationProcessing) { ValidateAtAspectJAnnotationsVisitor atAspectJVisitor = new ValidateAtAspectJAnnotationsVisitor(unit); unit.traverse(atAspectJVisitor, unit.scope); - } + } } public void afterAnalysing(CompilationUnitDeclaration unit) { @@ -310,7 +288,8 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { } public void beforeGenerating(CompilationUnitDeclaration unit) { - generatingToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.GENERATING_UNWOVEN_CODE_FOR_COMPILATION_UNIT, unit.getFileName()); + generatingToken = CompilationAndWeavingContext.enteringPhase( + CompilationAndWeavingContext.GENERATING_UNWOVEN_CODE_FOR_COMPILATION_UNIT, unit.getFileName()); } public void afterGenerating(CompilationUnitDeclaration unit) { @@ -322,22 +301,23 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { this.eWorld.cleanup(); if (!weaverInitialized) { // nothing got compiled, doesnt mean there is nothing to do... (binary weaving) if (!(isXTerminateAfterCompilation || (reportedErrors && !proceedOnError))) { -// acceptResult(unit.compilationResult); -// } else { + // acceptResult(unit.compilationResult); + // } else { try { - if (weaveQueuedEntries()) droppingBackToFullBuild=true; + if (weaveQueuedEntries()) + droppingBackToFullBuild = true; } catch (IOException ex) { - AbortCompilation ac = new AbortCompilation(null,ex); + AbortCompilation ac = new AbortCompilation(null, ex); throw ac; - } + } } } postWeave(); try { // not great ... but one more check before we continue, see pr132314 - if (!reportedErrors && units!=null) { + if (!reportedErrors && units != null) { for (int i = 0; i < units.length; i++) { - if (units[i]!=null && units[i].compilationResult!=null && units[i].compilationResult.hasErrors()) { + if (units[i] != null && units[i].compilationResult != null && units[i].compilationResult.hasErrors()) { reportedErrors = true; break; } @@ -347,58 +327,60 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { // no point weaving... just tell the requestor we're done notifyRequestor(); } else { - // weave(); // notification happens as weave progresses... -// weaver.getWorld().flush(); // pr152257 + // weave(); // notification happens as weave progresses... + // weaver.getWorld().flush(); // pr152257 } -// } catch (IOException ex) { -// AbortCompilation ac = new AbortCompilation(null,ex); -// throw ac; + // } catch (IOException ex) { + // AbortCompilation ac = new AbortCompilation(null,ex); + // throw ac; } catch (RuntimeException rEx) { - if (rEx instanceof AbortCompilation) throw rEx; // Don't wrap AbortCompilation exceptions! + if (rEx instanceof AbortCompilation) + throw rEx; // Don't wrap AbortCompilation exceptions! // This will be unwrapped in Compiler.handleInternalException() and the nested // RuntimeException thrown back to the original caller - which is AspectJ // which will then then log it as a compiler problem. - throw new AbortCompilation(true,rEx); + throw new AbortCompilation(true, rEx); } } public void afterProcessing(CompilationUnitDeclaration unit, int unitIndex) { CompilationAndWeavingContext.leavingPhase(processingToken); eWorld.finishedCompilationUnit(unit); - InterimCompilationResult intRes = new InterimCompilationResult(unit.compilationResult,outputFileNameProvider); - if (unit.compilationResult.hasErrors()) reportedErrors = true; - + InterimCompilationResult intRes = new InterimCompilationResult(unit.compilationResult, outputFileNameProvider); + if (unit.compilationResult.hasErrors()) + reportedErrors = true; + if (intermediateResultsRequestor != null) { intermediateResultsRequestor.acceptResult(intRes); } - + if (unit.compilationResult.hasErrors() || (isXTerminateAfterCompilation || (reportedErrors && !proceedOnError))) { acceptResult(unit.compilationResult); } else { queueForWeaving(intRes); } } - - - private void queueForWeaving(InterimCompilationResult intRes) { - resultsPendingWeave.add(intRes); - if (pipelineStalled) { - if (resultsPendingWeave.size()>=toWaitFor) pipelineStalled = false; - } - if (pipelineStalled) return; - try { - if (weaveQueuedEntries()) droppingBackToFullBuild=true; - } catch (IOException ex) { - AbortCompilation ac = new AbortCompilation(null,ex); + + private void queueForWeaving(InterimCompilationResult intRes) { + resultsPendingWeave.add(intRes); + if (pipelineStalled) { + if (resultsPendingWeave.size() >= toWaitFor) + pipelineStalled = false; + } + if (pipelineStalled) + return; + try { + if (weaveQueuedEntries()) + droppingBackToFullBuild = true; + } catch (IOException ex) { + AbortCompilation ac = new AbortCompilation(null, ex); throw ac; - } + } } - - + /* - * Called from the weaverAdapter once it has finished weaving the class files - * associated with a given compilation result. + * Called from the weaverAdapter once it has finished weaving the class files associated with a given compilation result. */ public void acceptResult(CompilationResult result) { compiler.requestor.acceptResult(result.tagAsAccepted()); @@ -416,7 +398,7 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { // helper methods... // ================================================================================== - + private List getBinarySourcesFrom(Map binarySourceEntries) { // Map is fileName |-> List<UnwovenClassFile> List ret = new ArrayList(); @@ -424,48 +406,52 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { String sourceFileName = (String) binIter.next(); List unwovenClassFiles = (List) binarySourceEntries.get(sourceFileName); // XXX - see bugs 57432,58679 - final parameter on next call should be "compiler.options.maxProblemsPerUnit" - CompilationResult result = new CompilationResult(sourceFileName.toCharArray(),0,0,Integer.MAX_VALUE); + CompilationResult result = new CompilationResult(sourceFileName.toCharArray(), 0, 0, Integer.MAX_VALUE); result.noSourceAvailable(); - InterimCompilationResult binarySource = - new InterimCompilationResult(result,unwovenClassFiles); + InterimCompilationResult binarySource = new InterimCompilationResult(result, unwovenClassFiles); ret.add(binarySource); } return ret; } - + private void notifyRequestor() { for (Iterator iter = resultsPendingWeave.iterator(); iter.hasNext();) { InterimCompilationResult iresult = (InterimCompilationResult) iter.next(); compiler.requestor.acceptResult(iresult.result().tagAsAccepted()); } } - + /** Return true if we've decided to drop back to a full build (too much has changed) */ private boolean weaveQueuedEntries() throws IOException { - if (debugPipeline) System.err.println(">.weaveQueuedEntries()"); + if (debugPipeline) + System.err.println(">.weaveQueuedEntries()"); for (Iterator iter = resultsPendingWeave.iterator(); iter.hasNext();) { InterimCompilationResult iresult = (InterimCompilationResult) iter.next(); for (int i = 0; i < iresult.unwovenClassFiles().length; i++) { weaver.addClassFile(iresult.unwovenClassFiles()[i]); - } + } } - ensureWeaverInitialized(); // by doing this only once, are we saying needToReweaveWorld can't change once the aspects have been stuffed into the weaver? - if (weaver.needToReweaveWorld() && !isBatchCompile) return true; - weaver.weave(new WeaverAdapter(this,weaverMessageHandler,progressListener)); + ensureWeaverInitialized(); // by doing this only once, are we saying needToReweaveWorld can't change once the aspects have + // been stuffed into the weaver? + if (weaver.needToReweaveWorld() && !isBatchCompile) + return true; + weaver.weave(new WeaverAdapter(this, weaverMessageHandler, progressListener)); resultsPendingWeave.clear(); // dont need to do those again this.eWorld.minicleanup(); - if (debugPipeline)System.err.println("<.weaveQueuedEntries()"); + if (debugPipeline) + System.err.println("<.weaveQueuedEntries()"); return false; } - + private void ensureWeaverInitialized() { - if (weaverInitialized) return; - weaverInitialized=true; + if (weaverInitialized) + return; + weaverInitialized = true; weaver.setIsBatchWeave(isBatchCompile); weaver.prepareForWeave(); if (weaver.needToReweaveWorld()) { if (!isBatchCompile) { - //force full recompilation from source + // force full recompilation from source this.incrementalCompilationState.forceBatchBuildNextTimeAround(); return; } @@ -475,124 +461,139 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourcesToAdd)); } } - - private void weave() throws IOException { - if (debugPipeline)System.err.println("> weave()"); - // ensure weaver state is set up correctly - for (Iterator iter = resultsPendingWeave.iterator(); iter.hasNext();) { - InterimCompilationResult iresult = (InterimCompilationResult) iter.next(); - for (int i = 0; i < iresult.unwovenClassFiles().length; i++) { - weaver.addClassFile(iresult.unwovenClassFiles()[i]); - } - } - weaver.setIsBatchWeave(isBatchCompile); - weaver.prepareForWeave(); - if (weaver.needToReweaveWorld()) { - if (!isBatchCompile) { - //force full recompilation from source - this.incrementalCompilationState.forceBatchBuildNextTimeAround(); - return; - } - resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourceSetForFullWeave)); - } else { - Map binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave(); - resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourcesToAdd)); - } + // private void weave() throws IOException { + // if (debugPipeline)System.err.println("> weave()"); + // // ensure weaver state is set up correctly + // for (Iterator iter = resultsPendingWeave.iterator(); iter.hasNext();) { + // InterimCompilationResult iresult = (InterimCompilationResult) iter.next(); + // for (int i = 0; i < iresult.unwovenClassFiles().length; i++) { + // weaver.addClassFile(iresult.unwovenClassFiles()[i]); + // } + // } + // + // weaver.setIsBatchWeave(isBatchCompile); + // weaver.prepareForWeave(); + // if (weaver.needToReweaveWorld()) { + // if (!isBatchCompile) { + // //force full recompilation from source + // this.incrementalCompilationState.forceBatchBuildNextTimeAround(); + // return; + // } + // resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourceSetForFullWeave)); + // } else { + // Map binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave(); + // resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourcesToAdd)); + // } + // + // try { + // weaver.weave(new WeaverAdapter(this,weaverMessageHandler,progressListener)); + // } finally { + // weaver.tidyUp(); + // IMessageHandler imh = weaver.getWorld().getMessageHandler(); + // if (imh instanceof WeaverMessageHandler) + // ((WeaverMessageHandler)imh).resetCompiler(null); + // } + // if (debugPipeline)System.err.println("< weave()"); + // } - try { - weaver.weave(new WeaverAdapter(this,weaverMessageHandler,progressListener)); - } finally { - weaver.tidyUp(); - IMessageHandler imh = weaver.getWorld().getMessageHandler(); - if (imh instanceof WeaverMessageHandler) - ((WeaverMessageHandler)imh).resetCompiler(null); - } - if (debugPipeline)System.err.println("< weave()"); - } - private void postWeave() { - if (debugPipeline)System.err.println("> postWeave()"); + if (debugPipeline) + System.err.println("> postWeave()"); IMessageHandler imh = weaver.getWorld().getMessageHandler(); if (imh instanceof WeaverMessageHandler) - ((WeaverMessageHandler)imh).setCurrentResult(null); - if (!droppingBackToFullBuild) weaver.allWeavingComplete(); + ((WeaverMessageHandler) imh).setCurrentResult(null); + if (!droppingBackToFullBuild) + weaver.allWeavingComplete(); weaver.tidyUp(); if (imh instanceof WeaverMessageHandler) - ((WeaverMessageHandler)imh).resetCompiler(null); - if (debugPipeline)System.err.println("< postWeave()"); + ((WeaverMessageHandler) imh).resetCompiler(null); + if (debugPipeline) + System.err.println("< postWeave()"); } - - - - /** - * Return true if the compilation unit declaration contains an aspect declaration (either code style - * or annotation style). It must inspect the multiple types that may be in a compilation - * unit declaration and any inner types. + * Return true if the compilation unit declaration contains an aspect declaration (either code style or annotation style). It + * must inspect the multiple types that may be in a compilation unit declaration and any inner types. */ private boolean containsAnAspect(CompilationUnitDeclaration cud) { TypeDeclaration[] typeDecls = cud.types; - if (typeDecls!=null) { + if (typeDecls != null) { for (int i = 0; i < typeDecls.length; i++) { // loop through top level types in the file TypeDeclaration declaration = typeDecls[i]; - if (isAspect(declaration)) return true; - if (declaration.memberTypes!=null) { + if (isAspect(declaration)) + return true; + if (declaration.memberTypes != null) { TypeDeclaration[] memberTypes = declaration.memberTypes; for (int j = 0; j < memberTypes.length; j++) { // loop through inner types - if (containsAnAspect(memberTypes[j])) return true; + if (containsAnAspect(memberTypes[j])) + return true; } } } } return false; } - + private boolean containsAnAspect(TypeDeclaration tDecl) { - if (isAspect(tDecl)) return true; - if (tDecl.memberTypes!=null) { + if (isAspect(tDecl)) + return true; + if (tDecl.memberTypes != null) { TypeDeclaration[] memberTypes = tDecl.memberTypes; for (int j = 0; j < memberTypes.length; j++) { // loop through inner types - if (containsAnAspect(memberTypes[j])) return true; + if (containsAnAspect(memberTypes[j])) + return true; } } return false; } private static final char[] aspectSig = "Lorg/aspectj/lang/annotation/Aspect;".toCharArray(); + private boolean isAspect(TypeDeclaration declaration) { // avoid an NPE when something else is wrong in this system ... the real problem will be reported elsewhere - if (declaration.staticInitializerScope==null) return false; - if (declaration instanceof AspectDeclaration) return true; // code style - else if (declaration.annotations!=null) { // check for annotation style + if (declaration.staticInitializerScope == null) + return false; + if (declaration instanceof AspectDeclaration) + return true; // code style + else if (declaration.annotations != null) { // check for annotation style for (int index = 0; index < declaration.annotations.length; index++) { - TypeDeclaration.resolveAnnotations(declaration.staticInitializerScope, declaration.annotations, declaration.binding); // force annotation resolution + TypeDeclaration + .resolveAnnotations(declaration.staticInitializerScope, declaration.annotations, declaration.binding); // force + // annotation + // resolution Annotation a = declaration.annotations[index]; - if (a.resolvedType == null) continue; // another problem is being reported, so don't crash here - if (CharOperation.equals(a.resolvedType.signature(),aspectSig)) return true; + if (a.resolvedType == null) + continue; // another problem is being reported, so don't crash here + if (CharOperation.equals(a.resolvedType.signature(), aspectSig)) + return true; } } return false; } // --- - /** - * SECRET: FOR TESTING - this can be used to collect information that tests can verify. - */ + /** + * SECRET: FOR TESTING - this can be used to collect information that tests can verify. + */ public static boolean pipelineTesting = false; public static Hashtable pipelineOutput = null; + // Keys into pipelineOutput: - // compileOrder "[XXX,YYY]" a list of the order in which files will be woven (aspects should be first) - // filesContainingAspects "NNN" how many input source files have aspects inside + // compileOrder "[XXX,YYY]" a list of the order in which files will be woven (aspects should be first) + // filesContainingAspects "NNN" how many input source files have aspects inside // - + public static String getPipelineDebugOutput(String key) { - if (pipelineOutput==null) return ""; - return (String)pipelineOutput.get(key); + if (pipelineOutput == null) + return ""; + return (String) pipelineOutput.get(key); } - + private final boolean debugPipeline = false; - public List getResultsPendingWeave() { return resultsPendingWeave;} + + public List getResultsPendingWeave() { + return resultsPendingWeave; + } }
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java index c7d0792f7..9d7b5535d 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java @@ -31,70 +31,71 @@ import org.aspectj.weaver.LintMessage; /** * @author colyer - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments + * + * To change the template for this generated type comment go to Window>Preferences>Java>Code Generation>Code and + * Comments */ public class WeaverMessageHandler implements IMessageHandler { private IMessageHandler sink; private CompilationResult currentlyWeaving; private Compiler compiler; - + public WeaverMessageHandler(IMessageHandler handler, Compiler compiler) { this.sink = handler; this.compiler = compiler; } - + public void resetCompiler(Compiler c) { this.compiler = c; - currentlyWeaving=null; + currentlyWeaving = null; } - + public void setCurrentResult(CompilationResult result) { currentlyWeaving = result; } public boolean handleMessage(IMessage message) throws AbortException { - if (! (message.isError() || message.isWarning()) ) return sink.handleMessage(message); + if (!(message.isError() || message.isWarning())) + return sink.handleMessage(message); // we only care about warnings and errors here... ISourceLocation sLoc = message.getSourceLocation(); - - // See bug 62073. We should assert that the caller pass the correct primary source location. + + // See bug 62073. We should assert that the caller pass the correct primary source location. // But for AJ1.2 final we will simply do less processing of the locations if that is not the // case (By calling sink.handleMessage()) - this ensures we don't put out bogus source context info. if (sLoc instanceof EclipseSourceLocation) { - EclipseSourceLocation esLoc = (EclipseSourceLocation)sLoc; - if (currentlyWeaving!=null && esLoc.getCompilationResult()!=null) { - if (!currentlyWeaving.equals(((EclipseSourceLocation)sLoc).getCompilationResult())) - return sink.handleMessage(message); - // throw new RuntimeException("Primary source location must match the file we are currently processing!"); + EclipseSourceLocation esLoc = (EclipseSourceLocation) sLoc; + if (currentlyWeaving != null && esLoc.getCompilationResult() != null) { + if (!currentlyWeaving.equals(((EclipseSourceLocation) sLoc).getCompilationResult())) + return sink.handleMessage(message); + // throw new RuntimeException("Primary source location must match the file we are currently processing!"); } } // bug 128618 - want to do a similar thing as in bug 62073 above, however // we're not an EclipseSourceLocation we're a SourceLocation. if (sLoc instanceof SourceLocation) { - SourceLocation sl = (SourceLocation)sLoc; + SourceLocation sl = (SourceLocation) sLoc; if (currentlyWeaving != null && sl.getSourceFile() != null) { - if (!String.valueOf(currentlyWeaving.getFileName()).equals( sl.getSourceFile().getAbsolutePath())) { + if (!String.valueOf(currentlyWeaving.getFileName()).equals(sl.getSourceFile().getAbsolutePath())) { return sink.handleMessage(message); - //throw new RuntimeException("Primary source location must match the file we are currently processing!"); + // throw new RuntimeException("Primary source location must match the file we are currently processing!"); } } } - + CompilationResult problemSource = currentlyWeaving; if (problemSource == null) { // must be a problem found during completeTypeBindings phase of begin to compile if (sLoc instanceof EclipseSourceLocation) { - problemSource = ((EclipseSourceLocation)sLoc).getCompilationResult(); + problemSource = ((EclipseSourceLocation) sLoc).getCompilationResult(); } if (problemSource == null) { // XXX this is ok for ajc, will have to do better for AJDT in time... return sink.handleMessage(message); } } - int startPos = getStartPos(sLoc,problemSource); - int endPos = getEndPos(sLoc,problemSource); + int startPos = getStartPos(sLoc, problemSource); + int endPos = getEndPos(sLoc, problemSource); int severity = message.isError() ? ProblemSeverities.Error : ProblemSeverities.Warning; char[] filename = problemSource.fileName; boolean usedBinarySourceFileName = false; @@ -105,21 +106,13 @@ public class WeaverMessageHandler implements IMessageHandler { } } ReferenceContext referenceContext = findReferenceContextFor(problemSource); - CategorizedProblem problem = compiler.problemReporter.createProblem( - filename, - IProblem.Unclassified, - new String[0], - new String[] {message.getMessage()}, - severity, - startPos, - endPos, - sLoc != null ? sLoc.getLine() : 0,sLoc!=null?sLoc.getColumn():0 - ); - IProblem[] seeAlso = buildSeeAlsoProblems(problem,message.getExtraSourceLocations(), - problemSource, - usedBinarySourceFileName); + CategorizedProblem problem = compiler.problemReporter.createProblem(filename, IProblem.Unclassified, new String[0], + new String[] { message.getMessage() }, severity, startPos, endPos, sLoc != null ? sLoc.getLine() : 0, + sLoc != null ? sLoc.getColumn() : 0); + IProblem[] seeAlso = buildSeeAlsoProblems(problem, message.getExtraSourceLocations(), problemSource, + usedBinarySourceFileName); problem.setSeeAlsoProblems(seeAlso); - + StringBuffer details = new StringBuffer(); // Stick more info in supplementary message info if (message.getDetails() != null) { @@ -130,10 +123,10 @@ public class WeaverMessageHandler implements IMessageHandler { details.append("[deow=true]"); } if (message instanceof LintMessage) { - String lintMessageName = ((LintMessage)message).getLintKind(); + String lintMessageName = ((LintMessage) message).getLintKind(); details.append("[Xlint:").append(lintMessageName).append("]"); } - if (details.length()!=0) { + if (details.length() != 0) { problem.setSupplementaryMessageInfo(details.toString()); } compiler.problemReporter.record(problem, problemSource, referenceContext); @@ -144,53 +137,57 @@ public class WeaverMessageHandler implements IMessageHandler { return sink.isIgnoring(kind); } - /** - * No-op - * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind) - * @param kind - */ - public void dontIgnore(IMessage.Kind kind) { - ; - } - - /** - * No-op - * @see org.aspectj.bridge.IMessageHandler#ignore(org.aspectj.bridge.IMessage.Kind) - * @param kind - */ + /** + * No-op + * + * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind) + * @param kind + */ + public void dontIgnore(IMessage.Kind kind) { + + } + + /** + * No-op + * + * @see org.aspectj.bridge.IMessageHandler#ignore(org.aspectj.bridge.IMessage.Kind) + * @param kind + */ public void ignore(Kind kind) { } - - private int getStartPos(ISourceLocation sLoc,CompilationResult result) { + + private int getStartPos(ISourceLocation sLoc, CompilationResult result) { int pos = 0; - if (sLoc == null) return 0; + if (sLoc == null) + return 0; int line = sLoc.getLine(); if (sLoc instanceof EclipseSourceLocation) { - pos = ((EclipseSourceLocation)sLoc).getStartPos(); + pos = ((EclipseSourceLocation) sLoc).getStartPos(); } else { - if (line <= 1) return 0; + if (line <= 1) + return 0; if (result != null) { - if ((result.lineSeparatorPositions != null) && - (result.lineSeparatorPositions.length >= (line-1))) { - pos = result.lineSeparatorPositions[line-2] + 1; + if ((result.lineSeparatorPositions != null) && (result.lineSeparatorPositions.length >= (line - 1))) { + pos = result.lineSeparatorPositions[line - 2] + 1; } } } return pos; } - private int getEndPos(ISourceLocation sLoc,CompilationResult result) { + private int getEndPos(ISourceLocation sLoc, CompilationResult result) { int pos = 0; - if (sLoc == null) return 0; + if (sLoc == null) + return 0; int line = sLoc.getLine(); - if (line <= 0) line = 1; + if (line <= 0) + line = 1; if (sLoc instanceof EclipseSourceLocation) { - pos = ((EclipseSourceLocation)sLoc).getEndPos(); + pos = ((EclipseSourceLocation) sLoc).getEndPos(); } else { if (result != null) { - if ((result.lineSeparatorPositions != null) && - (result.lineSeparatorPositions.length >= line)) { - pos = result.lineSeparatorPositions[line -1] -1; + if ((result.lineSeparatorPositions != null) && (result.lineSeparatorPositions.length >= line)) { + pos = result.lineSeparatorPositions[line - 1] - 1; } } } @@ -199,50 +196,41 @@ public class WeaverMessageHandler implements IMessageHandler { private ReferenceContext findReferenceContextFor(CompilationResult result) { ReferenceContext context = null; - if (compiler.unitsToProcess == null) return null; + if (compiler.unitsToProcess == null) + return null; for (int i = 0; i < compiler.unitsToProcess.length; i++) { - if ((compiler.unitsToProcess[i] != null) && - (compiler.unitsToProcess[i].compilationResult == result)) { + if ((compiler.unitsToProcess[i] != null) && (compiler.unitsToProcess[i].compilationResult == result)) { context = compiler.unitsToProcess[i]; break; - } + } } return context; } - - private IProblem[] buildSeeAlsoProblems(IProblem originalProblem,List sourceLocations, - CompilationResult problemSource, - boolean usedBinarySourceFileName) { + + private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List sourceLocations, CompilationResult problemSource, + boolean usedBinarySourceFileName) { List ret = new ArrayList(); for (int i = 0; i < sourceLocations.size(); i++) { ISourceLocation loc = (ISourceLocation) sourceLocations.get(i); - if (loc != null ) { - DefaultProblem dp = - new DefaultProblem( loc.getSourceFile().getPath().toCharArray(), - "see also", - 0, - new String[] {}, - ProblemSeverities.Ignore, - getStartPos(loc,null), - getEndPos(loc,null), - loc.getLine(),loc.getColumn()); - ret.add(dp); + if (loc != null) { + DefaultProblem dp = new DefaultProblem(loc.getSourceFile().getPath().toCharArray(), "see also", 0, new String[] {}, + ProblemSeverities.Ignore, getStartPos(loc, null), getEndPos(loc, null), loc.getLine(), loc.getColumn()); + ret.add(dp); } else { System.err.println("About to abort due to null location, dumping state:"); - System.err.println("> Original Problem="+problemSource.toString()); - throw new RuntimeException("Internal Compiler Error: Unexpected null source location passed as 'see also' location."); + System.err.println("> Original Problem=" + problemSource.toString()); + throw new RuntimeException( + "Internal Compiler Error: Unexpected null source location passed as 'see also' location."); } } if (usedBinarySourceFileName) { - DefaultProblem dp = new DefaultProblem(problemSource.fileName,"see also",0,new String[] {}, - ProblemSeverities.Ignore,0, - 0,0,0); + DefaultProblem dp = new DefaultProblem(problemSource.fileName, "see also", 0, new String[] {}, + ProblemSeverities.Ignore, 0, 0, 0, 0); ret.add(dp); } - IProblem[] retValue = (IProblem[])ret.toArray(new IProblem[]{}); + IProblem[] retValue = (IProblem[]) ret.toArray(new IProblem[] {}); return retValue; } } - diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java index 0ec353bb1..a4cc08b8f 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.ajdt.internal.compiler.ast; import java.lang.reflect.Modifier; @@ -46,30 +45,28 @@ import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.UnresolvedType; /** - * Represents before, after and around advice in an aspect. - * Will generate a method corresponding to the body of the advice with an + * Represents before, after and around advice in an aspect. Will generate a method corresponding to the body of the advice with an * attribute including additional information. * * @author Jim Hugunin */ public class AdviceDeclaration extends AjMethodDeclaration { - public PointcutDesignator pointcutDesignator; // set during parsing - int baseArgumentCount; // referenced by IfPseudoToken.makeArguments - - public Argument extraArgument; // set during parsing, referenced by Proceed - - public AdviceKind kind; // set during parsing, referenced by Proceed and AsmElementFormatter + public PointcutDesignator pointcutDesignator; // set during parsing + int baseArgumentCount; // referenced by IfPseudoToken.makeArguments + + public Argument extraArgument; // set during parsing, referenced by Proceed + + public AdviceKind kind; // set during parsing, referenced by Proceed and AsmElementFormatter private int extraArgumentFlags = 0; - - public MethodBinding proceedMethodBinding; // set during this.resolveStaments, referenced by Proceed - public List proceedCalls = new ArrayList(2); // populated during Proceed.findEnclosingAround - + + public MethodBinding proceedMethodBinding; // set during this.resolveStaments, referenced by Proceed + public List proceedCalls = new ArrayList(2); // populated during Proceed.findEnclosingAround + private boolean proceedInInners; private ResolvedMember[] proceedCallSignatures; private boolean[] formalsUnchangedToProceed; private UnresolvedType[] declaredExceptions; - - + public AdviceDeclaration(CompilationResult result, AdviceKind kind) { super(result); this.returnType = TypeReference.baseTypeReference(T_void, 0); @@ -80,33 +77,32 @@ public class AdviceDeclaration extends AjMethodDeclaration { protected int generateInfoAttributes(ClassFile classFile) { List l = new ArrayList(1); l.add(new EclipseAttributeAdapter(makeAttribute())); - addDeclarationStartLineAttribute(l,classFile); + addDeclarationStartLineAttribute(l, classFile); return classFile.generateMethodInfoAttribute(binding, false, l); } - + private AjAttribute makeAttribute() { if (kind == AdviceKind.Around) { - return new AjAttribute.AdviceAttribute(kind, pointcutDesignator.getPointcut(), - extraArgumentFlags, sourceStart, sourceEnd, null, - proceedInInners, proceedCallSignatures, formalsUnchangedToProceed, - declaredExceptions); + return new AjAttribute.AdviceAttribute(kind, pointcutDesignator.getPointcut(), extraArgumentFlags, sourceStart, + sourceEnd, null, proceedInInners, proceedCallSignatures, formalsUnchangedToProceed, declaredExceptions); } else { - return new AjAttribute.AdviceAttribute(kind, pointcutDesignator.getPointcut(), - extraArgumentFlags, sourceStart, sourceEnd, null); + return new AjAttribute.AdviceAttribute(kind, pointcutDesignator.getPointcut(), extraArgumentFlags, sourceStart, + sourceEnd, null); } } // override public void resolveStatements() { - if (binding == null || ignoreFurtherInvestigation) return; - - ClassScope upperScope = (ClassScope)scope.parent; //!!! safety - + if (binding == null || ignoreFurtherInvestigation) + return; + + ClassScope upperScope = (ClassScope) scope.parent; // !!! safety + modifiers = checkAndSetModifiers(modifiers, upperScope); int bindingModifiers = (modifiers | (binding.modifiers & ExtraCompilerModifiers.AccGenericSignature)); binding.modifiers = bindingModifiers; - + if (kind == AdviceKind.AfterThrowing && extraArgument != null) { TypeBinding argTb = extraArgument.binding.type; TypeBinding expectedTb = upperScope.getJavaLangThrowable(); @@ -116,82 +112,80 @@ public class AdviceDeclaration extends AjMethodDeclaration { return; } } - - - pointcutDesignator.finishResolveTypes(this, this.binding, - baseArgumentCount, upperScope.referenceContext.binding); - - if (binding == null || ignoreFurtherInvestigation) return; - + + pointcutDesignator.finishResolveTypes(this, this.binding, baseArgumentCount, upperScope.referenceContext.binding); + + if (binding == null || ignoreFurtherInvestigation) + return; + if (kind == AdviceKind.Around) { - ReferenceBinding[] exceptions = - new ReferenceBinding[] { upperScope.getJavaLangThrowable() }; - proceedMethodBinding = new MethodBinding(Modifier.STATIC | Flags.AccSynthetic, - "proceed".toCharArray(), binding.returnType, - resize(baseArgumentCount+1, binding.parameters), - exceptions, binding.declaringClass); - proceedMethodBinding.selector = - CharOperation.concat(selector, proceedMethodBinding.selector); + ReferenceBinding[] exceptions = new ReferenceBinding[] { upperScope.getJavaLangThrowable() }; + proceedMethodBinding = new MethodBinding(Modifier.STATIC | Flags.AccSynthetic, "proceed".toCharArray(), + binding.returnType, resize(baseArgumentCount + 1, binding.parameters), exceptions, binding.declaringClass); + proceedMethodBinding.selector = CharOperation.concat(selector, proceedMethodBinding.selector); } - - super.resolveStatements(); //upperScope); - if (binding != null) determineExtraArgumentFlags(); - + + super.resolveStatements(); // upperScope); + if (binding != null) + determineExtraArgumentFlags(); + if (kind == AdviceKind.Around) { int n = proceedCalls.size(); -// EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(upperScope); - - //System.err.println("access to: " + Arrays.asList(handler.getMembers())); - - //XXX set these correctly + // EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(upperScope); + + // System.err.println("access to: " + Arrays.asList(handler.getMembers())); + + // XXX set these correctly formalsUnchangedToProceed = new boolean[baseArgumentCount]; proceedCallSignatures = new ResolvedMember[0]; proceedInInners = false; declaredExceptions = new UnresolvedType[0]; - - for (int i=0; i < n; i++) { - Proceed call = (Proceed)proceedCalls.get(i); + + for (int i = 0; i < n; i++) { + Proceed call = (Proceed) proceedCalls.get(i); if (call.inInner) { - //System.err.println("proceed in inner: " + call); + // System.err.println("proceed in inner: " + call); proceedInInners = true; - //XXX wrong - //proceedCallSignatures[i] = world.makeResolvedMember(call.binding); + // XXX wrong + // proceedCallSignatures[i] = world.makeResolvedMember(call.binding); } } - + // ??? should reorganize into AspectDeclaration // if we have proceed in inners we won't ever be inlined so the code below is unneeded if (!proceedInInners) { - PrivilegedHandler handler = (PrivilegedHandler)upperScope.referenceContext.binding.privilegedHandler; + PrivilegedHandler handler = (PrivilegedHandler) upperScope.referenceContext.binding.privilegedHandler; if (handler == null) { - handler = new PrivilegedHandler((AspectDeclaration)upperScope.referenceContext); - //upperScope.referenceContext.binding.privilegedHandler = handler; + handler = new PrivilegedHandler((AspectDeclaration) upperScope.referenceContext); + // upperScope.referenceContext.binding.privilegedHandler = handler; } - - this.traverse(new MakeDeclsPublicVisitor(), (ClassScope)null); - - AccessForInlineVisitor v = new AccessForInlineVisitor((AspectDeclaration)upperScope.referenceContext, handler); - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.ACCESS_FOR_INLINE, selector); + + this.traverse(new MakeDeclsPublicVisitor(), (ClassScope) null); + + AccessForInlineVisitor v = new AccessForInlineVisitor((AspectDeclaration) upperScope.referenceContext, handler); + ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.ACCESS_FOR_INLINE, + selector); this.traverse(v, (ClassScope) null); CompilationAndWeavingContext.leavingPhase(tok); - + // ??? if we found a construct that we can't inline, set - // proceedInInners so that we won't try to inline this body - if (!v.isInlinable) proceedInInners = true; + // proceedInInners so that we won't try to inline this body + if (!v.isInlinable) + proceedInInners = true; } } } - // called by Proceed.resolveType + // called by Proceed.resolveType public int getDeclaredParameterCount() { // this only works before code generation return this.arguments.length - 3 - ((extraArgument == null) ? 0 : 1); - //Advice.countOnes(extraArgumentFlags); + // Advice.countOnes(extraArgumentFlags); } private void generateProceedMethod(ClassScope classScope, ClassFile classFile) { - MethodBinding binding = (MethodBinding)proceedMethodBinding; - + MethodBinding binding = proceedMethodBinding; + classFile.generateMethodInfoHeader(binding); int methodAttributeOffset = classFile.contentsOffset; int attributeNumber = classFile.generateMethodInfoAttribute(binding, false, AstUtil.getAjSyntheticAttribute()); @@ -199,29 +193,24 @@ public class AdviceDeclaration extends AjMethodDeclaration { classFile.generateCodeAttributeHeader(); CodeStream codeStream = classFile.codeStream; codeStream.reset(this, classFile); - + // push the closure int nargs = binding.parameters.length; int closureIndex = 0; - for (int i=0; i < nargs-1; i++) { + for (int i = 0; i < nargs - 1; i++) { closureIndex += AstUtil.slotsNeeded(binding.parameters[i]); } - - + codeStream.aload(closureIndex); - + // build the Object[] - codeStream.generateInlinedValue(nargs-1); - codeStream.newArray( - new ArrayBinding( - classScope.getType(TypeConstants.JAVA_LANG_OBJECT, - TypeConstants.JAVA_LANG_OBJECT.length), - 1, - classScope.environment())); - + codeStream.generateInlinedValue(nargs - 1); + codeStream.newArray(new ArrayBinding(classScope.getType(TypeConstants.JAVA_LANG_OBJECT, + TypeConstants.JAVA_LANG_OBJECT.length), 1, classScope.environment())); + int index = 0; - for (int i=0; i < nargs-1; i++) { + for (int i = 0; i < nargs - 1; i++) { TypeBinding type = binding.parameters[i]; codeStream.dup(); codeStream.generateInlinedValue(i); @@ -230,12 +219,12 @@ public class AdviceDeclaration extends AjMethodDeclaration { if (type.isBaseType()) { codeStream.invokestatic(AjTypeConstants.getConversionMethodToObject(classScope, type)); } - + codeStream.aastore(); } - + // call run - ReferenceBinding closureType = (ReferenceBinding)binding.parameters[nargs-1]; + ReferenceBinding closureType = (ReferenceBinding) binding.parameters[nargs - 1]; MethodBinding runMethod = closureType.getMethods("run".toCharArray())[0]; codeStream.invokevirtual(runMethod); @@ -246,31 +235,31 @@ public class AdviceDeclaration extends AjMethodDeclaration { codeStream.checkcast(returnType); } AstUtil.generateReturn(returnType, codeStream); - codeStream.recordPositionsFrom(0,1); + codeStream.recordPositionsFrom(0, 1); classFile.completeCodeAttribute(codeAttributeOffset); attributeNumber++; classFile.completeMethodInfo(methodAttributeOffset, attributeNumber); } - // override public void generateCode(ClassScope classScope, ClassFile classFile) { - if (ignoreFurtherInvestigation) return; - + if (ignoreFurtherInvestigation) + return; + super.generateCode(classScope, classFile); if (proceedMethodBinding != null) { generateProceedMethod(classScope, classFile); } } - private void determineExtraArgumentFlags() { - if (extraArgument != null) extraArgumentFlags |= Advice.ExtraArgument; - + if (extraArgument != null) + extraArgumentFlags |= Advice.ExtraArgument; + ThisJoinPointVisitor tjp = new ThisJoinPointVisitor(this); extraArgumentFlags |= tjp.removeUnusedExtraArguments(); } - + private static TypeBinding[] resize(int newSize, TypeBinding[] bindings) { int len = bindings.length; TypeBinding[] ret = new TypeBinding[newSize]; @@ -289,75 +278,78 @@ public class AdviceDeclaration extends AjMethodDeclaration { extraArgumentName = new String(extraArgument.name); } String argNames = buildArgNameRepresentation(); - + if (kind == AdviceKind.Before) { - adviceAnnotation = AtAspectJAnnotationFactory.createBeforeAnnotation(pointcutExpression,argNames,declarationSourceStart); + adviceAnnotation = AtAspectJAnnotationFactory.createBeforeAnnotation(pointcutExpression, argNames, + declarationSourceStart); } else if (kind == AdviceKind.After) { - adviceAnnotation = AtAspectJAnnotationFactory.createAfterAnnotation(pointcutExpression,argNames,declarationSourceStart); + adviceAnnotation = AtAspectJAnnotationFactory.createAfterAnnotation(pointcutExpression, argNames, + declarationSourceStart); } else if (kind == AdviceKind.AfterReturning) { - adviceAnnotation = AtAspectJAnnotationFactory.createAfterReturningAnnotation(pointcutExpression,argNames,extraArgumentName,declarationSourceStart); + adviceAnnotation = AtAspectJAnnotationFactory.createAfterReturningAnnotation(pointcutExpression, argNames, + extraArgumentName, declarationSourceStart); } else if (kind == AdviceKind.AfterThrowing) { - adviceAnnotation = AtAspectJAnnotationFactory.createAfterThrowingAnnotation(pointcutExpression,argNames,extraArgumentName,declarationSourceStart); + adviceAnnotation = AtAspectJAnnotationFactory.createAfterThrowingAnnotation(pointcutExpression, argNames, + extraArgumentName, declarationSourceStart); } else if (kind == AdviceKind.Around) { - adviceAnnotation = AtAspectJAnnotationFactory.createAroundAnnotation(pointcutExpression,argNames,declarationSourceStart); + adviceAnnotation = AtAspectJAnnotationFactory.createAroundAnnotation(pointcutExpression, argNames, + declarationSourceStart); } - AtAspectJAnnotationFactory.addAnnotation(this, adviceAnnotation,this.scope); + AtAspectJAnnotationFactory.addAnnotation(this, adviceAnnotation, this.scope); } - + private String buildArgNameRepresentation() { StringBuffer args = new StringBuffer(); int numArgsWeCareAbout = getDeclaredParameterCount(); if (this.arguments != null) { for (int i = 0; i < numArgsWeCareAbout; i++) { - if (i != 0) args.append(","); + if (i != 0) + args.append(","); args.append(new String(this.arguments[i].name)); } } if (extraArgument != null) { - if (numArgsWeCareAbout > 0) { args.append(","); } + if (numArgsWeCareAbout > 0) { + args.append(","); + } args.append(new String(extraArgument.name)); } return args.toString(); } - + // override, Called by ClassScope.postParse public void postParse(TypeDeclaration typeDec) { - AspectDeclaration aspectDecl = (AspectDeclaration)typeDec; + AspectDeclaration aspectDecl = (AspectDeclaration) typeDec; int adviceSequenceNumberInType = aspectDecl.adviceCounter++; - + StringBuffer stringifiedPointcut = new StringBuffer(30); - pointcutDesignator.print(0,stringifiedPointcut); - this.selector = - NameMangler.adviceName( - EclipseFactory.getName(typeDec.binding).replace('.', '_'), - kind, - adviceSequenceNumberInType, - stringifiedPointcut.toString().hashCode()).toCharArray(); + pointcutDesignator.print(0, stringifiedPointcut); + this.selector = NameMangler.adviceName(EclipseFactory.getName(typeDec.binding).replace('.', '_'), kind, + adviceSequenceNumberInType, stringifiedPointcut.toString().hashCode()).toCharArray(); if (arguments != null) { baseArgumentCount = arguments.length; } - + if (kind == AdviceKind.Around) { - extraArgument = makeFinalArgument("ajc_aroundClosure", - AjTypeConstants.getAroundClosureType()); + extraArgument = makeFinalArgument("ajc_aroundClosure", AjTypeConstants.getAroundClosureType()); } - + int addedArguments = 3; if (extraArgument != null) { addedArguments += 1; } - + arguments = extendArgumentsLength(arguments, addedArguments); - + int index = baseArgumentCount; if (extraArgument != null) { arguments[index++] = extraArgument; } - + arguments[index++] = makeFinalArgument("thisJoinPointStaticPart", AjTypeConstants.getJoinPointStaticPartType()); arguments[index++] = makeFinalArgument("thisJoinPoint", AjTypeConstants.getJoinPointType()); arguments[index++] = makeFinalArgument("thisEnclosingJoinPointStaticPart", AjTypeConstants.getJoinPointStaticPartType()); - + if (pointcutDesignator.isError()) { this.ignoreFurtherInvestigation = true; } @@ -365,35 +357,35 @@ public class AdviceDeclaration extends AjMethodDeclaration { } private int checkAndSetModifiers(int modifiers, ClassScope scope) { - if (modifiers == 0) return Modifier.PUBLIC; - else if (modifiers == Modifier.STRICT) return Modifier.PUBLIC | Modifier.STRICT; + if (modifiers == 0) + return Modifier.PUBLIC; + else if (modifiers == Modifier.STRICT) + return Modifier.PUBLIC | Modifier.STRICT; else { tagAsHavingErrors(); - scope.problemReporter().signalError(declarationSourceStart, sourceStart-1, "illegal modifier on advice, only strictfp is allowed"); + scope.problemReporter().signalError(declarationSourceStart, sourceStart - 1, + "illegal modifier on advice, only strictfp is allowed"); return Modifier.PUBLIC; } } // called by IfPseudoToken - public static Argument[] addTjpArguments(Argument[] arguments) { + public static Argument[] addTjpArguments(Argument[] arguments) { int index = arguments.length; arguments = extendArgumentsLength(arguments, 3); - + arguments[index++] = makeFinalArgument("thisJoinPointStaticPart", AjTypeConstants.getJoinPointStaticPartType()); arguments[index++] = makeFinalArgument("thisJoinPoint", AjTypeConstants.getJoinPointType()); arguments[index++] = makeFinalArgument("thisEnclosingJoinPointStaticPart", AjTypeConstants.getJoinPointStaticPartType()); - + return arguments; } - - private static Argument makeFinalArgument(String name, TypeReference typeRef) { - long pos = 0; //XXX encode start and end location + long pos = 0; // XXX encode start and end location return new Argument(name.toCharArray(), pos, typeRef, Modifier.FINAL); } - private static Argument[] extendArgumentsLength(Argument[] args, int addedArguments) { if (args == null) { return new Argument[addedArguments]; @@ -404,62 +396,61 @@ public class AdviceDeclaration extends AjMethodDeclaration { return ret; } - -// public String toString(int tab) { -// String s = tabString(tab); -// if (modifiers != AccDefault) { -// s += modifiersString(modifiers); -// } -// -// if (kind == AdviceKind.Around) { -// s += returnTypeToString(0); -// } -// -// s += new String(selector) + "("; //$NON-NLS-1$ -// if (arguments != null) { -// for (int i = 0; i < arguments.length; i++) { -// s += arguments[i].toString(0); -// if (i != (arguments.length - 1)) -// s = s + ", "; //$NON-NLS-1$ -// }; -// }; -// s += ")"; //$NON-NLS-1$ -// -// if (extraArgument != null) { -// s += "(" + extraArgument.toString(0) + ")"; -// } -// -// -// -// if (thrownExceptions != null) { -// s += " throws "; //$NON-NLS-1$ -// for (int i = 0; i < thrownExceptions.length; i++) { -// s += thrownExceptions[i].toString(0); -// if (i != (thrownExceptions.length - 1)) -// s = s + ", "; //$NON-NLS-1$ -// }; -// }; -// -// s += ": "; -// if (pointcutDesignator != null) { -// s += pointcutDesignator.toString(0); -// } -// -// s += toStringStatements(tab + 1); -// return s; -// } + // public String toString(int tab) { + // String s = tabString(tab); + // if (modifiers != AccDefault) { + // s += modifiersString(modifiers); + // } + // + // if (kind == AdviceKind.Around) { + // s += returnTypeToString(0); + // } + // + // s += new String(selector) + "("; //$NON-NLS-1$ + // if (arguments != null) { + // for (int i = 0; i < arguments.length; i++) { + // s += arguments[i].toString(0); + // if (i != (arguments.length - 1)) + // s = s + ", "; //$NON-NLS-1$ + // }; + // }; + // s += ")"; //$NON-NLS-1$ + // + // if (extraArgument != null) { + // s += "(" + extraArgument.toString(0) + ")"; + // } + // + // + // + // if (thrownExceptions != null) { + // s += " throws "; //$NON-NLS-1$ + // for (int i = 0; i < thrownExceptions.length; i++) { + // s += thrownExceptions[i].toString(0); + // if (i != (thrownExceptions.length - 1)) + // s = s + ", "; //$NON-NLS-1$ + // }; + // }; + // + // s += ": "; + // if (pointcutDesignator != null) { + // s += pointcutDesignator.toString(0); + // } + // + // s += toStringStatements(tab + 1); + // return s; + // } public StringBuffer printBody(int indent, StringBuffer output) { output.append(": "); if (pointcutDesignator != null) { output.append(pointcutDesignator.toString()); } - return super.printBody(indent,output); + return super.printBody(indent, output); } public StringBuffer printReturnType(int indent, StringBuffer output) { if (this.kind == AdviceKind.Around) { - return super.printReturnType(indent,output); + return super.printReturnType(indent, output); } return output; } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java index 7719e213c..d636732b2 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java @@ -334,7 +334,7 @@ public class AspectDeclaration extends TypeDeclaration { return; } - EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope); + // EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope); if (perClause.getKind() == PerClause.SINGLETON) { generatePerSingletonAspectOfMethod(classFile); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java index 9a457245e..af4fb4204 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.ajdt.internal.compiler.ast; import java.lang.reflect.Modifier; @@ -38,22 +37,23 @@ import org.aspectj.weaver.patterns.Pointcut; /** * pointcut [declaredModifiers] [declaredName]([arguments]): [pointcutDesignator]; * - * <p>No method will actually be generated for this node but an attribute - * will be added to the enclosing class.</p> + * <p> + * No method will actually be generated for this node but an attribute will be added to the enclosing class. + * </p> * * @author Jim Hugunin */ public class PointcutDeclaration extends AjMethodDeclaration { public static final char[] mangledPrefix = "ajc$pointcut$".toCharArray(); - + public PointcutDesignator pointcutDesignator; private int declaredModifiers; private String declaredName; private boolean generateSyntheticPointcutMethod = false; private EclipseFactory world = null; - //private boolean mangleSelector = true; - - private ResolvedPointcutDefinition resolvedPointcutDeclaration = null; + // private boolean mangleSelector = true; + + private ResolvedPointcutDefinition resolvedPointcutDeclaration = null; public PointcutDeclaration(CompilationResult compilationResult) { super(compilationResult); @@ -67,222 +67,212 @@ public class PointcutDeclaration extends AjMethodDeclaration { return pointcutDesignator.getPointcut(); } } - - - public void parseStatements( - Parser parser, - CompilationUnitDeclaration unit) { + + public void parseStatements(Parser parser, CompilationUnitDeclaration unit) { // do nothing } public void postParse(TypeDeclaration typeDec) { - if (arguments == null) arguments = new Argument[0]; + if (arguments == null) + arguments = new Argument[0]; this.declaredModifiers = modifiers; this.declaredName = new String(selector); - // amc - if we set mangle selector to false, then the generated bytecode has the + // amc - if we set mangle selector to false, then the generated bytecode has the // pointcut method name that the user of an @Pointcut would expect. // But then we will unpack it again in the weaver which may cause redundant // error messages to be issued. This seems the better trade-off... - //if (mangleSelector) { - selector = CharOperation.concat(mangledPrefix, '$', selector, '$', - Integer.toHexString(sourceStart).toCharArray()); - //} - + // if (mangleSelector) { + selector = CharOperation.concat(mangledPrefix, '$', selector, '$', Integer.toHexString(sourceStart).toCharArray()); + // } + if (Modifier.isAbstract(this.declaredModifiers)) { if (!(typeDec instanceof AspectDeclaration)) { - // check for @Aspect - if (isAtAspectJ(typeDec)) { - ;//no need to check abstract class as JDT does that - } else { - typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd, - "The abstract pointcut " + new String(declaredName) + - " can only be defined in an aspect"); - ignoreFurtherInvestigation = true; - return; - } - } else if (!Modifier.isAbstract(typeDec.modifiers)) { - typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd, - "The abstract pointcut " + new String(declaredName) + - " can only be defined in an abstract aspect"); + // check for @Aspect + if (isAtAspectJ(typeDec)) { + // no need to check abstract class as JDT does that + } else { + typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd, + "The abstract pointcut " + new String(declaredName) + " can only be defined in an aspect"); + ignoreFurtherInvestigation = true; + return; + } + } else if (!Modifier.isAbstract(typeDec.modifiers)) { + typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd, + "The abstract pointcut " + new String(declaredName) + " can only be defined in an abstract aspect"); ignoreFurtherInvestigation = true; return; } } - + if (pointcutDesignator != null) { pointcutDesignator.postParse(typeDec, this); } } - private boolean isAtAspectJ(TypeDeclaration typeDec) { - if (typeDec.annotations == null) - return false; - - for (int i = 0; i < typeDec.annotations.length; i++) { - Annotation annotation = typeDec.annotations[i]; - if ("Lorg/aspectj/lang/annotation/Aspect;".equals(new String(annotation.resolvedType.signature()))) { - return true; - } - } - return false; - } + private boolean isAtAspectJ(TypeDeclaration typeDec) { + if (typeDec.annotations == null) + return false; + for (int i = 0; i < typeDec.annotations.length; i++) { + Annotation annotation = typeDec.annotations[i]; + if ("Lorg/aspectj/lang/annotation/Aspect;".equals(new String(annotation.resolvedType.signature()))) { + return true; + } + } + return false; + } - /** - * Called from the AtAspectJVisitor to create the @Pointcut annotation - * (and corresponding method) for this pointcut - * + /** + * Called from the AtAspectJVisitor to create the @Pointcut annotation (and corresponding method) for this pointcut + * */ public void addAtAspectJAnnotations() { String argNames = buildArgNameRepresentation(); - Annotation pcutAnnotation = - AtAspectJAnnotationFactory.createPointcutAnnotation(getPointcutText(),argNames,declarationSourceStart);; + Annotation pcutAnnotation = AtAspectJAnnotationFactory.createPointcutAnnotation(getPointcutText(), argNames, + declarationSourceStart); + if (annotations == null) { annotations = new Annotation[] { pcutAnnotation }; } else { Annotation[] old = annotations; - annotations = new Annotation[old.length +1]; - System.arraycopy(old,0,annotations,0,old.length); + annotations = new Annotation[old.length + 1]; + System.arraycopy(old, 0, annotations, 0, old.length); annotations[old.length] = pcutAnnotation; - } + } generateSyntheticPointcutMethod = true; } - + private String getPointcutText() { String text = getPointcut().toString(); - if (text.indexOf("BindingTypePattern") == -1) return text; + if (text.indexOf("BindingTypePattern") == -1) + return text; // has been wrecked by resolution, try to reconstruct from tokens if (pointcutDesignator != null) { text = pointcutDesignator.getPointcutDeclarationText(); } return text; } - + private String buildArgNameRepresentation() { StringBuffer args = new StringBuffer(); if (this.arguments != null) { for (int i = 0; i < this.arguments.length; i++) { - if (i != 0) args.append(","); + if (i != 0) + args.append(","); args.append(new String(this.arguments[i].name)); } } return args.toString(); } - - + // coming from an @Pointcut declaration public void setGenerateSyntheticPointcutMethod() { generateSyntheticPointcutMethod = true; - //mangleSelector = false; + // mangleSelector = false; } - - public void resolve(ClassScope upperScope) { + + public void resolve(ClassScope upperScope) { // we attempted to resolve annotations below, but that was too early, so we do it again // now at the 'right' time. - if (binding!= null) { + if (binding != null) { binding.tagBits -= TagBits.AnnotationResolved; resolveAnnotations(scope, this.annotations, this.binding); } - // for the rest of the resolution process, this method should do nothing, use the entry point below... - } - - public void resolvePointcut(ClassScope upperScope) { - this.world = EclipseFactory.fromScopeLookupEnvironment(upperScope); - super.resolve(upperScope); - } + // for the rest of the resolution process, this method should do nothing, use the entry point below... + } + public void resolvePointcut(ClassScope upperScope) { + this.world = EclipseFactory.fromScopeLookupEnvironment(upperScope); + super.resolve(upperScope); + } public void resolveStatements() { if (isAbstract()) { this.modifiers |= ExtraCompilerModifiers.AccSemicolonBody; } - - - if (binding == null || ignoreFurtherInvestigation) return; - if (Modifier.isAbstract(this.declaredModifiers)&& (pointcutDesignator != null)) { + if (binding == null || ignoreFurtherInvestigation) + return; + + if (Modifier.isAbstract(this.declaredModifiers) && (pointcutDesignator != null)) { scope.problemReporter().signalError(sourceStart, sourceEnd, "abstract pointcut can't have body"); ignoreFurtherInvestigation = true; return; } - + if (pointcutDesignator != null) { - pointcutDesignator.finishResolveTypes(this, this.binding, arguments.length, - scope.enclosingSourceType()); + pointcutDesignator.finishResolveTypes(this, this.binding, arguments.length, scope.enclosingSourceType()); } - - //System.out.println("resolved: " + getPointcut() + ", " + getPointcut().state); + + // System.out.println("resolved: " + getPointcut() + ", " + getPointcut().state); makeResolvedPointcutDefinition(world); - resolvedPointcutDeclaration.setPointcut(getPointcut()); + resolvedPointcutDeclaration.setPointcut(getPointcut()); super.resolveStatements(); } - public ResolvedPointcutDefinition makeResolvedPointcutDefinition(EclipseFactory inWorld) { - if (resolvedPointcutDeclaration != null) return resolvedPointcutDeclaration; - //System.out.println("pc: " + getPointcut() + ", " + getPointcut().state); - resolvedPointcutDeclaration = new ResolvedPointcutDefinition( - inWorld.fromBinding(this.binding.declaringClass), - declaredModifiers, - declaredName, - inWorld.fromBindings(this.binding.parameters), - getPointcut()); //??? might want to use null - + if (resolvedPointcutDeclaration != null) + return resolvedPointcutDeclaration; + // System.out.println("pc: " + getPointcut() + ", " + getPointcut().state); + resolvedPointcutDeclaration = new ResolvedPointcutDefinition(inWorld.fromBinding(this.binding.declaringClass), + declaredModifiers, declaredName, inWorld.fromBindings(this.binding.parameters), getPointcut()); // ??? might want to + // use null + resolvedPointcutDeclaration.setPosition(sourceStart, sourceEnd); resolvedPointcutDeclaration.setSourceContext(new EclipseSourceContext(compilationResult)); return resolvedPointcutDeclaration; } - public AjAttribute makeAttribute() { return new AjAttribute.PointcutDeclarationAttribute(makeResolvedPointcutDefinition(world)); } - /** - * A pointcut declaration exists in a classfile only as an attibute on the - * class. Unlike advice and inter-type declarations, it has no corresponding - * method. + * A pointcut declaration exists in a classfile only as an attibute on the class. Unlike advice and inter-type declarations, it + * has no corresponding method. */ public void generateCode(ClassScope classScope, ClassFile classFile) { - this.world = EclipseFactory.fromScopeLookupEnvironment(classScope); - if (ignoreFurtherInvestigation) return ; + this.world = EclipseFactory.fromScopeLookupEnvironment(classScope); + if (ignoreFurtherInvestigation) + return; classFile.extraAttributes.add(new EclipseAttributeAdapter(makeAttribute())); addVersionAttributeIfNecessary(classFile); - + if (generateSyntheticPointcutMethod) { this.binding.modifiers |= ClassFileConstants.AccSynthetic; - super.generateCode(classScope,classFile); + super.generateCode(classScope, classFile); } return; } - + /** - * Normally, pointcuts occur in aspects - aspects are always tagged with a weaver version attribute, - * see AspectDeclaration. However, pointcuts can also occur in regular classes and in this case there - * is no AspectDeclaration to ensure the attribute is added. So, this method adds the attribute - * if someone else hasn't already. + * Normally, pointcuts occur in aspects - aspects are always tagged with a weaver version attribute, see AspectDeclaration. + * However, pointcuts can also occur in regular classes and in this case there is no AspectDeclaration to ensure the attribute + * is added. So, this method adds the attribute if someone else hasn't already. */ private void addVersionAttributeIfNecessary(ClassFile classFile) { for (Iterator iter = classFile.extraAttributes.iterator(); iter.hasNext();) { EclipseAttributeAdapter element = (EclipseAttributeAdapter) iter.next(); - if (CharOperation.equals(element.getNameChars(),weaverVersionChars)) return; + if (CharOperation.equals(element.getNameChars(), weaverVersionChars)) + return; } classFile.extraAttributes.add(new EclipseAttributeAdapter(new AjAttribute.WeaverVersionInfo())); } + private static char[] weaverVersionChars = "org.aspectj.weaver.WeaverVersion".toCharArray(); - - + protected int generateInfoAttributes(ClassFile classFile) { - return super.generateInfoAttributes(classFile,true); + return super.generateInfoAttributes(classFile, true); } - + public StringBuffer printReturnType(int indent, StringBuffer output) { return output.append("pointcut"); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration#printBody(int, java.lang.StringBuffer) */ public StringBuffer printBody(int indent, StringBuffer output) { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java index 14c37c316..a645d3fd7 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java @@ -582,7 +582,7 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor { // && returnsVoid // && (methodDeclaration.arguments == null || methodDeclaration.arguments.length == 0)) { ) { - ;// fine + // fine } else { methodDeclaration.scope.problemReporter().signalError(methodDeclaration.returnType.sourceStart, methodDeclaration.returnType.sourceEnd, diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index 48123a750..d9889a7fd 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -954,7 +954,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC private static Annotation createAnnotationFromBcelAnnotation(AnnotationX annX, int pos, EclipseFactory factory) { String name = annX.getTypeName(); TypeBinding tb = factory.makeTypeBinding(annX.getSignature()); - String theName = annX.getSignature().getBaseName(); + // String theName = annX.getSignature().getBaseName(); char[][] typeName = CharOperation.splitOn('.', name.replace('$', '.').toCharArray()); // pr149293 - not bulletproof... long[] positions = new long[typeName.length]; for (int i = 0; i < positions.length; i++) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java index b9ca28911..2e8f9291a 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java @@ -245,7 +245,7 @@ public class EclipseFactory { UnresolvedType[] arguments = null; if (ptb.arguments != null) { // null can mean this is an inner type of a Parameterized Type with no bounds of its own - // (pr100227) + // (pr100227) arguments = new UnresolvedType[ptb.arguments.length]; for (int i = 0; i < arguments.length; i++) { arguments[i] = fromBinding(ptb.arguments[i]); @@ -758,8 +758,8 @@ public class EclipseFactory { public SyntheticFieldBinding createSyntheticFieldBinding(SourceTypeBinding owningType, ResolvedMember member) { SyntheticFieldBinding sfb = new SyntheticFieldBinding(member.getName().toCharArray(), makeTypeBinding(member .getReturnType()), member.getModifiers() | Flags.AccSynthetic, owningType, Constant.NotAConstant, -1); // index - // filled in - // later + // filled in + // later owningType.addSyntheticField(sfb); return sfb; } @@ -771,7 +771,6 @@ public class EclipseFactory { */ public FieldBinding internalMakeFieldBinding(ResolvedMember member, List aliases) { typeVariableToTypeBinding.clear(); - TypeVariableBinding[] tvbs = null; ReferenceBinding declaringType = (ReferenceBinding) makeTypeBinding(member.getDeclaringType()); @@ -972,7 +971,7 @@ public class EclipseFactory { tvBinding = new TypeVariableBinding(tv.getName().toCharArray(), declaringElement, tv.getRank()); typeVariableToTypeBinding.put(tv.getName(), tvBinding); tvBinding.superclass = (ReferenceBinding) makeTypeBinding(tv.getUpperBound()); - tvBinding.firstBound = (ReferenceBinding) makeTypeBinding(tv.getFirstBound()); + tvBinding.firstBound = makeTypeBinding(tv.getFirstBound()); if (tv.getAdditionalInterfaceBounds() == null) { tvBinding.superInterfaces = TypeVariableBinding.NO_SUPERINTERFACES; } else { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java index ae62d46a9..9ebb91e8a 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java @@ -147,7 +147,8 @@ public class EclipseResolvedMember extends ResolvedMemberImpl { public ResolvedType[] getAnnotationTypes() { if (cachedAnnotationTypes == null) { - long abits = realBinding.getAnnotationTagBits(); // ensure resolved + // long abits = + realBinding.getAnnotationTagBits(); // ensure resolved Annotation[] annos = getEclipseAnnotations(); if (annos == null) { cachedAnnotationTypes = ResolvedType.EMPTY_RESOLVED_TYPE_ARRAY; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java index 78770ad98..54a8b9919 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.ajdt.internal.compiler.lookup; import java.lang.reflect.Modifier; @@ -32,117 +31,118 @@ import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.ResolvedTypeMunger; import org.aspectj.weaver.World; - public class EclipseTypeMunger extends ConcreteTypeMunger { private ResolvedType targetTypeX; - //protected ReferenceBinding targetBinding = null; + // protected ReferenceBinding targetBinding = null; private AbstractMethodDeclaration sourceMethod; private EclipseFactory world; private ISourceLocation sourceLocation; - public EclipseTypeMunger(EclipseFactory world, ResolvedTypeMunger munger, ResolvedType aspectType, - AbstractMethodDeclaration sourceMethod) - { + AbstractMethodDeclaration sourceMethod) { super(munger, aspectType); this.world = world; this.sourceMethod = sourceMethod; if (sourceMethod != null) { - this.sourceLocation = - new EclipseSourceLocation(sourceMethod.compilationResult, - sourceMethod.sourceStart, sourceMethod.sourceEnd); + this.sourceLocation = new EclipseSourceLocation(sourceMethod.compilationResult, sourceMethod.sourceStart, + sourceMethod.sourceEnd); // Piece of magic that tells type mungers where they came from. // Won't be persisted unless ResolvedTypeMunger.persistSourceLocation is true. munger.setSourceLocation(sourceLocation); } targetTypeX = munger.getSignature().getDeclaringType().resolve(world.getWorld()); // AMC, needed until generic and raw have distinct sigs... - if (targetTypeX.isParameterizedType() || targetTypeX.isRawType()) targetTypeX = targetTypeX.getGenericType(); - //targetBinding = (ReferenceBinding)world.makeTypeBinding(targetTypeX); + if (targetTypeX.isParameterizedType() || targetTypeX.isRawType()) + targetTypeX = targetTypeX.getGenericType(); + // targetBinding = (ReferenceBinding)world.makeTypeBinding(targetTypeX); } - + public static boolean supportsKind(ResolvedTypeMunger.Kind kind) { - return kind == ResolvedTypeMunger.Field - || kind == ResolvedTypeMunger.Method - || kind == ResolvedTypeMunger.Constructor; + return kind == ResolvedTypeMunger.Field || kind == ResolvedTypeMunger.Method || kind == ResolvedTypeMunger.Constructor; } public String toString() { return "(EclipseTypeMunger " + getMunger() + ")"; } - + /** - * Modifies signatures of a TypeBinding through its ClassScope, - * i.e. adds Method|FieldBindings, plays with inheritance, ... + * Modifies signatures of a TypeBinding through its ClassScope, i.e. adds Method|FieldBindings, plays with inheritance, ... */ public boolean munge(SourceTypeBinding sourceType, ResolvedType onType) { ResolvedType rt = onType; - if (rt.isRawType() || rt.isParameterizedType()) rt = rt.getGenericType(); + if (rt.isRawType() || rt.isParameterizedType()) + rt = rt.getGenericType(); boolean isExactTargetType = rt.equals(targetTypeX); if (!isExactTargetType) { // might be the topmost implementor of an interface we care about - if (munger.getKind() != ResolvedTypeMunger.Method) return false; - if (onType.isInterface()) return false; - if (!munger.needsAccessToTopmostImplementor()) return false; + if (munger.getKind() != ResolvedTypeMunger.Method) + return false; + if (onType.isInterface()) + return false; + if (!munger.needsAccessToTopmostImplementor()) + return false; // so we do need access, and this type could be it... - if (!onType.isTopmostImplementor(targetTypeX)) return false; + if (!onType.isTopmostImplementor(targetTypeX)) + return false; // we are the topmost implementor of an interface type that needs munging - // but we only care about public methods here (we only do this at all to + // but we only care about public methods here (we only do this at all to // drive the JDT MethodVerifier correctly) - if (!Modifier.isPublic(munger.getSignature().getModifiers())) return false; + if (!Modifier.isPublic(munger.getSignature().getModifiers())) + return false; } - //System.out.println("munging: " + sourceType); -// System.out.println("match: " + world.fromEclipse(sourceType) + -// " with " + targetTypeX); + // System.out.println("munging: " + sourceType); + // System.out.println("match: " + world.fromEclipse(sourceType) + + // " with " + targetTypeX); if (munger.getKind() == ResolvedTypeMunger.Field) { - mungeNewField(sourceType, (NewFieldTypeMunger)munger); + mungeNewField(sourceType, (NewFieldTypeMunger) munger); } else if (munger.getKind() == ResolvedTypeMunger.Method) { - return mungeNewMethod(sourceType, onType, (NewMethodTypeMunger)munger, isExactTargetType); + return mungeNewMethod(sourceType, onType, (NewMethodTypeMunger) munger, isExactTargetType); } else if (munger.getKind() == ResolvedTypeMunger.Constructor) { - mungeNewConstructor(sourceType, (NewConstructorTypeMunger)munger); + mungeNewConstructor(sourceType, (NewConstructorTypeMunger) munger); } else { throw new RuntimeException("unimplemented: " + munger.getKind()); } return true; } - - private boolean mungeNewMethod(SourceTypeBinding sourceType, ResolvedType onType, NewMethodTypeMunger munger, boolean isExactTargetType) { - InterTypeMethodBinding binding = - new InterTypeMethodBinding(world, munger, aspectType, sourceMethod); + private boolean mungeNewMethod(SourceTypeBinding sourceType, ResolvedType onType, NewMethodTypeMunger munger, + boolean isExactTargetType) { + InterTypeMethodBinding binding = new InterTypeMethodBinding(world, munger, aspectType, sourceMethod); if (!isExactTargetType) { // we're munging an interface ITD onto a topmost implementor - ResolvedMember existingMember = onType.lookupMemberIncludingITDsOnInterfaces(getSignature()); + ResolvedMember existingMember = onType.lookupMemberIncludingITDsOnInterfaces(getSignature()); if (existingMember != null) { // already have an implementation, so don't do anything if (onType == existingMember.getDeclaringType() && Modifier.isFinal(munger.getSignature().getModifiers())) { // final modifier on default implementation is taken to mean that // no-one else can provide an implementation - MethodBinding offendingBinding = sourceType.getExactMethod(binding.selector, binding.parameters, sourceType.scope.compilationUnitScope()); + MethodBinding offendingBinding = sourceType.getExactMethod(binding.selector, binding.parameters, + sourceType.scope.compilationUnitScope()); sourceType.scope.problemReporter().finalMethodCannotBeOverridden(offendingBinding, binding); } // so that we find methods from our superinterfaces later on... findOrCreateInterTypeMemberFinder(sourceType); return false; - } + } } - + // retain *only* the visibility modifiers and abstract when putting methods on an interface... if (sourceType.isInterface()) { boolean isAbstract = (binding.modifiers & ClassFileConstants.AccAbstract) != 0; binding.modifiers = (binding.modifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate)); - if (isAbstract) binding.modifiers |= ClassFileConstants.AccAbstract; + if (isAbstract) + binding.modifiers |= ClassFileConstants.AccAbstract; } - if (munger.getSignature().isVarargsMethod()) binding.modifiers |= ClassFileConstants.AccVarargs; + if (munger.getSignature().isVarargsMethod()) + binding.modifiers |= ClassFileConstants.AccVarargs; findOrCreateInterTypeMemberFinder(sourceType).addInterTypeMethod(binding); return true; } - - - private void mungeNewConstructor(SourceTypeBinding sourceType, NewConstructorTypeMunger munger) { + + private void mungeNewConstructor(SourceTypeBinding sourceType, NewConstructorTypeMunger munger) { if (shouldTreatAsPublic()) { - MethodBinding binding = world.makeMethodBinding(munger.getSignature(),munger.getTypeVariableAliases()); + MethodBinding binding = world.makeMethodBinding(munger.getSignature(), munger.getTypeVariableAliases()); findOrCreateInterTypeMemberFinder(sourceType).addInterTypeMethod(binding); TypeVariableBinding[] typeVariables = binding.typeVariables; for (int i = 0; i < typeVariables.length; i++) { @@ -150,48 +150,43 @@ public class EclipseTypeMunger extends ConcreteTypeMunger { String name = new String(tv.sourceName); TypeVariableBinding[] tv2 = sourceMethod.binding.typeVariables; for (int j = 0; j < tv2.length; j++) { - TypeVariableBinding typeVariable = tv2[j]; - if (new String(tv2[j].sourceName).equals(name)) typeVariables[i].declaringElement = binding; + if (new String(tv2[j].sourceName).equals(name)) + typeVariables[i].declaringElement = binding; } } for (int i = 0; i < typeVariables.length; i++) { - if (typeVariables[i].declaringElement==null) throw new RuntimeException("Declaring element not set"); - + if (typeVariables[i].declaringElement == null) + throw new RuntimeException("Declaring element not set"); + } - //classScope.referenceContext.binding.addMethod(binding); + // classScope.referenceContext.binding.addMethod(binding); } else { - InterTypeMethodBinding binding = - new InterTypeMethodBinding(world, munger, aspectType, sourceMethod); + InterTypeMethodBinding binding = new InterTypeMethodBinding(world, munger, aspectType, sourceMethod); findOrCreateInterTypeMemberFinder(sourceType).addInterTypeMethod(binding); } } - - private void mungeNewField(SourceTypeBinding sourceType, NewFieldTypeMunger munger) { + private void mungeNewField(SourceTypeBinding sourceType, NewFieldTypeMunger munger) { if (shouldTreatAsPublic() && !targetTypeX.isInterface()) { FieldBinding binding = world.makeFieldBinding(munger); findOrCreateInterTypeMemberFinder(sourceType).addInterTypeField(binding); - //classScope.referenceContext.binding.addField(binding); + // classScope.referenceContext.binding.addField(binding); } else { - InterTypeFieldBinding binding = - new InterTypeFieldBinding(world, munger, aspectType, sourceMethod); + InterTypeFieldBinding binding = new InterTypeFieldBinding(world, munger, aspectType, sourceMethod); findOrCreateInterTypeMemberFinder(sourceType).addInterTypeField(binding); } } - - + private boolean shouldTreatAsPublic() { - //??? this is where we could fairly easily choose to treat package-protected - //??? introductions like public ones when the target type and the aspect - //??? are in the same package + // ??? this is where we could fairly easily choose to treat package-protected + // ??? introductions like public ones when the target type and the aspect + // ??? are in the same package return Modifier.isPublic(munger.getSignature().getModifiers()); } - - + private InterTypeMemberFinder findOrCreateInterTypeMemberFinder(SourceTypeBinding sourceType) { - InterTypeMemberFinder finder = - (InterTypeMemberFinder)sourceType.memberFinder; + InterTypeMemberFinder finder = (InterTypeMemberFinder) sourceType.memberFinder; if (finder == null) { finder = new InterTypeMemberFinder(); sourceType.memberFinder = finder; @@ -199,7 +194,7 @@ public class EclipseTypeMunger extends ConcreteTypeMunger { } return finder; } - + public ISourceLocation getSourceLocation() { return sourceLocation; } @@ -214,13 +209,13 @@ public class EclipseTypeMunger extends ConcreteTypeMunger { public AbstractMethodDeclaration getSourceMethod() { return sourceMethod; } - + public ConcreteTypeMunger parameterizedFor(ResolvedType target) { - return new EclipseTypeMunger(world,munger.parameterizedFor(target),aspectType,sourceMethod); + return new EclipseTypeMunger(world, munger.parameterizedFor(target), aspectType, sourceMethod); } - public ConcreteTypeMunger parameterizeWith(Map m,World w) { - return new EclipseTypeMunger(world,munger.parameterizeWith(m,w),aspectType,sourceMethod); + public ConcreteTypeMunger parameterizeWith(Map m, World w) { + return new EclipseTypeMunger(world, munger.parameterizeWith(m, w), aspectType, sourceMethod); } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java index fe5901c98..9b0f93144 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -886,40 +886,40 @@ public class AjState { } } - private void deleteResources() { - List oldResources = new ArrayList(); - oldResources.addAll(resources); - - // note - this deliberately ignores resources in jars as we don't yet handle jar changes - // with incremental compilation - for (Iterator i = buildConfig.getInpath().iterator(); i.hasNext();) { - File inPathElement = (File) i.next(); - if (inPathElement.isDirectory() && AjBuildManager.COPY_INPATH_DIR_RESOURCES) { - deleteResourcesFromDirectory(inPathElement, oldResources); - } - } - - if (buildConfig.getSourcePathResources() != null) { - for (Iterator i = buildConfig.getSourcePathResources().keySet().iterator(); i.hasNext();) { - String resource = (String) i.next(); - maybeDeleteResource(resource, oldResources); - } - } - - // oldResources need to be deleted... - for (Iterator iter = oldResources.iterator(); iter.hasNext();) { - String victim = (String) iter.next(); - List outputDirs = getOutputLocations(buildConfig); - for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) { - File dir = (File) iterator.next(); - File f = new File(dir, victim); - if (f.exists()) { - f.delete(); - } - resources.remove(victim); - } - } - } + // private void deleteResources() { + // List oldResources = new ArrayList(); + // oldResources.addAll(resources); + // + // // note - this deliberately ignores resources in jars as we don't yet handle jar changes + // // with incremental compilation + // for (Iterator i = buildConfig.getInpath().iterator(); i.hasNext();) { + // File inPathElement = (File) i.next(); + // if (inPathElement.isDirectory() && AjBuildManager.COPY_INPATH_DIR_RESOURCES) { + // deleteResourcesFromDirectory(inPathElement, oldResources); + // } + // } + // + // if (buildConfig.getSourcePathResources() != null) { + // for (Iterator i = buildConfig.getSourcePathResources().keySet().iterator(); i.hasNext();) { + // String resource = (String) i.next(); + // maybeDeleteResource(resource, oldResources); + // } + // } + // + // // oldResources need to be deleted... + // for (Iterator iter = oldResources.iterator(); iter.hasNext();) { + // String victim = (String) iter.next(); + // List outputDirs = getOutputLocations(buildConfig); + // for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) { + // File dir = (File) iterator.next(); + // File f = new File(dir, victim); + // if (f.exists()) { + // f.delete(); + // } + // resources.remove(victim); + // } + // } + // } private void maybeDeleteResource(String resName, List oldResources) { if (resources.contains(resName)) { @@ -935,32 +935,32 @@ public class AjState { } } - private void deleteResourcesFromDirectory(File dir, List oldResources) { - File[] files = FileUtil.listFiles(dir, new FileFilter() { - public boolean accept(File f) { - boolean accept = !(f.isDirectory() || f.getName().endsWith(".class")); - return accept; - } - }); - - // For each file, add it either as a real .class file or as a resource - for (int i = 0; i < files.length; i++) { - // ASSERT: files[i].getAbsolutePath().startsWith(inFile.getAbsolutePath() - // or we are in trouble... - String filename = null; - try { - filename = files[i].getCanonicalPath().substring(dir.getCanonicalPath().length() + 1); - } catch (IOException e) { - // we are in trouble if this happens... - IMessage msg = new Message("call to getCanonicalPath() failed for file " + files[i] + " with: " + e.getMessage(), - new SourceLocation(files[i], 0), false); - buildManager.handler.handleMessage(msg); - filename = files[i].getAbsolutePath().substring(dir.getAbsolutePath().length() + 1); - } - - maybeDeleteResource(filename, oldResources); - } - } + // private void deleteResourcesFromDirectory(File dir, List oldResources) { + // File[] files = FileUtil.listFiles(dir, new FileFilter() { + // public boolean accept(File f) { + // boolean accept = !(f.isDirectory() || f.getName().endsWith(".class")); + // return accept; + // } + // }); + // + // // For each file, add it either as a real .class file or as a resource + // for (int i = 0; i < files.length; i++) { + // // ASSERT: files[i].getAbsolutePath().startsWith(inFile.getAbsolutePath() + // // or we are in trouble... + // String filename = null; + // try { + // filename = files[i].getCanonicalPath().substring(dir.getCanonicalPath().length() + 1); + // } catch (IOException e) { + // // we are in trouble if this happens... + // IMessage msg = new Message("call to getCanonicalPath() failed for file " + files[i] + " with: " + e.getMessage(), + // new SourceLocation(files[i], 0), false); + // buildManager.handler.handleMessage(msg); + // filename = files[i].getAbsolutePath().substring(dir.getAbsolutePath().length() + 1); + // } + // + // maybeDeleteResource(filename, oldResources); + // } + // } private void deleteClassFile(ClassFile cf) { classesFromName.remove(cf.fullyQualifiedTypeName); @@ -1356,14 +1356,14 @@ public class AjState { return (eclipseModifiers == resolvedTypeModifiers); } - private static StringSet makeStringSet(List strings) { - StringSet ret = new StringSet(strings.size()); - for (Iterator iter = strings.iterator(); iter.hasNext();) { - String element = (String) iter.next(); - ret.add(element); - } - return ret; - } + // private static StringSet makeStringSet(List strings) { + // StringSet ret = new StringSet(strings.size()); + // for (Iterator iter = strings.iterator(); iter.hasNext();) { + // String element = (String) iter.next(); + // ret.add(element); + // } + // return ret; + // } private String stringifyList(Set l) { StringBuffer sb = new StringBuffer(); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java index e4fd440fb..c970971a6 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java @@ -72,7 +72,7 @@ public class AsmElementFormatter { setParameters(methodDeclaration, node); } else if (methodDeclaration instanceof PointcutDeclaration) { - PointcutDeclaration pd = (PointcutDeclaration) methodDeclaration; + // PointcutDeclaration pd = (PointcutDeclaration) methodDeclaration; node.setKind(IProgramElement.Kind.POINTCUT); node.setName(translatePointcutName(new String(methodDeclaration.selector))); setParameters(methodDeclaration, node); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java index 737d696cf..8e3e13587 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java @@ -55,30 +55,28 @@ import org.eclipse.core.runtime.Path; /** * @author colyer - * - * This is the builder class used by AJDT, and that the org.eclipse.ajdt.core - * plugin references. + * + * This is the builder class used by AJDT, and that the org.eclipse.ajdt.core plugin references. */ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFactory { - - - // One builder instance per project (important) + + // One builder instance per project (important) private BcelWeaver myWeaver = null; private BcelWorld myBcelWorld = null; private EclipseClassPathManager cpManager = null; private UnwovenResultCollector unwovenResultCollector = null; private OutputFileNameProvider fileNameProvider = null; - + private boolean isBatchBuild = false; - - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) */ - protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) - throws CoreException { + protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) throws CoreException { // super method always causes construction of a new XXXImageBuilder, which - // causes construction of a new Compiler, so we will be detected as the + // causes construction of a new Compiler, so we will be detected as the // adapter. CompilerAdapter.setCompilerAdapterFactory(this); return super.build(kind, ignored, monitor); @@ -88,13 +86,15 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto isBatchBuild = true; return new AjBatchImageBuilder(this); } - + protected IncrementalImageBuilder getIncrementalImageBuilder() { isBatchBuild = false; return new AjIncrementalImageBuilder(this); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.eclipse.jdt.internal.compiler.ICompilerAdapterFactory#getAdapter(org.eclipse.jdt.internal.compiler.Compiler) */ public ICompilerAdapter getAdapter(Compiler forCompiler) { @@ -102,29 +102,28 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto // TODO get aspectj options from project and add into map before... AjCompilerOptions ajOptions = new AjCompilerOptions(javaOptions); forCompiler.options = ajOptions; - + if (isBatchBuild || myBcelWorld == null || myWeaver == null) { initWorldAndWeaver(ajOptions); } else { // update the nameEnvironment each time we compile... cpManager.setNameEnvironment(nameEnvironment); } - - // * an eclipse factory -- create from AjLookupEnvironment, need to hide AjBuildManager field - AjProblemReporter pr = - new AjProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), - forCompiler.options, new DefaultProblemFactory(Locale.getDefault())); - forCompiler.problemReporter = pr; - AjLookupEnvironment le = - new AjLookupEnvironment(forCompiler, forCompiler.options, pr,nameEnvironment); - EclipseFactory eFactory = new EclipseFactory(le,myBcelWorld,ajOptions.xSerializableAspects); + + // * an eclipse factory -- create from AjLookupEnvironment, need to hide AjBuildManager field + AjProblemReporter pr = new AjProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), forCompiler.options, + new DefaultProblemFactory(Locale.getDefault())); + forCompiler.problemReporter = pr; + AjLookupEnvironment le = new AjLookupEnvironment(forCompiler, forCompiler.options, pr, nameEnvironment); + EclipseFactory eFactory = new EclipseFactory(le, myBcelWorld, ajOptions.xSerializableAspects); le.factory = eFactory; forCompiler.lookupEnvironment = le; - + AjBuildNotifier ajNotifier = (AjBuildNotifier) notifier; - if (fileNameProvider == null ) fileNameProvider = new OutputFileNameProvider(getProject()); - - // * the set of binary source entries for this compile -- from analyzing deltas, or everything if batch + if (fileNameProvider == null) + fileNameProvider = new OutputFileNameProvider(getProject()); + + // * the set of binary source entries for this compile -- from analyzing deltas, or everything if batch // * the full set of binary source entries for the project -- from IAspectJProject // TODO deal with inpath, injars here... IBinarySourceProvider bsProvider = new NullBinarySourceProvider(); @@ -135,89 +134,95 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto unwovenResultCollector = new UnwovenResultCollector(); } Collection resultSetForFullWeave = unwovenResultCollector.getIntermediateResults(); - + throw new UnsupportedOperationException("Is anyone actually using the AspectJBuilder class??"); -// return new AjCompilerAdapter(forCompiler,isBatchBuild,myBcelWorld, -// myWeaver,eFactory,unwovenResultCollector,ajNotifier,fileNameProvider,bsProvider, -// fullBinarySourceEntries,resultSetForFullWeave, -// ajOptions.noWeave,ajOptions.proceedOnError,ajOptions.noAtAspectJProcessing); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.internal.core.builder.JavaBuilder#createBuildNotifier(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.resources.IProject) + // return new AjCompilerAdapter(forCompiler,isBatchBuild,myBcelWorld, + // myWeaver,eFactory,unwovenResultCollector,ajNotifier,fileNameProvider,bsProvider, + // fullBinarySourceEntries,resultSetForFullWeave, + // ajOptions.noWeave,ajOptions.proceedOnError,ajOptions.noAtAspectJProcessing); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jdt.internal.core.builder.JavaBuilder#createBuildNotifier(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.resources.IProject) */ - protected BuildNotifier createBuildNotifier(IProgressMonitor monitor, - IProject currentProject) { + protected BuildNotifier createBuildNotifier(IProgressMonitor monitor, IProject currentProject) { return new AjBuildNotifier(monitor, currentProject); } - private void initWorldAndWeaver(AjCompilerOptions options) { cpManager = new EclipseClassPathManager(nameEnvironment); - myBcelWorld = new BcelWorld(cpManager,new UnhandledMessageHandler(getProject()),null /*(xrefHandler)*/); + myBcelWorld = new BcelWorld(cpManager, new UnhandledMessageHandler(getProject()), null /* (xrefHandler) */); myBcelWorld.setBehaveInJava5Way(options.behaveInJava5Way); myBcelWorld.setTargetAspectjRuntimeLevel(options.targetAspectjRuntimeLevel); myBcelWorld.setXnoInline(options.xNoInline); myBcelWorld.setXlazyTjp(options.xLazyThisJoinPoint); myBcelWorld.setXHasMemberSupportEnabled(options.xHasMember); myBcelWorld.setPinpointMode(options.xdevPinpoint); - setLintProperties(myBcelWorld,options); + setLintProperties(myBcelWorld, options); myWeaver = new BcelWeaver(myBcelWorld); myWeaver.setReweavableMode(options.xNotReweavable); // TODO deal with injars, inpath, and aspectpath here... } - + private void setLintProperties(BcelWorld world, AjCompilerOptions options) { Properties p = new Properties(); Lint lintSettings = world.getLint(); Map map = options.getMap(); - p.put(lintSettings.invalidAbsoluteTypeName.getName(),map.get(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName)); - p.put(lintSettings.invalidWildcardTypeName.getName(),map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName)); - p.put(lintSettings.unresolvableMember.getName(),map.get(AjCompilerOptions.OPTION_ReportUnresolvableMember)); - p.put(lintSettings.typeNotExposedToWeaver.getName(),map.get(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver)); - p.put(lintSettings.shadowNotInStructure.getName(),map.get(AjCompilerOptions.OPTION_ReportShadowNotInStructure)); - p.put(lintSettings.unmatchedSuperTypeInCall.getName(),map.get(AjCompilerOptions.OPTION_ReportUnmatchedSuperTypeInCall)); - p.put(lintSettings.canNotImplementLazyTjp.getName(),map.get(AjCompilerOptions.OPTION_ReportCannotImplementLazyTJP)); - p.put(lintSettings.needsSerialVersionUIDField.getName(),map.get(AjCompilerOptions.OPTION_ReportNeedSerialVersionUIDField)); - p.put(lintSettings.serialVersionUIDBroken.getName(),map.get(AjCompilerOptions.OPTION_ReportIncompatibleSerialVersion)); + p.put(lintSettings.invalidAbsoluteTypeName.getName(), map.get(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName)); + p.put(lintSettings.invalidWildcardTypeName.getName(), map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName)); + p.put(lintSettings.unresolvableMember.getName(), map.get(AjCompilerOptions.OPTION_ReportUnresolvableMember)); + p.put(lintSettings.typeNotExposedToWeaver.getName(), map.get(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver)); + p.put(lintSettings.shadowNotInStructure.getName(), map.get(AjCompilerOptions.OPTION_ReportShadowNotInStructure)); + p.put(lintSettings.unmatchedSuperTypeInCall.getName(), map.get(AjCompilerOptions.OPTION_ReportUnmatchedSuperTypeInCall)); + p.put(lintSettings.canNotImplementLazyTjp.getName(), map.get(AjCompilerOptions.OPTION_ReportCannotImplementLazyTJP)); + p.put(lintSettings.needsSerialVersionUIDField.getName(), map.get(AjCompilerOptions.OPTION_ReportNeedSerialVersionUIDField)); + p.put(lintSettings.serialVersionUIDBroken.getName(), map.get(AjCompilerOptions.OPTION_ReportIncompatibleSerialVersion)); lintSettings.setFromProperties(p); } - + private static class UnwovenResultCollector implements IIntermediateResultsRequestor { private Collection results = new ArrayList(); - - /* (non-Javadoc) - * @see org.aspectj.ajdt.internal.compiler.IIntermediateResultsRequestor#acceptResult(org.aspectj.ajdt.internal.compiler.InterimCompilationResult) + + /* + * (non-Javadoc) + * + * @seeorg.aspectj.ajdt.internal.compiler.IIntermediateResultsRequestor#acceptResult(org.aspectj.ajdt.internal.compiler. + * InterimCompilationResult) */ public void acceptResult(InterimCompilationResult intRes) { results.add(intRes); } - + public Collection getIntermediateResults() { return results; } - + } - + // this class will only get messages that the weaver adapter couldn't tie into // an originating resource in the project - make them messages on the project // itself. private static class UnhandledMessageHandler implements IMessageHandler { - + private IProject project; - + public UnhandledMessageHandler(IProject p) { this.project = p; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.bridge.IMessageHandler#handleMessage(org.aspectj.bridge.IMessage) */ public boolean handleMessage(IMessage message) throws AbortException { try { IMarker marker = project.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); - marker.setAttribute(IMarker.MESSAGE, message.getMessage()); + marker.setAttribute(IMarker.MESSAGE, message.getMessage()); marker.setAttribute(IMarker.SEVERITY, message.isError() ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING); } catch (CoreException e) { AspectJCore.getPlugin().getLog().log(e.getStatus()); @@ -225,43 +230,50 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind) */ public boolean isIgnoring(Kind kind) { - if (kind == IMessage.DEBUG || kind == IMessage.INFO) return true; + if (kind == IMessage.DEBUG || kind == IMessage.INFO) + return true; return false; } - - /** - * No-op - * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind) - * @param kind - */ - public void dontIgnore(IMessage.Kind kind) { - ; - } + + /** + * No-op + * + * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind) + * @param kind + */ + public void dontIgnore(IMessage.Kind kind) { + + } public void ignore(Kind kind) { } - + } - + private static class OutputFileNameProvider implements IOutputClassFileNameProvider { private IPath outputLocation; - + public OutputFileNameProvider(IProject p) { try { outputLocation = JavaCore.create(p).getOutputLocation(); } catch (JavaModelException e) { outputLocation = new Path("."); - AspectJCore.getPlugin().getLog().log(e.getStatus()); + AspectJCore.getPlugin().getLog().log(e.getStatus()); } } - - /* (non-Javadoc) - * @see org.aspectj.ajdt.internal.compiler.IOutputClassFileNameProvider#getOutputClassFileName(char[], org.eclipse.jdt.internal.compiler.CompilationResult) + + /* + * (non-Javadoc) + * + * @see org.aspectj.ajdt.internal.compiler.IOutputClassFileNameProvider#getOutputClassFileName(char[], + * org.eclipse.jdt.internal.compiler.CompilationResult) */ public String getOutputClassFileName(char[] eclipseClassFileName, CompilationResult result) { // In the AJDT implementation, the name provided here will be ignored, we write the results @@ -272,18 +284,20 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto out.addFileExtension(".class"); return out.toOSString(); } - + } // default impl class until the implementation is extended to cope with inpath, injars private static class NullBinarySourceProvider implements IBinarySourceProvider { - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.ajdt.internal.compiler.IBinarySourceProvider#getBinarySourcesForThisWeave() */ public Map getBinarySourcesForThisWeave() { return new HashMap(); } - + } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java index 62cfaa7f4..d84e2d557 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java @@ -26,194 +26,175 @@ import org.aspectj.weaver.World; public class EclipseAdapterUtils { - //XXX some cut-and-paste from eclipse sources - public static String makeLocationContext(ICompilationUnit compilationUnit, IProblem problem) { - //extra from the source the innacurate token - //and "highlight" it using some underneath ^^^^^ - //put some context around too. - - //this code assumes that the font used in the console is fixed size - - //sanity ..... - int startPosition = problem.getSourceStart(); - int endPosition = problem.getSourceEnd(); - - if ((startPosition > endPosition) - || ((startPosition <= 0) && (endPosition <= 0)) - || compilationUnit==null) - //return Util.bind("problem.noSourceInformation"); //$NON-NLS-1$ - return "(no source information available)"; - - final char SPACE = '\u0020'; - final char MARK = '^'; - final char TAB = '\t'; - char[] source = compilationUnit.getContents(); - //the next code tries to underline the token..... - //it assumes (for a good display) that token source does not - //contain any \r \n. This is false on statements ! - //(the code still works but the display is not optimal !) - - //compute the how-much-char we are displaying around the inaccurate token - int begin = startPosition >= source.length ? source.length - 1 : startPosition; - if (begin==-1) - return "(no source information available)"; // Dont like this - why does it occur? pr152835 - int relativeStart = 0; - int end = endPosition >= source.length ? source.length - 1 : endPosition; - int relativeEnd = 0; - label : for (relativeStart = 0;; relativeStart++) { - if (begin == 0) - break label; - if ((source[begin - 1] == '\n') || (source[begin - 1] == '\r')) - break label; - begin--; - } - label : for (relativeEnd = 0;; relativeEnd++) { - if ((end + 1) >= source.length) - break label; - if ((source[end + 1] == '\r') || (source[end + 1] == '\n')) { - break label; - } - end++; - } - //extract the message form the source - char[] extract = new char[end - begin + 1]; - System.arraycopy(source, begin, extract, 0, extract.length); - char c; - //remove all SPACE and TAB that begin the error message... - int trimLeftIndex = 0; - while ( (((c = extract[trimLeftIndex++]) == TAB) || (c == SPACE)) && trimLeftIndex<extract.length ) { }; - if (trimLeftIndex>=extract.length) return new String(extract)+"\n"; - System.arraycopy( - extract, - trimLeftIndex - 1, - extract = new char[extract.length - trimLeftIndex + 1], - 0, - extract.length); - relativeStart -= trimLeftIndex; - //buffer spaces and tabs in order to reach the error position - int pos = 0; - char[] underneath = new char[extract.length]; // can't be bigger - for (int i = 0; i <= relativeStart; i++) { - if (extract[i] == TAB) { - underneath[pos++] = TAB; - } else { - underneath[pos++] = SPACE; - } - } - //mark the error position - for (int i = startPosition + trimLeftIndex; // AMC if we took stuff off the start, take it into account! - i <= (endPosition >= source.length ? source.length - 1 : endPosition); - i++) - underneath[pos++] = MARK; - //resize underneathto remove 'null' chars - System.arraycopy(underneath, 0, underneath = new char[pos], 0, pos); - - return new String(extract) + "\n" + new String(underneath); //$NON-NLS-2$ //$NON-NLS-1$ - } - - /** - * Extract source location file, start and end lines, and context. - * Column is not extracted correctly. - * @return ISourceLocation with correct file and lines but not column. - */ - public static ISourceLocation makeSourceLocation(ICompilationUnit unit, IProblem problem) { - int line = problem.getSourceLineNumber(); - File file = new File(new String(problem.getOriginatingFileName())); - String context = makeLocationContext(unit, problem); - // XXX 0 column is wrong but recoverable from makeLocationContext - return new SourceLocation(file, line, line, 0, context); - } - - /** - * Extract message text and source location, including context. - * @param world - */ - public static IMessage makeMessage(ICompilationUnit unit, IProblem problem, World world) { - ISourceLocation sourceLocation = makeSourceLocation(unit, problem); - IProblem[] seeAlso = problem.seeAlso(); - // If the user has turned off classfile line number gen, then we may not be able to tell them - // about all secondary locations (pr209372) - int validPlaces = 0; - for (int ii=0;ii<seeAlso.length;ii++) { - if (seeAlso[ii].getSourceLineNumber()>=0) validPlaces++; - } - ISourceLocation[] seeAlsoLocations = new ISourceLocation[validPlaces]; - int pos = 0; - for (int i = 0; i < seeAlso.length; i++) { - if (seeAlso[i].getSourceLineNumber()>=0) { - seeAlsoLocations[pos++] = new SourceLocation(new File(new String(seeAlso[i].getOriginatingFileName())), - seeAlso[i].getSourceLineNumber()); - } + // XXX some cut-and-paste from eclipse sources + public static String makeLocationContext(ICompilationUnit compilationUnit, IProblem problem) { + // extra from the source the innacurate token + // and "highlight" it using some underneath ^^^^^ + // put some context around too. + + // this code assumes that the font used in the console is fixed size + + // sanity ..... + int startPosition = problem.getSourceStart(); + int endPosition = problem.getSourceEnd(); + + if ((startPosition > endPosition) || ((startPosition <= 0) && (endPosition <= 0)) || compilationUnit == null) + //return Util.bind("problem.noSourceInformation"); //$NON-NLS-1$ + return "(no source information available)"; + + final char SPACE = '\u0020'; + final char MARK = '^'; + final char TAB = '\t'; + char[] source = compilationUnit.getContents(); + // the next code tries to underline the token..... + // it assumes (for a good display) that token source does not + // contain any \r \n. This is false on statements ! + // (the code still works but the display is not optimal !) + + // compute the how-much-char we are displaying around the inaccurate token + int begin = startPosition >= source.length ? source.length - 1 : startPosition; + if (begin == -1) + return "(no source information available)"; // Dont like this - why does it occur? pr152835 + int relativeStart = 0; + int end = endPosition >= source.length ? source.length - 1 : endPosition; + int relativeEnd = 0; + label: for (relativeStart = 0;; relativeStart++) { + if (begin == 0) + break label; + if ((source[begin - 1] == '\n') || (source[begin - 1] == '\r')) + break label; + begin--; + } + label: for (relativeEnd = 0;; relativeEnd++) { + if ((end + 1) >= source.length) + break label; + if ((source[end + 1] == '\r') || (source[end + 1] == '\n')) { + break label; + } + end++; + } + // extract the message form the source + char[] extract = new char[end - begin + 1]; + System.arraycopy(source, begin, extract, 0, extract.length); + char c; + // remove all SPACE and TAB that begin the error message... + int trimLeftIndex = 0; + while ((((c = extract[trimLeftIndex++]) == TAB) || (c == SPACE)) && trimLeftIndex < extract.length) { + } + if (trimLeftIndex >= extract.length) + return new String(extract) + "\n"; + System.arraycopy(extract, trimLeftIndex - 1, extract = new char[extract.length - trimLeftIndex + 1], 0, extract.length); + relativeStart -= trimLeftIndex; + // buffer spaces and tabs in order to reach the error position + int pos = 0; + char[] underneath = new char[extract.length]; // can't be bigger + for (int i = 0; i <= relativeStart; i++) { + if (extract[i] == TAB) { + underneath[pos++] = TAB; + } else { + underneath[pos++] = SPACE; + } + } + // mark the error position + for (int i = startPosition + trimLeftIndex; // AMC if we took stuff off the start, take it into account! + i <= (endPosition >= source.length ? source.length - 1 : endPosition); i++) + underneath[pos++] = MARK; + // resize underneathto remove 'null' chars + System.arraycopy(underneath, 0, underneath = new char[pos], 0, pos); + + return new String(extract) + "\n" + new String(underneath); //$NON-NLS-2$ //$NON-NLS-1$ + } + + /** + * Extract source location file, start and end lines, and context. Column is not extracted correctly. + * + * @return ISourceLocation with correct file and lines but not column. + */ + public static ISourceLocation makeSourceLocation(ICompilationUnit unit, IProblem problem) { + int line = problem.getSourceLineNumber(); + File file = new File(new String(problem.getOriginatingFileName())); + String context = makeLocationContext(unit, problem); + // XXX 0 column is wrong but recoverable from makeLocationContext + return new SourceLocation(file, line, line, 0, context); + } + + /** + * Extract message text and source location, including context. + * + * @param world + */ + public static IMessage makeMessage(ICompilationUnit unit, IProblem problem, World world) { + ISourceLocation sourceLocation = makeSourceLocation(unit, problem); + IProblem[] seeAlso = problem.seeAlso(); + // If the user has turned off classfile line number gen, then we may not be able to tell them + // about all secondary locations (pr209372) + int validPlaces = 0; + for (int ii = 0; ii < seeAlso.length; ii++) { + if (seeAlso[ii].getSourceLineNumber() >= 0) + validPlaces++; + } + ISourceLocation[] seeAlsoLocations = new ISourceLocation[validPlaces]; + int pos = 0; + for (int i = 0; i < seeAlso.length; i++) { + if (seeAlso[i].getSourceLineNumber() >= 0) { + seeAlsoLocations[pos++] = new SourceLocation(new File(new String(seeAlso[i].getOriginatingFileName())), seeAlso[i] + .getSourceLineNumber()); + } } // We transform messages from AJ types to eclipse IProblems - // and back to AJ types. During their time as eclipse problems, + // and back to AJ types. During their time as eclipse problems, // we remember whether the message originated from a declare // in the extraDetails. String extraDetails = problem.getSupplementaryMessageInfo(); boolean declared = false; boolean isLintMessage = false; String lintkey = null; - if (extraDetails!=null && extraDetails.endsWith("[deow=true]")) { + if (extraDetails != null && extraDetails.endsWith("[deow=true]")) { declared = true; - extraDetails = extraDetails.substring(0,extraDetails.length()-"[deow=true]".length()); + extraDetails = extraDetails.substring(0, extraDetails.length() - "[deow=true]".length()); } - if (extraDetails!=null && extraDetails.indexOf("[Xlint:")!=-1) { + if (extraDetails != null && extraDetails.indexOf("[Xlint:") != -1) { isLintMessage = true; lintkey = extraDetails.substring(extraDetails.indexOf("[Xlint:")); lintkey = lintkey.substring("[Xlint:".length()); - lintkey = lintkey.substring(0,lintkey.indexOf("]")); + lintkey = lintkey.substring(0, lintkey.indexOf("]")); } - + // If the 'problem' represents a TO DO kind of thing then use the message kind that // represents this so AJDT sees it correctly. IMessage.Kind kind; - if (problem.getID()==IProblem.Task) { - kind=IMessage.TASKTAG; + if (problem.getID() == IProblem.Task) { + kind = IMessage.TASKTAG; } else { - if (problem.isError()) { kind = IMessage.ERROR; } - else { kind = IMessage.WARNING; } + if (problem.isError()) { + kind = IMessage.ERROR; + } else { + kind = IMessage.WARNING; + } } IMessage msg = null; if (isLintMessage) { - msg = new LintMessage( - problem.getMessage(), - extraDetails, - world.getLint().fromKey(lintkey), - kind, - sourceLocation, - null, - seeAlsoLocations, - declared, - problem.getID(), - problem.getSourceStart(),problem.getSourceEnd()); + msg = new LintMessage(problem.getMessage(), extraDetails, world.getLint().fromKey(lintkey), kind, sourceLocation, null, + seeAlsoLocations, declared, problem.getID(), problem.getSourceStart(), problem.getSourceEnd()); } else { - msg = new Message(problem.getMessage(), - extraDetails, - kind, - sourceLocation, - null, - seeAlsoLocations, - declared, - problem.getID(), - problem.getSourceStart(),problem.getSourceEnd()); + msg = new Message(problem.getMessage(), extraDetails, kind, sourceLocation, null, seeAlsoLocations, declared, problem + .getID(), problem.getSourceStart(), problem.getSourceEnd()); } return msg; - } + } - public static IMessage makeErrorMessage(ICompilationUnit unit, String text, Exception ex) { - ISourceLocation loc = new SourceLocation(new File(new String(unit.getFileName())), - 0,0,0,""); - IMessage msg = new Message(text,IMessage.ERROR,ex,loc); - return msg; - } + public static IMessage makeErrorMessage(ICompilationUnit unit, String text, Exception ex) { + ISourceLocation loc = new SourceLocation(new File(new String(unit.getFileName())), 0, 0, 0, ""); + IMessage msg = new Message(text, IMessage.ERROR, ex, loc); + return msg; + } public static IMessage makeErrorMessage(String srcFile, String text, Exception ex) { - ISourceLocation loc = new SourceLocation(new File(srcFile), - 0,0,0,""); - IMessage msg = new Message(text,IMessage.ERROR,ex,loc); + ISourceLocation loc = new SourceLocation(new File(srcFile), 0, 0, 0, ""); + IMessage msg = new Message(text, IMessage.ERROR, ex, loc); return msg; } - + private EclipseAdapterUtils() { } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java index d846bedcb..a796e43d3 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java @@ -11,7 +11,6 @@ package org.aspectj.org.eclipse.jdt.core.dom; - import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -48,7 +47,6 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeConstants; -import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Scanner; import org.aspectj.org.eclipse.jdt.internal.compiler.parser.TerminalTokens; import org.aspectj.weaver.AdviceKind; import org.aspectj.weaver.patterns.Declare; @@ -67,55 +65,52 @@ import org.eclipse.core.runtime.IProgressMonitor; */ public class AjASTConverter extends ASTConverter { - public AjASTConverter(Map options, boolean resolveBindings, IProgressMonitor monitor) { - super(options,resolveBindings,monitor); + super(options, resolveBindings, monitor); } - - - public ASTNode convert(AdviceDeclaration adviceDeclaration){ - // ajh02: method added + public ASTNode convert(AdviceDeclaration adviceDeclaration) { + // ajh02: method added org.aspectj.org.eclipse.jdt.core.dom.AdviceDeclaration adviceDecl = null; - if (adviceDeclaration.kind.equals(AdviceKind.Before)){ + if (adviceDeclaration.kind.equals(AdviceKind.Before)) { adviceDecl = new org.aspectj.org.eclipse.jdt.core.dom.BeforeAdviceDeclaration(this.ast); - } else if (adviceDeclaration.kind.equals(AdviceKind.After)){ + } else if (adviceDeclaration.kind.equals(AdviceKind.After)) { adviceDecl = new org.aspectj.org.eclipse.jdt.core.dom.AfterAdviceDeclaration(this.ast); - } else if (adviceDeclaration.kind.equals(AdviceKind.AfterThrowing)){ + } else if (adviceDeclaration.kind.equals(AdviceKind.AfterThrowing)) { adviceDecl = new AfterThrowingAdviceDeclaration(this.ast); if (adviceDeclaration.extraArgument != null) { - SingleVariableDeclaration throwing = convert(adviceDeclaration.extraArgument); - ((AfterThrowingAdviceDeclaration)adviceDecl).setThrowing(throwing); + SingleVariableDeclaration throwing = convert(adviceDeclaration.extraArgument); + ((AfterThrowingAdviceDeclaration) adviceDecl).setThrowing(throwing); } - } else if (adviceDeclaration.kind.equals(AdviceKind.AfterReturning)){ + } else if (adviceDeclaration.kind.equals(AdviceKind.AfterReturning)) { adviceDecl = new AfterReturningAdviceDeclaration(this.ast); if (adviceDeclaration.extraArgument != null) { - SingleVariableDeclaration returning = convert(adviceDeclaration.extraArgument); - ((AfterReturningAdviceDeclaration)adviceDecl).setReturning(returning); - } - } else if (adviceDeclaration.kind.equals(AdviceKind.Around)){ + SingleVariableDeclaration returning = convert(adviceDeclaration.extraArgument); + ((AfterReturningAdviceDeclaration) adviceDecl).setReturning(returning); + } + } else if (adviceDeclaration.kind.equals(AdviceKind.Around)) { adviceDecl = new AroundAdviceDeclaration(this.ast); // set the returnType org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference = adviceDeclaration.returnType; if (typeReference != null) { Type returnType = convertType(typeReference); // get the positions of the right parenthesis - setTypeForAroundAdviceDeclaration((AroundAdviceDeclaration)adviceDecl, returnType); + setTypeForAroundAdviceDeclaration((AroundAdviceDeclaration) adviceDecl, returnType); } org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = adviceDeclaration.typeParameters(); if (typeParameters != null) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - adviceDecl.setFlags(adviceDecl.getFlags() | ASTNode.MALFORMED); - break; - case AST.JLS3 : - for (int i = 0, max = typeParameters.length; i < max; i++) { - ((AroundAdviceDeclaration)adviceDecl).typeParameters().add(convert(typeParameters[i])); - } + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + adviceDecl.setFlags(adviceDecl.getFlags() | ASTNode.MALFORMED); + break; + case AST.JLS3: + for (int i = 0, max = typeParameters.length; i < max; i++) { + ((AroundAdviceDeclaration) adviceDecl).typeParameters().add(convert(typeParameters[i])); + } } } } -// set its javadoc, parameters, throws, pointcut and body + // set its javadoc, parameters, throws, pointcut and body org.aspectj.weaver.patterns.Pointcut pointcut = adviceDeclaration.pointcutDesignator.getPointcut(); adviceDecl.setPointcut(convert(pointcut)); org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = adviceDeclaration.thrownExceptions; @@ -134,17 +129,18 @@ public class AjASTConverter extends ASTConverter { } int start = adviceDeclaration.sourceStart; int end = retrieveIdentifierEndPosition(start, adviceDeclaration.sourceEnd); - + int declarationSourceStart = adviceDeclaration.declarationSourceStart; int declarationSourceEnd = adviceDeclaration.bodyEnd; adviceDecl.setSourceRange(declarationSourceStart, declarationSourceEnd - declarationSourceStart + 1); - int closingPosition = retrieveRightBraceOrSemiColonPosition(adviceDeclaration.bodyEnd + 1, adviceDeclaration.declarationSourceEnd); + int closingPosition = retrieveRightBraceOrSemiColonPosition(adviceDeclaration.bodyEnd + 1, + adviceDeclaration.declarationSourceEnd); if (closingPosition != -1) { int startPosition = adviceDecl.getStartPosition(); adviceDecl.setSourceRange(startPosition, closingPosition - startPosition + 1); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = adviceDeclaration.statements; - + start = retrieveStartBlockPosition(adviceDeclaration.sourceStart, declarationSourceEnd); end = retrieveEndBlockPosition(adviceDeclaration.sourceStart, adviceDeclaration.declarationSourceEnd); Block block = null; @@ -171,44 +167,44 @@ public class AjASTConverter extends ASTConverter { } } else { // syntax error in this advice declaration - start = retrieveStartBlockPosition(adviceDeclaration.sourceStart, declarationSourceEnd); - end = adviceDeclaration.bodyEnd; - // try to get the best end position - IProblem[] problems = adviceDeclaration.compilationResult().problems; - if (problems != null) { - for (int i = 0, max = adviceDeclaration.compilationResult().problemCount; i < max; i++) { - IProblem currentProblem = problems[i]; - if (currentProblem.getSourceStart() == start && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) { - end = currentProblem.getSourceEnd(); - break; - } + start = retrieveStartBlockPosition(adviceDeclaration.sourceStart, declarationSourceEnd); + end = adviceDeclaration.bodyEnd; + // try to get the best end position + IProblem[] problems = adviceDeclaration.compilationResult().problems; + if (problems != null) { + for (int i = 0, max = adviceDeclaration.compilationResult().problemCount; i < max; i++) { + IProblem currentProblem = problems[i]; + if (currentProblem.getSourceStart() == start && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) { + end = currentProblem.getSourceEnd(); + break; } } - int startPosition = adviceDecl.getStartPosition(); - adviceDecl.setSourceRange(startPosition, end - startPosition + 1); - if (start != -1 && end != -1) { - /* - * start or end can be equal to -1 if we have an interface's method. - */ - Block block = new Block(this.ast); - block.setSourceRange(start, end - start + 1); - adviceDecl.setBody(block); - } + } + int startPosition = adviceDecl.getStartPosition(); + adviceDecl.setSourceRange(startPosition, end - startPosition + 1); + if (start != -1 && end != -1) { + /* + * start or end can be equal to -1 if we have an interface's method. + */ + Block block = new Block(this.ast); + block.setSourceRange(start, end - start + 1); + adviceDecl.setBody(block); + } } - + // The javadoc comment is now got from list store in compilation unit declaration if (this.resolveBindings) { recordNodes(adviceDecl, adviceDeclaration); - //if (adviceDecl.resolveBinding() != null) { - //// ajh02: what is resolveBinding()? - // convert(adviceDeclaration.javadoc, adviceDecl); - //} + // if (adviceDecl.resolveBinding() != null) { + // // ajh02: what is resolveBinding()? + // convert(adviceDeclaration.javadoc, adviceDecl); + // } } else { convert(adviceDeclaration.javadoc, adviceDecl); } return adviceDecl; } - + public ASTNode convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration methodDeclaration) { checkCanceled(); if (methodDeclaration instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration) { @@ -217,26 +213,28 @@ public class AjASTConverter extends ASTConverter { MethodDeclaration methodDecl = new MethodDeclaration(this.ast); boolean isConstructor = methodDeclaration.isConstructor(); methodDecl.setConstructor(isConstructor); - - ////////////////// ajh02: added. ugh, polymorphism! Where are you! - if (methodDeclaration instanceof DeclareDeclaration){ - return convert((DeclareDeclaration)methodDeclaration); - } else if (methodDeclaration instanceof InterTypeFieldDeclaration){ + + // //////////////// ajh02: added. ugh, polymorphism! Where are you! + if (methodDeclaration instanceof DeclareDeclaration) { + return convert((DeclareDeclaration) methodDeclaration); + } else if (methodDeclaration instanceof InterTypeFieldDeclaration) { return convert((InterTypeFieldDeclaration) methodDeclaration); - } else if (methodDeclaration instanceof InterTypeMethodDeclaration){ + } else if (methodDeclaration instanceof InterTypeMethodDeclaration) { methodDecl = new org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration(this.ast); - ((org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration) methodDecl).setOnType(((InterTypeMethodDeclaration) methodDeclaration).getOnType().toString()); - } else if (methodDeclaration instanceof InterTypeConstructorDeclaration){ + ((org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration) methodDecl) + .setOnType(((InterTypeMethodDeclaration) methodDeclaration).getOnType().toString()); + } else if (methodDeclaration instanceof InterTypeConstructorDeclaration) { methodDecl = new org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration(this.ast); - ((org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration) methodDecl).setOnType(((InterTypeConstructorDeclaration) methodDeclaration).getOnType().toString()); + ((org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration) methodDecl) + .setOnType(((InterTypeConstructorDeclaration) methodDeclaration).getOnType().toString()); methodDecl.setConstructor(true); - } else if (methodDeclaration instanceof PointcutDeclaration){ + } else if (methodDeclaration instanceof PointcutDeclaration) { return convert((PointcutDeclaration) methodDeclaration); - } else if (methodDeclaration instanceof AdviceDeclaration){ - return convert((AdviceDeclaration)methodDeclaration); + } else if (methodDeclaration instanceof AdviceDeclaration) { + return convert((AdviceDeclaration) methodDeclaration); } - ///////////////////////// - + // /////////////////////// + // set modifiers after checking whether we're an itd, otherwise // the modifiers are not set on the correct object. setModifiers(methodDecl, methodDeclaration); @@ -253,7 +251,7 @@ public class AjASTConverter extends ASTConverter { int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd); methodName.setSourceRange(start, end - start + 1); methodDecl.setName(methodName); - + org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions; if (thrownExceptions != null) { int thrownExceptionsLength = thrownExceptions.length; @@ -272,16 +270,16 @@ public class AjASTConverter extends ASTConverter { if (isConstructor) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration constructorDeclaration = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration) methodDeclaration; explicitConstructorCall = constructorDeclaration.constructorCall; - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - // set the return type to VOID - PrimitiveType returnType = new PrimitiveType(this.ast); - returnType.setPrimitiveTypeCode(PrimitiveType.VOID); - returnType.setSourceRange(methodDeclaration.sourceStart, 0); - methodDecl.internalSetReturnType(returnType); - break; - case AST.JLS3 : - methodDecl.setReturnType2(null); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + // set the return type to VOID + PrimitiveType returnType = new PrimitiveType(this.ast); + returnType.setPrimitiveTypeCode(PrimitiveType.VOID); + returnType.setSourceRange(methodDeclaration.sourceStart, 0); + methodDecl.internalSetReturnType(returnType); + break; + case AST.JLS3: + methodDecl.setReturnType2(null); } } else if (methodDeclaration instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration method = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) methodDeclaration; @@ -298,13 +296,14 @@ public class AjASTConverter extends ASTConverter { int declarationSourceStart = methodDeclaration.declarationSourceStart; int declarationSourceEnd = methodDeclaration.bodyEnd; methodDecl.setSourceRange(declarationSourceStart, declarationSourceEnd - declarationSourceStart + 1); - int closingPosition = retrieveRightBraceOrSemiColonPosition(methodDeclaration.bodyEnd + 1, methodDeclaration.declarationSourceEnd); + int closingPosition = retrieveRightBraceOrSemiColonPosition(methodDeclaration.bodyEnd + 1, + methodDeclaration.declarationSourceEnd); if (closingPosition != -1) { int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = methodDeclaration.statements; - + start = retrieveStartBlockPosition(methodDeclaration.sourceStart, declarationSourceEnd); end = retrieveEndBlockPosition(methodDeclaration.sourceStart, methodDeclaration.declarationSourceEnd); Block block = null; @@ -317,7 +316,8 @@ public class AjASTConverter extends ASTConverter { methodDecl.setBody(block); } if (block != null && (statements != null || explicitConstructorCall != null)) { - if (explicitConstructorCall != null && explicitConstructorCall.accessMode != org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall.ImplicitSuper) { + if (explicitConstructorCall != null + && explicitConstructorCall.accessMode != org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall.ImplicitSuper) { block.statements().add(super.convert(explicitConstructorCall)); } int statementsLength = statements == null ? 0 : statements.length; @@ -342,7 +342,8 @@ public class AjASTConverter extends ASTConverter { if (problems != null) { for (int i = 0, max = methodDeclaration.compilationResult().problemCount; i < max; i++) { IProblem currentProblem = problems[i]; - if (currentProblem.getSourceStart() == start && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) { + if (currentProblem.getSourceStart() == start + && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) { end = currentProblem.getSourceEnd(); break; } @@ -358,22 +359,22 @@ public class AjASTConverter extends ASTConverter { block.setSourceRange(start, end - start + 1); methodDecl.setBody(block); } - } + } } org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = methodDeclaration.typeParameters(); if (typeParameters != null) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); - break; - case AST.JLS3 : - for (int i = 0, max = typeParameters.length; i < max; i++) { - methodDecl.typeParameters().add(convert(typeParameters[i])); - } + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); + break; + case AST.JLS3: + for (int i = 0, max = typeParameters.length; i < max; i++) { + methodDecl.typeParameters().add(convert(typeParameters[i])); + } } } - + // The javadoc comment is now got from list store in compilation unit declaration if (this.resolveBindings) { recordNodes(methodDecl, methodDeclaration); @@ -385,123 +386,125 @@ public class AjASTConverter extends ASTConverter { convert(methodDeclaration.javadoc, methodDecl); } return methodDecl; - } - - + } + public ASTNode convert(DeclareDeclaration declareDecl) { checkCanceled(); // is this line needed? org.aspectj.org.eclipse.jdt.core.dom.DeclareDeclaration declareDeclaration = null; Declare declare = declareDecl.declareDecl; if (declare instanceof DeclareAnnotation) { - DeclareAnnotation da = (DeclareAnnotation)declare; + DeclareAnnotation da = (DeclareAnnotation) declare; if (da.getKind().equals(DeclareAnnotation.AT_TYPE)) { declareDeclaration = new DeclareAtTypeDeclaration(this.ast); - ((DeclareAtTypeDeclaration)declareDeclaration).setPatternNode(convert(da.getTypePattern())); + ((DeclareAtTypeDeclaration) declareDeclaration).setPatternNode(convert(da.getTypePattern())); SimpleName annotationName = new SimpleName(this.ast); - annotationName.internalSetIdentifier(new String(da.getAnnotationString())); - ((DeclareAtTypeDeclaration)declareDeclaration).setAnnotationName(annotationName); + annotationName.internalSetIdentifier(new String(da.getAnnotationString())); + ((DeclareAtTypeDeclaration) declareDeclaration).setAnnotationName(annotationName); } else if (da.getKind().equals(DeclareAnnotation.AT_CONSTRUCTOR)) { declareDeclaration = new DeclareAtConstructorDeclaration(this.ast); - ((DeclareAtConstructorDeclaration)declareDeclaration).setPatternNode(convert(da.getSignaturePattern())); + ((DeclareAtConstructorDeclaration) declareDeclaration).setPatternNode(convert(da.getSignaturePattern())); SimpleName annotationName = new SimpleName(this.ast); - annotationName.internalSetIdentifier(new String(da.getAnnotationString())); - ((DeclareAtConstructorDeclaration)declareDeclaration).setAnnotationName(annotationName); + annotationName.internalSetIdentifier(new String(da.getAnnotationString())); + ((DeclareAtConstructorDeclaration) declareDeclaration).setAnnotationName(annotationName); } else if (da.getKind().equals(DeclareAnnotation.AT_FIELD)) { declareDeclaration = new DeclareAtFieldDeclaration(this.ast); - ((DeclareAtFieldDeclaration)declareDeclaration).setPatternNode(convert(da.getSignaturePattern())); + ((DeclareAtFieldDeclaration) declareDeclaration).setPatternNode(convert(da.getSignaturePattern())); SimpleName annotationName = new SimpleName(this.ast); - annotationName.internalSetIdentifier(new String(da.getAnnotationString())); - ((DeclareAtFieldDeclaration)declareDeclaration).setAnnotationName(annotationName); + annotationName.internalSetIdentifier(new String(da.getAnnotationString())); + ((DeclareAtFieldDeclaration) declareDeclaration).setAnnotationName(annotationName); } else if (da.getKind().equals(DeclareAnnotation.AT_METHOD)) { declareDeclaration = new DeclareAtMethodDeclaration(this.ast); - ((DeclareAtMethodDeclaration)declareDeclaration).setPatternNode(convert(da.getSignaturePattern())); + ((DeclareAtMethodDeclaration) declareDeclaration).setPatternNode(convert(da.getSignaturePattern())); SimpleName annotationName = new SimpleName(this.ast); - annotationName.internalSetIdentifier(new String(da.getAnnotationString())); - ((DeclareAtMethodDeclaration)declareDeclaration).setAnnotationName(annotationName); + annotationName.internalSetIdentifier(new String(da.getAnnotationString())); + ((DeclareAtMethodDeclaration) declareDeclaration).setAnnotationName(annotationName); } - } else if (declare instanceof DeclareErrorOrWarning){ - DeclareErrorOrWarning deow = (DeclareErrorOrWarning)declare; + } else if (declare instanceof DeclareErrorOrWarning) { + DeclareErrorOrWarning deow = (DeclareErrorOrWarning) declare; if (deow.isError()) { declareDeclaration = new DeclareErrorDeclaration(this.ast); - ((DeclareErrorDeclaration)declareDeclaration).setPointcut(convert(deow.getPointcut())); + ((DeclareErrorDeclaration) declareDeclaration).setPointcut(convert(deow.getPointcut())); StringLiteral message = new StringLiteral(this.ast); message.setEscapedValue(updateString(deow.getMessage())); - ((DeclareErrorDeclaration)declareDeclaration).setMessage(message); + ((DeclareErrorDeclaration) declareDeclaration).setMessage(message); } else { declareDeclaration = new DeclareWarningDeclaration(this.ast); - ((DeclareWarningDeclaration)declareDeclaration).setPointcut(convert(deow.getPointcut())); + ((DeclareWarningDeclaration) declareDeclaration).setPointcut(convert(deow.getPointcut())); StringLiteral message = new StringLiteral(this.ast); message.setEscapedValue(updateString(deow.getMessage())); - ((DeclareWarningDeclaration)declareDeclaration).setMessage(message); + ((DeclareWarningDeclaration) declareDeclaration).setMessage(message); } } else if (declare instanceof DeclareParents) { - DeclareParents dp = (DeclareParents)declare; - declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclareParentsDeclaration(this.ast,dp.isExtends()); + DeclareParents dp = (DeclareParents) declare; + declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclareParentsDeclaration(this.ast, dp.isExtends()); org.aspectj.org.eclipse.jdt.core.dom.PatternNode pNode = convert(dp.getChild()); if (pNode instanceof org.aspectj.org.eclipse.jdt.core.dom.TypePattern) { - ((DeclareParentsDeclaration)declareDeclaration).setChildTypePattern((org.aspectj.org.eclipse.jdt.core.dom.TypePattern)pNode); + ((DeclareParentsDeclaration) declareDeclaration) + .setChildTypePattern((org.aspectj.org.eclipse.jdt.core.dom.TypePattern) pNode); } TypePattern[] weaverTypePatterns = dp.getParents().getTypePatterns(); - List typePatterns = ((DeclareParentsDeclaration)declareDeclaration).parentTypePatterns(); + List typePatterns = ((DeclareParentsDeclaration) declareDeclaration).parentTypePatterns(); for (int i = 0; i < weaverTypePatterns.length; i++) { typePatterns.add(convert(weaverTypePatterns[i])); } } else if (declare instanceof DeclarePrecedence) { declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclarePrecedenceDeclaration(this.ast); - DeclarePrecedence dp = (DeclarePrecedence)declare; + DeclarePrecedence dp = (DeclarePrecedence) declare; TypePattern[] weaverTypePatterns = dp.getPatterns().getTypePatterns(); - List typePatterns = ((DeclarePrecedenceDeclaration)declareDeclaration).typePatterns(); + List typePatterns = ((DeclarePrecedenceDeclaration) declareDeclaration).typePatterns(); for (int i = 0; i < weaverTypePatterns.length; i++) { typePatterns.add(convert(weaverTypePatterns[i])); } } else if (declare instanceof DeclareSoft) { declareDeclaration = new DeclareSoftDeclaration(this.ast); - DeclareSoft ds = (DeclareSoft)declare; - ((DeclareSoftDeclaration)declareDeclaration).setPointcut(convert(ds.getPointcut())); + DeclareSoft ds = (DeclareSoft) declare; + ((DeclareSoftDeclaration) declareDeclaration).setPointcut(convert(ds.getPointcut())); org.aspectj.org.eclipse.jdt.core.dom.PatternNode pNode = convert(ds.getException()); if (pNode instanceof org.aspectj.org.eclipse.jdt.core.dom.TypePattern) { - ((DeclareSoftDeclaration)declareDeclaration).setTypePattern((org.aspectj.org.eclipse.jdt.core.dom.TypePattern)pNode); - } + ((DeclareSoftDeclaration) declareDeclaration) + .setTypePattern((org.aspectj.org.eclipse.jdt.core.dom.TypePattern) pNode); + } } - declareDeclaration.setSourceRange(declareDecl.declarationSourceStart, - declareDecl.declarationSourceEnd - declareDecl.declarationSourceStart + 1); + declareDeclaration.setSourceRange(declareDecl.declarationSourceStart, declareDecl.declarationSourceEnd + - declareDecl.declarationSourceStart + 1); return declareDeclaration; } private String updateString(String message) { - StringBuffer sb = new StringBuffer(message); - int nextQuote = sb.toString().indexOf("\""); - while (nextQuote != -1) { - sb.insert(nextQuote,"\\"); + StringBuffer sb = new StringBuffer(message); + int nextQuote = sb.toString().indexOf("\""); + while (nextQuote != -1) { + sb.insert(nextQuote, "\\"); nextQuote = sb.toString().indexOf("\""); } - int nextNewLine = sb.toString().indexOf("\n"); - while (nextNewLine != -1) { - sb.insert(nextNewLine,"\\"); + int nextNewLine = sb.toString().indexOf("\n"); + while (nextNewLine != -1) { + sb.insert(nextNewLine, "\\"); nextNewLine = sb.toString().indexOf("\n"); } - if(!sb.toString().startsWith("\"")) { - sb.insert(0,"\""); - } - if(!sb.toString().endsWith("\"")) { - sb.insert(sb.toString().length(),"\""); - } - return sb.toString(); + if (!sb.toString().startsWith("\"")) { + sb.insert(0, "\""); + } + if (!sb.toString().endsWith("\"")) { + sb.insert(sb.toString().length(), "\""); + } + return sb.toString(); } - - + public ASTNode convert(InterTypeFieldDeclaration fieldDecl) { // ajh02: method added checkCanceled(); // ajh02: is this line needed? VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(fieldDecl); - final org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration fieldDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration(this.ast); + final org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration fieldDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration( + this.ast); fieldDeclaration.fragments().add(variableDeclarationFragment); IVariableBinding binding = null; if (this.resolveBindings) { recordNodes(variableDeclarationFragment, fieldDecl); binding = variableDeclarationFragment.resolveBinding(); } - fieldDeclaration.setSourceRange(fieldDecl.declarationSourceStart, fieldDecl.declarationSourceEnd - fieldDecl.declarationSourceStart + 1); + fieldDeclaration.setSourceRange(fieldDecl.declarationSourceStart, fieldDecl.declarationSourceEnd + - fieldDecl.declarationSourceStart + 1); Type type = convertType(fieldDecl.returnType); setTypeForField(fieldDeclaration, type, variableDeclarationFragment.getExtraDimensions()); setModifiers(fieldDeclaration, fieldDecl); @@ -511,22 +514,26 @@ public class AjASTConverter extends ASTConverter { fieldDeclaration.setOnType(fieldDecl.getOnType().toString()); return fieldDeclaration; } + public ASTNode convert(PointcutDeclaration pointcutDeclaration) { // ajh02: method added checkCanceled(); - org.aspectj.org.eclipse.jdt.core.dom.PointcutDeclaration pointcutDecl = new org.aspectj.org.eclipse.jdt.core.dom.PointcutDeclaration(this.ast); + org.aspectj.org.eclipse.jdt.core.dom.PointcutDeclaration pointcutDecl = new org.aspectj.org.eclipse.jdt.core.dom.PointcutDeclaration( + this.ast); setModifiers(pointcutDecl, pointcutDeclaration); final SimpleName pointcutName = new SimpleName(this.ast); - pointcutName.internalSetIdentifier(new String(pointcutDeclaration.selector)); + pointcutName.internalSetIdentifier(new String(pointcutDeclaration.selector)); int start = pointcutDeclaration.sourceStart; int end = retrieveIdentifierEndPosition(start, pointcutDeclaration.sourceEnd); pointcutName.setSourceRange(start, end - start + 1); - pointcutDecl.setSourceRange(pointcutDeclaration.declarationSourceStart, (pointcutDeclaration.bodyEnd - pointcutDeclaration.declarationSourceStart + 1)); + pointcutDecl.setSourceRange(pointcutDeclaration.declarationSourceStart, (pointcutDeclaration.bodyEnd + - pointcutDeclaration.declarationSourceStart + 1)); pointcutDecl.setName(pointcutName); - if (pointcutDeclaration.pointcutDesignator != null){ - pointcutDecl.setDesignator((org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator)convert(pointcutDeclaration.pointcutDesignator.getPointcut())); + if (pointcutDeclaration.pointcutDesignator != null) { + pointcutDecl.setDesignator(convert(pointcutDeclaration.pointcutDesignator.getPointcut())); } else { - pointcutDecl.setDesignator(new org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut(this.ast,pointcutDeclaration.toString())); + pointcutDecl.setDesignator(new org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut(this.ast, pointcutDeclaration + .toString())); } org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument[] parameters = pointcutDeclaration.arguments; if (parameters != null) { @@ -535,8 +542,8 @@ public class AjASTConverter extends ASTConverter { pointcutDecl.parameters().add(convert(parameters[i])); } } - -// The javadoc comment is now got from list store in compilation unit declaration + + // The javadoc comment is now got from list store in compilation unit declaration if (this.resolveBindings) { recordNodes(pointcutDecl, pointcutDeclaration); recordNodes(pointcutName, pointcutDeclaration); @@ -545,76 +552,87 @@ public class AjASTConverter extends ASTConverter { } return pointcutDecl; } - public org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator convert(org.aspectj.weaver.patterns.Pointcut pointcut){ + + public org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator convert(org.aspectj.weaver.patterns.Pointcut pointcut) { // ajh02: this could do with being seperate methods // rather than a huge if.elseif..elseif.. thing org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator pointcutDesi = null; - if (pointcut instanceof org.aspectj.weaver.patterns.ReferencePointcut){ + if (pointcut instanceof org.aspectj.weaver.patterns.ReferencePointcut) { pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.ReferencePointcut(this.ast); final SimpleName pointcutName = new SimpleName(this.ast); int start = pointcut.getStart(); int end = retrieveIdentifierEndPosition(start, pointcut.getEnd()); pointcutName.setSourceRange(start, end - start + 1); - pointcutName.internalSetIdentifier(((org.aspectj.weaver.patterns.ReferencePointcut)pointcut).name); - ((org.aspectj.org.eclipse.jdt.core.dom.ReferencePointcut)pointcutDesi).setName(pointcutName); + pointcutName.internalSetIdentifier(((org.aspectj.weaver.patterns.ReferencePointcut) pointcut).name); + ((org.aspectj.org.eclipse.jdt.core.dom.ReferencePointcut) pointcutDesi).setName(pointcutName); } else if (pointcut instanceof org.aspectj.weaver.patterns.NotPointcut) { pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.NotPointcut(this.ast); - final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.NotPointcut)pointcut).getNegatedPointcut()); - ((org.aspectj.org.eclipse.jdt.core.dom.NotPointcut)pointcutDesi).setBody(body); + final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.NotPointcut) pointcut) + .getNegatedPointcut()); + ((org.aspectj.org.eclipse.jdt.core.dom.NotPointcut) pointcutDesi).setBody(body); } else if (pointcut instanceof org.aspectj.weaver.patterns.PerObject) { pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.PerObject(this.ast); - final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.PerObject)pointcut).getEntry()); - ((org.aspectj.org.eclipse.jdt.core.dom.PerObject)pointcutDesi).setBody(body); + final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.PerObject) pointcut) + .getEntry()); + ((org.aspectj.org.eclipse.jdt.core.dom.PerObject) pointcutDesi).setBody(body); } else if (pointcut instanceof org.aspectj.weaver.patterns.PerCflow) { pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.PerCflow(this.ast); - final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.PerCflow)pointcut).getEntry()); - ((org.aspectj.org.eclipse.jdt.core.dom.PerCflow)pointcutDesi).setBody(body); + final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.PerCflow) pointcut) + .getEntry()); + ((org.aspectj.org.eclipse.jdt.core.dom.PerCflow) pointcutDesi).setBody(body); } else if (pointcut instanceof org.aspectj.weaver.patterns.PerTypeWithin) { pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.PerTypeWithin(this.ast); // should set its type pattern here } else if (pointcut instanceof org.aspectj.weaver.patterns.CflowPointcut) { pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.CflowPointcut(this.ast); - final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.CflowPointcut)pointcut).getEntry()); - ((org.aspectj.org.eclipse.jdt.core.dom.CflowPointcut)pointcutDesi).setBody(body); - ((org.aspectj.org.eclipse.jdt.core.dom.CflowPointcut)pointcutDesi).setIsCflowBelow(((org.aspectj.weaver.patterns.CflowPointcut)pointcut).isCflowBelow()); + final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.CflowPointcut) pointcut) + .getEntry()); + ((org.aspectj.org.eclipse.jdt.core.dom.CflowPointcut) pointcutDesi).setBody(body); + ((org.aspectj.org.eclipse.jdt.core.dom.CflowPointcut) pointcutDesi) + .setIsCflowBelow(((org.aspectj.weaver.patterns.CflowPointcut) pointcut).isCflowBelow()); } else if (pointcut instanceof org.aspectj.weaver.patterns.AndPointcut) { pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.AndPointcut(this.ast); - final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator left = convert(((org.aspectj.weaver.patterns.AndPointcut)pointcut).getLeft()); - final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator right = convert(((org.aspectj.weaver.patterns.AndPointcut)pointcut).getRight()); - ((org.aspectj.org.eclipse.jdt.core.dom.AndPointcut)pointcutDesi).setLeft(left); - ((org.aspectj.org.eclipse.jdt.core.dom.AndPointcut)pointcutDesi).setRight(right); + final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator left = convert(((org.aspectj.weaver.patterns.AndPointcut) pointcut) + .getLeft()); + final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator right = convert(((org.aspectj.weaver.patterns.AndPointcut) pointcut) + .getRight()); + ((org.aspectj.org.eclipse.jdt.core.dom.AndPointcut) pointcutDesi).setLeft(left); + ((org.aspectj.org.eclipse.jdt.core.dom.AndPointcut) pointcutDesi).setRight(right); } else if (pointcut instanceof org.aspectj.weaver.patterns.OrPointcut) { pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.OrPointcut(this.ast); - final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator left = convert(((org.aspectj.weaver.patterns.OrPointcut)pointcut).getLeft()); - final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator right = convert(((org.aspectj.weaver.patterns.OrPointcut)pointcut).getRight()); - ((org.aspectj.org.eclipse.jdt.core.dom.OrPointcut)pointcutDesi).setLeft(left); - ((org.aspectj.org.eclipse.jdt.core.dom.OrPointcut)pointcutDesi).setRight(right); + final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator left = convert(((org.aspectj.weaver.patterns.OrPointcut) pointcut) + .getLeft()); + final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator right = convert(((org.aspectj.weaver.patterns.OrPointcut) pointcut) + .getRight()); + ((org.aspectj.org.eclipse.jdt.core.dom.OrPointcut) pointcutDesi).setLeft(left); + ((org.aspectj.org.eclipse.jdt.core.dom.OrPointcut) pointcutDesi).setRight(right); } else { // ajh02: default stub until I make all the concrete PointcutDesignator types - pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut(this.ast,pointcut.toString()); + pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut(this.ast, pointcut.toString()); } - pointcutDesi.setSourceRange(pointcut.getStart(),(pointcut.getEnd() - pointcut.getStart() + 1)); + pointcutDesi.setSourceRange(pointcut.getStart(), (pointcut.getEnd() - pointcut.getStart() + 1)); return pointcutDesi; } - - public org.aspectj.org.eclipse.jdt.core.dom.PatternNode convert(PatternNode patternNode){ - // this is a stub to be used until dom classes have been created for + + public org.aspectj.org.eclipse.jdt.core.dom.PatternNode convert(PatternNode patternNode) { + // this is a stub to be used until dom classes have been created for // the different weaver TypePattern's org.aspectj.org.eclipse.jdt.core.dom.PatternNode pNode = null; if (patternNode instanceof TypePattern) { - TypePattern typePat = (TypePattern)patternNode; - pNode = new DefaultTypePattern(this.ast,typePat.toString()); - pNode.setSourceRange(typePat.getStart(),(typePat.getEnd() - typePat.getStart() + 1)); + TypePattern typePat = (TypePattern) patternNode; + pNode = new DefaultTypePattern(this.ast, typePat.toString()); + pNode.setSourceRange(typePat.getStart(), (typePat.getEnd() - typePat.getStart() + 1)); } else if (patternNode instanceof SignaturePattern) { - SignaturePattern sigPat = (SignaturePattern)patternNode; - pNode = new org.aspectj.org.eclipse.jdt.core.dom.SignaturePattern(this.ast,sigPat.toString()); - pNode.setSourceRange(sigPat.getStart(),(sigPat.getEnd() - sigPat.getStart() + 1)); + SignaturePattern sigPat = (SignaturePattern) patternNode; + pNode = new org.aspectj.org.eclipse.jdt.core.dom.SignaturePattern(this.ast, sigPat.toString()); + pNode.setSourceRange(sigPat.getStart(), (sigPat.getEnd() - sigPat.getStart() + 1)); } return pNode; - + } - - public ASTNode convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) { + + public ASTNode convert( + org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) { checkCanceled(); if (this.ast.apiLevel == AST.JLS2_INTERNAL) { return null; @@ -648,7 +666,7 @@ public class AjASTConverter extends ASTConverter { } return annotationTypeMemberDeclaration2; } - + public SingleVariableDeclaration convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument argument) { SingleVariableDeclaration variableDecl = new SingleVariableDeclaration(this.ast); setModifiers(variableDecl, argument); @@ -670,8 +688,7 @@ public class AjASTConverter extends ASTConverter { int typeEnd = type.getStartPosition() + type.getLength() - 1; int rightEnd = Math.max(typeEnd, argument.declarationSourceEnd); /* - * There is extra work to do to set the proper type positions - * See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284 + * There is extra work to do to set the proper type positions See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284 */ if (isVarArgs) { setTypeForSingleVariableDeclaration(variableDecl, type, extraDimensions + 1); @@ -682,14 +699,14 @@ public class AjASTConverter extends ASTConverter { setTypeForSingleVariableDeclaration(variableDecl, type, extraDimensions); } variableDecl.setSourceRange(argument.declarationSourceStart, rightEnd - argument.declarationSourceStart + 1); - + if (isVarArgs) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED); - break; - case AST.JLS3 : - variableDecl.setVarargs(true); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED); + break; + case AST.JLS3: + variableDecl.setVarargs(true); } } if (this.resolveBindings) { @@ -700,68 +717,67 @@ public class AjASTConverter extends ASTConverter { return variableDecl; } - -// public Annotation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation) { -// if (annotation instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) annotation); -// } else if (annotation instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation) { -// org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation ma = -// (org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation) annotation; -// return convert( ma);//(org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation) annotation); -// } else { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NormalAnnotation) annotation); -// } -// } - -// public ArrayCreation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression expression) { -// ArrayCreation arrayCreation = new ArrayCreation(this.ast); -// if (this.resolveBindings) { -// recordNodes(arrayCreation, expression); -// } -// arrayCreation.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); -// org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] dimensions = expression.dimensions; -// -// int dimensionsLength = dimensions.length; -// for (int i = 0; i < dimensionsLength; i++) { -// if (dimensions[i] != null) { -// Expression dimension = convert(dimensions[i]); -// if (this.resolveBindings) { -// recordNodes(dimension, dimensions[i]); -// } -// arrayCreation.dimensions().add(dimension); -// } -// } -// Type type = convertType(expression.type); -// if (this.resolveBindings) { -// recordNodes(type, expression.type); -// } -// ArrayType arrayType = null; -// if (type.isArrayType()) { -// arrayType = (ArrayType) type; -// } else { -// arrayType = this.ast.newArrayType(type, dimensionsLength); -// if (this.resolveBindings) { -// completeRecord(arrayType, expression); -// } -// int start = type.getStartPosition(); -// int end = type.getStartPosition() + type.getLength(); -// int previousSearchStart = end; -// ArrayType componentType = (ArrayType) type.getParent(); -// for (int i = 0; i < dimensionsLength; i++) { -// previousSearchStart = retrieveRightBracketPosition(previousSearchStart + 1, this.compilationUnitSourceLength); -// componentType.setSourceRange(start, previousSearchStart - start + 1); -// componentType = (ArrayType) componentType.getParent(); -// } -// } -// arrayCreation.setType(arrayType); -// if (this.resolveBindings) { -// recordNodes(arrayType, expression); -// } -// if (expression.initializer != null) { -// arrayCreation.setInitializer(convert(expression.initializer)); -// } -// return arrayCreation; -// } + // public Annotation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation) { + // if (annotation instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) annotation); + // } else if (annotation instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation) { + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation ma = + // (org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation) annotation; + // return convert( ma);//(org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation) annotation); + // } else { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NormalAnnotation) annotation); + // } + // } + + // public ArrayCreation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression expression) { + // ArrayCreation arrayCreation = new ArrayCreation(this.ast); + // if (this.resolveBindings) { + // recordNodes(arrayCreation, expression); + // } + // arrayCreation.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] dimensions = expression.dimensions; + // + // int dimensionsLength = dimensions.length; + // for (int i = 0; i < dimensionsLength; i++) { + // if (dimensions[i] != null) { + // Expression dimension = convert(dimensions[i]); + // if (this.resolveBindings) { + // recordNodes(dimension, dimensions[i]); + // } + // arrayCreation.dimensions().add(dimension); + // } + // } + // Type type = convertType(expression.type); + // if (this.resolveBindings) { + // recordNodes(type, expression.type); + // } + // ArrayType arrayType = null; + // if (type.isArrayType()) { + // arrayType = (ArrayType) type; + // } else { + // arrayType = this.ast.newArrayType(type, dimensionsLength); + // if (this.resolveBindings) { + // completeRecord(arrayType, expression); + // } + // int start = type.getStartPosition(); + // int end = type.getStartPosition() + type.getLength(); + // int previousSearchStart = end; + // ArrayType componentType = (ArrayType) type.getParent(); + // for (int i = 0; i < dimensionsLength; i++) { + // previousSearchStart = retrieveRightBracketPosition(previousSearchStart + 1, this.compilationUnitSourceLength); + // componentType.setSourceRange(start, previousSearchStart - start + 1); + // componentType = (ArrayType) componentType.getParent(); + // } + // } + // arrayCreation.setType(arrayType); + // if (this.resolveBindings) { + // recordNodes(arrayType, expression); + // } + // if (expression.initializer != null) { + // arrayCreation.setInitializer(convert(expression.initializer)); + // } + // return arrayCreation; + // } public ArrayInitializer convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer expression) { ArrayInitializer arrayInitializer = new ArrayInitializer(this.ast); @@ -783,49 +799,48 @@ public class AjASTConverter extends ASTConverter { return arrayInitializer; } -// public ArrayAccess convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference reference) { -// ArrayAccess arrayAccess = new ArrayAccess(this.ast); -// if (this.resolveBindings) { -// recordNodes(arrayAccess, reference); -// } -// arrayAccess.setSourceRange(reference.sourceStart, reference.sourceEnd - reference.sourceStart + 1); -// arrayAccess.setArray(convert(reference.receiver)); -// arrayAccess.setIndex(convert(reference.position)); -// return arrayAccess; -// } - -// public AssertStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.AssertStatement statement) { -// AssertStatement assertStatement = new AssertStatement(this.ast); -// int end = statement.assertExpression.sourceEnd + 1; -// assertStatement.setExpression(convert(statement.assertExpression)); -// org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression exceptionArgument = statement.exceptionArgument; -// if (exceptionArgument != null) { -// end = exceptionArgument.sourceEnd + 1; -// assertStatement.setMessage(convert(exceptionArgument)); -// } -// int start = statement.sourceStart; -// int sourceEnd = retrieveEndingSemiColonPosition(end, this.compilationUnitSourceLength); -// assertStatement.setSourceRange(start, sourceEnd - start + 1); -// return assertStatement; -// } - -// public Assignment convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Assignment expression) { -// Assignment assignment = new Assignment(this.ast); -// if (this.resolveBindings) { -// recordNodes(assignment, expression); -// } -// Expression lhs = convert(expression.lhs); -// assignment.setLeftHandSide(lhs); -// assignment.setOperator(Assignment.Operator.ASSIGN); -// assignment.setRightHandSide(convert(expression.expression)); -// int start = lhs.getStartPosition(); -// assignment.setSourceRange(start, expression.sourceEnd - start + 1); -// return assignment; -// } + // public ArrayAccess convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference reference) { + // ArrayAccess arrayAccess = new ArrayAccess(this.ast); + // if (this.resolveBindings) { + // recordNodes(arrayAccess, reference); + // } + // arrayAccess.setSourceRange(reference.sourceStart, reference.sourceEnd - reference.sourceStart + 1); + // arrayAccess.setArray(convert(reference.receiver)); + // arrayAccess.setIndex(convert(reference.position)); + // return arrayAccess; + // } + + // public AssertStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.AssertStatement statement) { + // AssertStatement assertStatement = new AssertStatement(this.ast); + // int end = statement.assertExpression.sourceEnd + 1; + // assertStatement.setExpression(convert(statement.assertExpression)); + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression exceptionArgument = statement.exceptionArgument; + // if (exceptionArgument != null) { + // end = exceptionArgument.sourceEnd + 1; + // assertStatement.setMessage(convert(exceptionArgument)); + // } + // int start = statement.sourceStart; + // int sourceEnd = retrieveEndingSemiColonPosition(end, this.compilationUnitSourceLength); + // assertStatement.setSourceRange(start, sourceEnd - start + 1); + // return assertStatement; + // } + + // public Assignment convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Assignment expression) { + // Assignment assignment = new Assignment(this.ast); + // if (this.resolveBindings) { + // recordNodes(assignment, expression); + // } + // Expression lhs = convert(expression.lhs); + // assignment.setLeftHandSide(lhs); + // assignment.setOperator(Assignment.Operator.ASSIGN); + // assignment.setRightHandSide(convert(expression.expression)); + // int start = lhs.getStartPosition(); + // assignment.setSourceRange(start, expression.sourceEnd - start + 1); + // return assignment; + // } /* - * Internal use only - * Used to convert class body declarations + * Internal use only Used to convert class body declarations */ public TypeDeclaration convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode[] nodes) { final TypeDeclaration typeDecl = TypeDeclaration.getTypeDeclaration(this.ast); @@ -838,30 +853,32 @@ public class AjASTConverter extends ASTConverter { Initializer initializer = new Initializer(this.ast); initializer.setBody(convert(oldInitializer.block)); setModifiers(initializer, oldInitializer); - initializer.setSourceRange(oldInitializer.declarationSourceStart, oldInitializer.sourceEnd - oldInitializer.declarationSourceStart + 1); -// setJavaDocComment(initializer); -// initializer.setJavadoc(convert(oldInitializer.javadoc)); + initializer.setSourceRange(oldInitializer.declarationSourceStart, oldInitializer.sourceEnd + - oldInitializer.declarationSourceStart + 1); + // setJavaDocComment(initializer); + // initializer.setJavadoc(convert(oldInitializer.javadoc)); convert(oldInitializer.javadoc, initializer); typeDecl.bodyDeclarations().add(initializer); } else if (node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) node; if (i > 0 - && (nodes[i - 1] instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) - && ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration)nodes[i - 1]).declarationSourceStart == fieldDeclaration.declarationSourceStart) { + && (nodes[i - 1] instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) + && ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) nodes[i - 1]).declarationSourceStart == fieldDeclaration.declarationSourceStart) { // we have a multiple field declaration // We retrieve the existing fieldDeclaration to add the new VariableDeclarationFragment - FieldDeclaration currentFieldDeclaration = (FieldDeclaration) typeDecl.bodyDeclarations().get(typeDecl.bodyDeclarations().size() - 1); + FieldDeclaration currentFieldDeclaration = (FieldDeclaration) typeDecl.bodyDeclarations().get( + typeDecl.bodyDeclarations().size() - 1); currentFieldDeclaration.fragments().add(convertToVariableDeclarationFragment(fieldDeclaration)); } else { // we can create a new FieldDeclaration typeDecl.bodyDeclarations().add(convertToFieldDeclaration(fieldDeclaration)); } - } else if(node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration) { + } else if (node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration) { AbstractMethodDeclaration nextMethodDeclaration = (AbstractMethodDeclaration) node; if (!nextMethodDeclaration.isDefaultConstructor() && !nextMethodDeclaration.isClinit()) { typeDecl.bodyDeclarations().add(convert(nextMethodDeclaration)); } - } else if(node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { + } else if (node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration nextMemberDeclaration = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node; ASTNode nextMemberDeclarationNode = convert(nextMemberDeclaration); if (nextMemberDeclarationNode == null) { @@ -873,154 +890,158 @@ public class AjASTConverter extends ASTConverter { } return typeDecl; } - -// public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression expression) { -// InfixExpression infixExpression = new InfixExpression(this.ast); -// if (this.resolveBindings) { -// this.recordNodes(infixExpression, expression); -// } -// -// int expressionOperatorID = (expression.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT; -// switch (expressionOperatorID) { -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.EQUAL_EQUAL : -// infixExpression.setOperator(InfixExpression.Operator.EQUALS); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS_EQUAL : -// infixExpression.setOperator(InfixExpression.Operator.LESS_EQUALS); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER_EQUAL : -// infixExpression.setOperator(InfixExpression.Operator.GREATER_EQUALS); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.NOT_EQUAL : -// infixExpression.setOperator(InfixExpression.Operator.NOT_EQUALS); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT : -// infixExpression.setOperator(InfixExpression.Operator.LEFT_SHIFT); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT : -// infixExpression.setOperator(InfixExpression.Operator.RIGHT_SHIFT_SIGNED); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT : -// infixExpression.setOperator(InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR_OR : -// infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_OR); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND_AND : -// infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_AND); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS : -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS : -// infixExpression.setOperator(InfixExpression.Operator.MINUS); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER : -// infixExpression.setOperator(InfixExpression.Operator.REMAINDER); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR : -// infixExpression.setOperator(InfixExpression.Operator.XOR); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND : -// infixExpression.setOperator(InfixExpression.Operator.AND); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY : -// infixExpression.setOperator(InfixExpression.Operator.TIMES); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR : -// infixExpression.setOperator(InfixExpression.Operator.OR); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE : -// infixExpression.setOperator(InfixExpression.Operator.DIVIDE); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER : -// infixExpression.setOperator(InfixExpression.Operator.GREATER); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS : -// infixExpression.setOperator(InfixExpression.Operator.LESS); -// } -// -// if (expression.left instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression -// && ((expression.left.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) { -// // create an extended string literal equivalent => use the extended operands list -// infixExpression.extendedOperands().add(convert(expression.right)); -// org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression leftOperand = expression.left; -// org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression rightOperand = null; -// do { -// rightOperand = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) leftOperand).right; -// if ((((leftOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID -// && ((leftOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) -// || ((rightOperand instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression -// && ((rightOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID) -// && ((rightOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))) { -// List extendedOperands = infixExpression.extendedOperands(); -// InfixExpression temp = new InfixExpression(this.ast); -// if (this.resolveBindings) { -// this.recordNodes(temp, expression); -// } -// temp.setOperator(getOperatorFor(expressionOperatorID)); -// Expression leftSide = convert(leftOperand); -// temp.setLeftOperand(leftSide); -// temp.setSourceRange(leftSide.getStartPosition(), leftSide.getLength()); -// int size = extendedOperands.size(); -// for (int i = 0; i < size - 1; i++) { -// Expression expr = temp; -// temp = new InfixExpression(this.ast); -// -// if (this.resolveBindings) { -// this.recordNodes(temp, expression); -// } -// temp.setLeftOperand(expr); -// temp.setOperator(getOperatorFor(expressionOperatorID)); -// temp.setSourceRange(expr.getStartPosition(), expr.getLength()); -// } -// infixExpression = temp; -// for (int i = 0; i < size; i++) { -// Expression extendedOperand = (Expression) extendedOperands.remove(size - 1 - i); -// temp.setRightOperand(extendedOperand); -// int startPosition = temp.getLeftOperand().getStartPosition(); -// temp.setSourceRange(startPosition, extendedOperand.getStartPosition() + extendedOperand.getLength() - startPosition); -// if (temp.getLeftOperand().getNodeType() == ASTNode.INFIX_EXPRESSION) { -// temp = (InfixExpression) temp.getLeftOperand(); -// } -// } -// int startPosition = infixExpression.getLeftOperand().getStartPosition(); -// infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1); -// if (this.resolveBindings) { -// this.recordNodes(infixExpression, expression); -// } -// return infixExpression; -// } -// infixExpression.extendedOperands().add(0, convert(rightOperand)); -// leftOperand = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) leftOperand).left; -// } while (leftOperand instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression && ((leftOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)); -// Expression leftExpression = convert(leftOperand); -// infixExpression.setLeftOperand(leftExpression); -// infixExpression.setRightOperand((Expression)infixExpression.extendedOperands().remove(0)); -// int startPosition = leftExpression.getStartPosition(); -// infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1); -// return infixExpression; -// } else if (expression.left instanceof StringLiteralConcatenation -// && ((expression.left.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) { -// StringLiteralConcatenation literal = (StringLiteralConcatenation) expression.left; -// final org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] stringLiterals = literal.literals; -// infixExpression.setLeftOperand(convert(stringLiterals[0])); -// infixExpression.setRightOperand(convert(stringLiterals[1])); -// for (int i = 2; i < literal.counter; i++) { -// infixExpression.extendedOperands().add(convert(stringLiterals[i])); -// } -// infixExpression.extendedOperands().add(convert(expression.right)); -// int startPosition = literal.sourceStart; -// infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1); -// return infixExpression; -// } -// Expression leftExpression = convert(expression.left); -// infixExpression.setLeftOperand(leftExpression); -// infixExpression.setRightOperand(convert(expression.right)); -// int startPosition = leftExpression.getStartPosition(); -// infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1); -// return infixExpression; -// } + + // public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression expression) { + // InfixExpression infixExpression = new InfixExpression(this.ast); + // if (this.resolveBindings) { + // this.recordNodes(infixExpression, expression); + // } + // + // int expressionOperatorID = (expression.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT; + // switch (expressionOperatorID) { + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.EQUAL_EQUAL : + // infixExpression.setOperator(InfixExpression.Operator.EQUALS); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS_EQUAL : + // infixExpression.setOperator(InfixExpression.Operator.LESS_EQUALS); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER_EQUAL : + // infixExpression.setOperator(InfixExpression.Operator.GREATER_EQUALS); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.NOT_EQUAL : + // infixExpression.setOperator(InfixExpression.Operator.NOT_EQUALS); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT : + // infixExpression.setOperator(InfixExpression.Operator.LEFT_SHIFT); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT : + // infixExpression.setOperator(InfixExpression.Operator.RIGHT_SHIFT_SIGNED); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT : + // infixExpression.setOperator(InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR_OR : + // infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_OR); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND_AND : + // infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_AND); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS : + // infixExpression.setOperator(InfixExpression.Operator.PLUS); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS : + // infixExpression.setOperator(InfixExpression.Operator.MINUS); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER : + // infixExpression.setOperator(InfixExpression.Operator.REMAINDER); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR : + // infixExpression.setOperator(InfixExpression.Operator.XOR); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND : + // infixExpression.setOperator(InfixExpression.Operator.AND); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY : + // infixExpression.setOperator(InfixExpression.Operator.TIMES); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR : + // infixExpression.setOperator(InfixExpression.Operator.OR); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE : + // infixExpression.setOperator(InfixExpression.Operator.DIVIDE); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER : + // infixExpression.setOperator(InfixExpression.Operator.GREATER); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS : + // infixExpression.setOperator(InfixExpression.Operator.LESS); + // } + // + // if (expression.left instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression + // && ((expression.left.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) { + // // create an extended string literal equivalent => use the extended operands list + // infixExpression.extendedOperands().add(convert(expression.right)); + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression leftOperand = expression.left; + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression rightOperand = null; + // do { + // rightOperand = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) leftOperand).right; + // if ((((leftOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID + // && ((leftOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) + // || ((rightOperand instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression + // && ((rightOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID) + // && ((rightOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))) { + // List extendedOperands = infixExpression.extendedOperands(); + // InfixExpression temp = new InfixExpression(this.ast); + // if (this.resolveBindings) { + // this.recordNodes(temp, expression); + // } + // temp.setOperator(getOperatorFor(expressionOperatorID)); + // Expression leftSide = convert(leftOperand); + // temp.setLeftOperand(leftSide); + // temp.setSourceRange(leftSide.getStartPosition(), leftSide.getLength()); + // int size = extendedOperands.size(); + // for (int i = 0; i < size - 1; i++) { + // Expression expr = temp; + // temp = new InfixExpression(this.ast); + // + // if (this.resolveBindings) { + // this.recordNodes(temp, expression); + // } + // temp.setLeftOperand(expr); + // temp.setOperator(getOperatorFor(expressionOperatorID)); + // temp.setSourceRange(expr.getStartPosition(), expr.getLength()); + // } + // infixExpression = temp; + // for (int i = 0; i < size; i++) { + // Expression extendedOperand = (Expression) extendedOperands.remove(size - 1 - i); + // temp.setRightOperand(extendedOperand); + // int startPosition = temp.getLeftOperand().getStartPosition(); + // temp.setSourceRange(startPosition, extendedOperand.getStartPosition() + extendedOperand.getLength() - startPosition); + // if (temp.getLeftOperand().getNodeType() == ASTNode.INFIX_EXPRESSION) { + // temp = (InfixExpression) temp.getLeftOperand(); + // } + // } + // int startPosition = infixExpression.getLeftOperand().getStartPosition(); + // infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1); + // if (this.resolveBindings) { + // this.recordNodes(infixExpression, expression); + // } + // return infixExpression; + // } + // infixExpression.extendedOperands().add(0, convert(rightOperand)); + // leftOperand = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) leftOperand).left; + // } while (leftOperand instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression && ((leftOperand.bits & + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)); + // Expression leftExpression = convert(leftOperand); + // infixExpression.setLeftOperand(leftExpression); + // infixExpression.setRightOperand((Expression)infixExpression.extendedOperands().remove(0)); + // int startPosition = leftExpression.getStartPosition(); + // infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1); + // return infixExpression; + // } else if (expression.left instanceof StringLiteralConcatenation + // && ((expression.left.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) { + // StringLiteralConcatenation literal = (StringLiteralConcatenation) expression.left; + // final org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] stringLiterals = literal.literals; + // infixExpression.setLeftOperand(convert(stringLiterals[0])); + // infixExpression.setRightOperand(convert(stringLiterals[1])); + // for (int i = 2; i < literal.counter; i++) { + // infixExpression.extendedOperands().add(convert(stringLiterals[i])); + // } + // infixExpression.extendedOperands().add(convert(expression.right)); + // int startPosition = literal.sourceStart; + // infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1); + // return infixExpression; + // } + // Expression leftExpression = convert(expression.left); + // infixExpression.setLeftOperand(leftExpression); + // infixExpression.setRightOperand(convert(expression.right)); + // int startPosition = leftExpression.getStartPosition(); + // infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1); + // return infixExpression; + // } public Block convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Block statement) { Block block = new Block(this.ast); @@ -1035,13 +1056,13 @@ public class AjASTConverter extends ASTConverter { checkAndAddMultipleLocalDeclaration(statements, i, block.statements()); } else { block.statements().add(convert(statements[i])); - } + } } } return block; } - - public BreakStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.BreakStatement statement) { + + public BreakStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.BreakStatement statement) { BreakStatement breakStatement = new BreakStatement(this.ast); breakStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); if (statement.label != null) { @@ -1053,40 +1074,39 @@ public class AjASTConverter extends ASTConverter { retrieveSemiColonPosition(breakStatement); return breakStatement; } - - -// public SwitchCase convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CaseStatement statement) { -// SwitchCase switchCase = new SwitchCase(this.ast); -// org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression constantExpression = statement.constantExpression; -// if (constantExpression == null) { -// switchCase.setExpression(null); -// } else { -// switchCase.setExpression(convert(constantExpression)); -// } -// switchCase.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); -// retrieveColonPosition(switchCase); -// return switchCase; -// } - -// public CastExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression expression) { -// CastExpression castExpression = new CastExpression(this.ast); -// castExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); -// org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression type = expression.type; -// trimWhiteSpacesAndComments(type); -// if (type instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference ) { -// castExpression.setType(convertType((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference)type)); -// } else if (type instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference) { -// castExpression.setType(convertToType((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference)type)); -// } -// castExpression.setExpression(convert(expression.expression)); -// if (this.resolveBindings) { -// recordNodes(castExpression, expression); -// } -// return castExpression; -// } + + // public SwitchCase convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CaseStatement statement) { + // SwitchCase switchCase = new SwitchCase(this.ast); + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression constantExpression = statement.constantExpression; + // if (constantExpression == null) { + // switchCase.setExpression(null); + // } else { + // switchCase.setExpression(convert(constantExpression)); + // } + // switchCase.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); + // retrieveColonPosition(switchCase); + // return switchCase; + // } + + // public CastExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression expression) { + // CastExpression castExpression = new CastExpression(this.ast); + // castExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression type = expression.type; + // trimWhiteSpacesAndComments(type); + // if (type instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference ) { + // castExpression.setType(convertType((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference)type)); + // } else if (type instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference) { + // castExpression.setType(convertToType((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference)type)); + // } + // castExpression.setExpression(convert(expression.expression)); + // if (this.resolveBindings) { + // recordNodes(castExpression, expression); + // } + // return castExpression; + // } public CharacterLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral expression) { - int length = expression.sourceEnd - expression.sourceStart + 1; + int length = expression.sourceEnd - expression.sourceStart + 1; int sourceStart = expression.sourceStart; CharacterLiteral literal = new CharacterLiteral(this.ast); if (this.resolveBindings) { @@ -1097,6 +1117,7 @@ public class AjASTConverter extends ASTConverter { removeLeadingAndTrailingCommentsFromLiteral(literal); return literal; } + public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess expression) { TypeLiteral typeLiteral = new TypeLiteral(this.ast); if (this.resolveBindings) { @@ -1106,7 +1127,7 @@ public class AjASTConverter extends ASTConverter { typeLiteral.setType(convertType(expression.type)); return typeLiteral; } - + public CompilationUnit convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration unit, char[] source) { this.compilationUnitSource = source; this.compilationUnitSourceLength = source.length; @@ -1152,13 +1173,13 @@ public class AjASTConverter extends ASTConverter { } } } - compilationUnit.setSourceRange(unit.sourceStart, unit.sourceEnd - unit.sourceStart + 1); - + compilationUnit.setSourceRange(unit.sourceStart, unit.sourceEnd - unit.sourceStart + 1); + int problemLength = unit.compilationResult.problemCount; if (problemLength != 0) { CategorizedProblem[] resizedProblems = null; final CategorizedProblem[] problems = unit.compilationResult.getProblems(); - final int realProblemLength=problems.length; + final int realProblemLength = problems.length; if (realProblemLength == problemLength) { resizedProblems = problems; } else { @@ -1175,244 +1196,244 @@ public class AjASTConverter extends ASTConverter { return compilationUnit; } -// public Assignment convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompoundAssignment expression) { -// Assignment assignment = new Assignment(this.ast); -// Expression lhs = convert(expression.lhs); -// assignment.setLeftHandSide(lhs); -// int start = lhs.getStartPosition(); -// assignment.setSourceRange(start, expression.sourceEnd - start + 1); -// switch (expression.operator) { -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS : -// assignment.setOperator(Assignment.Operator.PLUS_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS : -// assignment.setOperator(Assignment.Operator.MINUS_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY : -// assignment.setOperator(Assignment.Operator.TIMES_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE : -// assignment.setOperator(Assignment.Operator.DIVIDE_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND : -// assignment.setOperator(Assignment.Operator.BIT_AND_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR : -// assignment.setOperator(Assignment.Operator.BIT_OR_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR : -// assignment.setOperator(Assignment.Operator.BIT_XOR_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER : -// assignment.setOperator(Assignment.Operator.REMAINDER_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT : -// assignment.setOperator(Assignment.Operator.LEFT_SHIFT_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT : -// assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_SIGNED_ASSIGN); -// break; -// case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT : -// assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN); -// break; -// } -// assignment.setRightHandSide(convert(expression.expression)); -// if (this.resolveBindings) { -// recordNodes(assignment, expression); -// } -// return assignment; -// } - -// public ConditionalExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConditionalExpression expression) { -// ConditionalExpression conditionalExpression = new ConditionalExpression(this.ast); -// if (this.resolveBindings) { -// recordNodes(conditionalExpression, expression); -// } -// conditionalExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); -// conditionalExpression.setExpression(convert(expression.condition)); -// conditionalExpression.setThenExpression(convert(expression.valueIfTrue)); -// conditionalExpression.setElseExpression(convert(expression.valueIfFalse)); -// return conditionalExpression; -// } - -// public Statement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall statement) { -// Statement newStatement; -// int sourceStart = statement.sourceStart; -// if (statement.isSuperAccess() || statement.isSuper()) { -// SuperConstructorInvocation superConstructorInvocation = new SuperConstructorInvocation(this.ast); -// if (statement.qualification != null) { -// superConstructorInvocation.setExpression(convert(statement.qualification)); -// } -// org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments; -// if (arguments != null) { -// int length = arguments.length; -// for (int i = 0; i < length; i++) { -// superConstructorInvocation.arguments().add(convert(arguments[i])); -// } -// } -// if (statement.typeArguments != null) { -// if (sourceStart > statement.typeArgumentsSourceStart) { -// sourceStart = statement.typeArgumentsSourceStart; -// } -// switch(this.ast.apiLevel) { -// case AST.JLS2_INTERNAL : -// superConstructorInvocation.setFlags(superConstructorInvocation.getFlags() | ASTNode.MALFORMED); -// break; -// case AST.JLS3 : -// for (int i = 0, max = statement.typeArguments.length; i < max; i++) { -// superConstructorInvocation.typeArguments().add(convertType(statement.typeArguments[i])); -// } -// break; -// } -// } -// newStatement = superConstructorInvocation; -// } else { -// ConstructorInvocation constructorInvocation = new ConstructorInvocation(this.ast); -// org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments; -// if (arguments != null) { -// int length = arguments.length; -// for (int i = 0; i < length; i++) { -// constructorInvocation.arguments().add(convert(arguments[i])); -// } -// } -// if (statement.typeArguments != null) { -// if (sourceStart > statement.typeArgumentsSourceStart) { -// sourceStart = statement.typeArgumentsSourceStart; -// } -// switch(this.ast.apiLevel) { -// case AST.JLS2_INTERNAL : -// constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED); -// break; -// case AST.JLS3 : -// for (int i = 0, max = statement.typeArguments.length; i < max; i++) { -// constructorInvocation.typeArguments().add(convertType(statement.typeArguments[i])); -// } -// break; -// } -// } -// if (statement.qualification != null) { -// // this is an error -// constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED); -// } -// newStatement = constructorInvocation; -// } -// newStatement.setSourceRange(sourceStart, statement.sourceEnd - sourceStart + 1); -// retrieveSemiColonPosition(newStatement); -// if (this.resolveBindings) { -// recordNodes(newStatement, statement); -// } -// return newStatement; -// } - -// public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression) { -// if ((expression.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) != 0) { -// return convertToParenthesizedExpression(expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression) expression); -// } -// // switch between all types of expression -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AllocationExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AllocationExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.PrefixExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.PrefixExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.PostfixExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.PostfixExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompoundAssignment) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompoundAssignment) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Assignment) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Assignment) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) expression); -// } -// if (expression instanceof StringLiteralConcatenation) { -// return convert((StringLiteralConcatenation) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.EqualExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.EqualExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.UnaryExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.UnaryExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConditionalExpression) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConditionalExpression) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Reference) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Reference) expression); -// } -// if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) { -// return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression); -// } -// return null; -// } + // public Assignment convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompoundAssignment expression) { + // Assignment assignment = new Assignment(this.ast); + // Expression lhs = convert(expression.lhs); + // assignment.setLeftHandSide(lhs); + // int start = lhs.getStartPosition(); + // assignment.setSourceRange(start, expression.sourceEnd - start + 1); + // switch (expression.operator) { + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS : + // assignment.setOperator(Assignment.Operator.PLUS_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS : + // assignment.setOperator(Assignment.Operator.MINUS_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY : + // assignment.setOperator(Assignment.Operator.TIMES_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE : + // assignment.setOperator(Assignment.Operator.DIVIDE_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND : + // assignment.setOperator(Assignment.Operator.BIT_AND_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR : + // assignment.setOperator(Assignment.Operator.BIT_OR_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR : + // assignment.setOperator(Assignment.Operator.BIT_XOR_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER : + // assignment.setOperator(Assignment.Operator.REMAINDER_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT : + // assignment.setOperator(Assignment.Operator.LEFT_SHIFT_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT : + // assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_SIGNED_ASSIGN); + // break; + // case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT : + // assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN); + // break; + // } + // assignment.setRightHandSide(convert(expression.expression)); + // if (this.resolveBindings) { + // recordNodes(assignment, expression); + // } + // return assignment; + // } + + // public ConditionalExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConditionalExpression expression) { + // ConditionalExpression conditionalExpression = new ConditionalExpression(this.ast); + // if (this.resolveBindings) { + // recordNodes(conditionalExpression, expression); + // } + // conditionalExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); + // conditionalExpression.setExpression(convert(expression.condition)); + // conditionalExpression.setThenExpression(convert(expression.valueIfTrue)); + // conditionalExpression.setElseExpression(convert(expression.valueIfFalse)); + // return conditionalExpression; + // } + + // public Statement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall statement) { + // Statement newStatement; + // int sourceStart = statement.sourceStart; + // if (statement.isSuperAccess() || statement.isSuper()) { + // SuperConstructorInvocation superConstructorInvocation = new SuperConstructorInvocation(this.ast); + // if (statement.qualification != null) { + // superConstructorInvocation.setExpression(convert(statement.qualification)); + // } + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments; + // if (arguments != null) { + // int length = arguments.length; + // for (int i = 0; i < length; i++) { + // superConstructorInvocation.arguments().add(convert(arguments[i])); + // } + // } + // if (statement.typeArguments != null) { + // if (sourceStart > statement.typeArgumentsSourceStart) { + // sourceStart = statement.typeArgumentsSourceStart; + // } + // switch(this.ast.apiLevel) { + // case AST.JLS2_INTERNAL : + // superConstructorInvocation.setFlags(superConstructorInvocation.getFlags() | ASTNode.MALFORMED); + // break; + // case AST.JLS3 : + // for (int i = 0, max = statement.typeArguments.length; i < max; i++) { + // superConstructorInvocation.typeArguments().add(convertType(statement.typeArguments[i])); + // } + // break; + // } + // } + // newStatement = superConstructorInvocation; + // } else { + // ConstructorInvocation constructorInvocation = new ConstructorInvocation(this.ast); + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments; + // if (arguments != null) { + // int length = arguments.length; + // for (int i = 0; i < length; i++) { + // constructorInvocation.arguments().add(convert(arguments[i])); + // } + // } + // if (statement.typeArguments != null) { + // if (sourceStart > statement.typeArgumentsSourceStart) { + // sourceStart = statement.typeArgumentsSourceStart; + // } + // switch(this.ast.apiLevel) { + // case AST.JLS2_INTERNAL : + // constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED); + // break; + // case AST.JLS3 : + // for (int i = 0, max = statement.typeArguments.length; i < max; i++) { + // constructorInvocation.typeArguments().add(convertType(statement.typeArguments[i])); + // } + // break; + // } + // } + // if (statement.qualification != null) { + // // this is an error + // constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED); + // } + // newStatement = constructorInvocation; + // } + // newStatement.setSourceRange(sourceStart, statement.sourceEnd - sourceStart + 1); + // retrieveSemiColonPosition(newStatement); + // if (this.resolveBindings) { + // recordNodes(newStatement, statement); + // } + // return newStatement; + // } + + // public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression) { + // if ((expression.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) != 0) { + // return convertToParenthesizedExpression(expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression) expression); + // } + // // switch between all types of expression + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AllocationExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AllocationExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.PrefixExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.PrefixExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.PostfixExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.PostfixExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompoundAssignment) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompoundAssignment) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Assignment) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Assignment) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) expression); + // } + // if (expression instanceof StringLiteralConcatenation) { + // return convert((StringLiteralConcatenation) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.EqualExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.EqualExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.UnaryExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.UnaryExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConditionalExpression) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConditionalExpression) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Reference) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Reference) expression); + // } + // if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) { + // return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression); + // } + // return null; + // } public StringLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral expression) { expression.computeConstant(); @@ -1426,15 +1447,15 @@ public class AjASTConverter extends ASTConverter { } public BooleanLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral expression) { - final BooleanLiteral literal = new BooleanLiteral(this.ast); + final BooleanLiteral literal = new BooleanLiteral(this.ast); literal.setBooleanValue(false); if (this.resolveBindings) { this.recordNodes(literal, expression); } literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); - return literal; + return literal; } - + public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference reference) { if (reference.receiver.isSuper()) { final SuperFieldAccess superFieldAccess = new SuperFieldAccess(this.ast); @@ -1450,14 +1471,15 @@ public class AjASTConverter extends ASTConverter { } final SimpleName simpleName = new SimpleName(this.ast); simpleName.internalSetIdentifier(new String(reference.token)); - int sourceStart = (int)(reference.nameSourcePosition>>>32); - int length = (int)(reference.nameSourcePosition & 0xFFFFFFFF) - sourceStart + 1; + int sourceStart = (int) (reference.nameSourcePosition >>> 32); + int length = (int) (reference.nameSourcePosition & 0xFFFFFFFF) - sourceStart + 1; simpleName.setSourceRange(sourceStart, length); superFieldAccess.setName(simpleName); if (this.resolveBindings) { recordNodes(simpleName, reference); } - superFieldAccess.setSourceRange(reference.receiver.sourceStart, reference.sourceEnd - reference.receiver.sourceStart + 1); + superFieldAccess.setSourceRange(reference.receiver.sourceStart, reference.sourceEnd - reference.receiver.sourceStart + + 1); return superFieldAccess; } else { final FieldAccess fieldAccess = new FieldAccess(this.ast); @@ -1468,8 +1490,8 @@ public class AjASTConverter extends ASTConverter { fieldAccess.setExpression(receiver); final SimpleName simpleName = new SimpleName(this.ast); simpleName.internalSetIdentifier(new String(reference.token)); - int sourceStart = (int)(reference.nameSourcePosition>>>32); - int length = (int)(reference.nameSourcePosition & 0xFFFFFFFF) - sourceStart + 1; + int sourceStart = (int) (reference.nameSourcePosition >>> 32); + int length = (int) (reference.nameSourcePosition & 0xFFFFFFFF) - sourceStart + 1; simpleName.setSourceRange(sourceStart, length); fieldAccess.setName(simpleName); if (this.resolveBindings) { @@ -1481,7 +1503,7 @@ public class AjASTConverter extends ASTConverter { } public NumberLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral expression) { - int length = expression.sourceEnd - expression.sourceStart + 1; + int length = expression.sourceEnd - expression.sourceStart + 1; int sourceStart = expression.sourceStart; NumberLiteral literal = new NumberLiteral(this.ast); literal.internalSetToken(new String(this.compilationUnitSource, sourceStart, length)); @@ -1492,25 +1514,25 @@ public class AjASTConverter extends ASTConverter { removeLeadingAndTrailingCommentsFromLiteral(literal); return literal; } - + public Statement convert(ForeachStatement statement) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - return createFakeEmptyStatement(statement); - case AST.JLS3 : - EnhancedForStatement enhancedForStatement = new EnhancedForStatement(this.ast); - enhancedForStatement.setParameter(convertToSingleVariableDeclaration(statement.elementVariable)); - enhancedForStatement.setExpression(super.convert(statement.collection)); - enhancedForStatement.setBody(convert(statement.action)); - int start = statement.sourceStart; - int end = statement.sourceEnd; - enhancedForStatement.setSourceRange(start, end - start + 1); - return enhancedForStatement; - default: - return createFakeEmptyStatement(statement); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + return createFakeEmptyStatement(statement); + case AST.JLS3: + EnhancedForStatement enhancedForStatement = new EnhancedForStatement(this.ast); + enhancedForStatement.setParameter(convertToSingleVariableDeclaration(statement.elementVariable)); + enhancedForStatement.setExpression(super.convert(statement.collection)); + enhancedForStatement.setBody(convert(statement.action)); + int start = statement.sourceStart; + int end = statement.sourceEnd; + enhancedForStatement.setSourceRange(start, end - start + 1); + return enhancedForStatement; + default: + return createFakeEmptyStatement(statement); } } - + public ForStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ForStatement statement) { ForStatement forStatement = new ForStatement(this.ast); forStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); @@ -1521,7 +1543,10 @@ public class AjASTConverter extends ASTConverter { VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) initializations[0]); int initializationsLength = initializations.length; for (int i = 1; i < initializationsLength; i++) { - variableDeclarationExpression.fragments().add(convertToVariableDeclarationFragment((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)initializations[i])); + variableDeclarationExpression + .fragments() + .add( + convertToVariableDeclarationFragment((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) initializations[i])); } if (initializationsLength != 1) { int start = variableDeclarationExpression.getStartPosition(); @@ -1548,13 +1573,13 @@ public class AjASTConverter extends ASTConverter { if (increments != null) { int incrementsLength = increments.length; for (int i = 0; i < incrementsLength; i++) { - forStatement.updaters().add(convertToExpression(increments[i])); + forStatement.updaters().add(convertToExpression(increments[i])); } } forStatement.setBody(convert(statement.action)); return forStatement; } - + public IfStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.IfStatement statement) { IfStatement ifStatement = new IfStatement(this.ast); ifStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); @@ -1565,7 +1590,7 @@ public class AjASTConverter extends ASTConverter { } return ifStatement; } - + public InstanceofExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression expression) { InstanceofExpression instanceOfExpression = new InstanceofExpression(this.ast); if (this.resolveBindings) { @@ -1580,7 +1605,7 @@ public class AjASTConverter extends ASTConverter { } public NumberLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral expression) { - int length = expression.sourceEnd - expression.sourceStart + 1; + int length = expression.sourceEnd - expression.sourceStart + 1; int sourceStart = expression.sourceStart; final NumberLiteral literal = new NumberLiteral(this.ast); literal.internalSetToken(new String(this.compilationUnitSource, sourceStart, length)); @@ -1593,7 +1618,7 @@ public class AjASTConverter extends ASTConverter { } public NumberLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue expression) { - int length = expression.sourceEnd - expression.sourceStart + 1; + int length = expression.sourceEnd - expression.sourceStart + 1; int sourceStart = expression.sourceStart; NumberLiteral literal = new NumberLiteral(this.ast); literal.internalSetToken(new String(this.compilationUnitSource, sourceStart, length)); @@ -1650,10 +1675,10 @@ public class AjASTConverter extends ASTConverter { } } } - + public LabeledStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LabeledStatement statement) { LabeledStatement labeledStatement = new LabeledStatement(this.ast); - labeledStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); + labeledStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement body = statement.statement; labeledStatement.setBody(convert(body)); final SimpleName name = new SimpleName(this.ast); @@ -1663,8 +1688,6 @@ public class AjASTConverter extends ASTConverter { return labeledStatement; } - - public InfixExpression convert(StringLiteralConcatenation expression) { expression.computeConstant(); final InfixExpression infixExpression = new InfixExpression(this.ast); @@ -1681,7 +1704,7 @@ public class AjASTConverter extends ASTConverter { infixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); return infixExpression; } - + public NormalAnnotation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.NormalAnnotation annotation) { final NormalAnnotation normalAnnotation = new NormalAnnotation(this.ast); setTypeNameForAnnotation(annotation, normalAnnotation); @@ -1706,7 +1729,7 @@ public class AjASTConverter extends ASTConverter { this.recordNodes(literal, expression); } literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); - return literal; + return literal; } public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression expression) { @@ -1731,12 +1754,12 @@ public class AjASTConverter extends ASTConverter { postfixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); postfixExpression.setOperand(super.convert(expression.lhs)); switch (expression.operator) { - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS : - postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT); - break; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS : - postfixExpression.setOperator(PostfixExpression.Operator.DECREMENT); - break; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS: + postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT); + break; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS: + postfixExpression.setOperator(PostfixExpression.Operator.DECREMENT); + break; } return postfixExpression; } @@ -1749,12 +1772,12 @@ public class AjASTConverter extends ASTConverter { prefixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); prefixExpression.setOperand(super.convert(expression.lhs)); switch (expression.operator) { - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS : - prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT); - break; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS : - prefixExpression.setOperator(PrefixExpression.Operator.DECREMENT); - break; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS: + prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT); + break; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS: + prefixExpression.setOperator(PrefixExpression.Operator.DECREMENT); + break; } return prefixExpression; } @@ -1764,12 +1787,12 @@ public class AjASTConverter extends ASTConverter { if (allocation.enclosingInstance != null) { classInstanceCreation.setExpression(super.convert(allocation.enclosingInstance)); } - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - classInstanceCreation.internalSetName(convert(allocation.type)); - break; - case AST.JLS3 : - classInstanceCreation.setType(convertType(allocation.type)); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + classInstanceCreation.internalSetName(convert(allocation.type)); + break; + case AST.JLS3: + classInstanceCreation.setType(convertType(allocation.type)); } org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = allocation.arguments; if (arguments != null) { @@ -1783,19 +1806,20 @@ public class AjASTConverter extends ASTConverter { } } if (allocation.typeArguments != null) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - classInstanceCreation.setFlags(classInstanceCreation.getFlags() | ASTNode.MALFORMED); - break; - case AST.JLS3 : - for (int i = 0, max = allocation.typeArguments.length; i < max; i++) { - classInstanceCreation.typeArguments().add(convertType(allocation.typeArguments[i])); - } - } + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + classInstanceCreation.setFlags(classInstanceCreation.getFlags() | ASTNode.MALFORMED); + break; + case AST.JLS3: + for (int i = 0, max = allocation.typeArguments.length; i < max; i++) { + classInstanceCreation.typeArguments().add(convertType(allocation.typeArguments[i])); + } + } } if (allocation.anonymousType != null) { int declarationSourceStart = allocation.sourceStart; - classInstanceCreation.setSourceRange(declarationSourceStart, allocation.anonymousType.bodyEnd - declarationSourceStart + 1); + classInstanceCreation.setSourceRange(declarationSourceStart, allocation.anonymousType.bodyEnd - declarationSourceStart + + 1); final AnonymousClassDeclaration anonymousClassDeclaration = new AnonymousClassDeclaration(this.ast); int start = retrieveStartBlockPosition(allocation.anonymousType.sourceEnd, allocation.anonymousType.bodyEnd); anonymousClassDeclaration.setSourceRange(start, allocation.anonymousType.bodyEnd - start + 1); @@ -1806,7 +1830,7 @@ public class AjASTConverter extends ASTConverter { recordNodes(anonymousClassDeclaration, allocation.anonymousType); anonymousClassDeclaration.resolveBinding(); } - return classInstanceCreation; + return classInstanceCreation; } else { final int start = allocation.sourceStart; classInstanceCreation.setSourceRange(start, allocation.sourceEnd - start + 1); @@ -1836,7 +1860,7 @@ public class AjASTConverter extends ASTConverter { } return thisExpression; } - + public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Reference reference) { if (reference instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference) { return super.convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference) reference); @@ -1852,17 +1876,17 @@ public class AjASTConverter extends ASTConverter { } return null; // cannot be reached } - + public ReturnStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ReturnStatement statement) { final ReturnStatement returnStatement = new ReturnStatement(this.ast); - returnStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); + returnStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); if (statement.expression != null) { returnStatement.setExpression(super.convert(statement.expression)); } retrieveSemiColonPosition(returnStatement); return returnStatement; } - + public SingleMemberAnnotation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation annotation) { final SingleMemberAnnotation singleMemberAnnotation = new SingleMemberAnnotation(this.ast); setTypeNameForAnnotation(annotation, singleMemberAnnotation); @@ -1891,7 +1915,7 @@ public class AjASTConverter extends ASTConverter { return convert((ForeachStatement) statement); } if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) { - return convertToVariableDeclarationStatement((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)statement); + return convertToVariableDeclarationStatement((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) statement); } if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AssertStatement) { return super.convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AssertStatement) statement); @@ -1946,50 +1970,50 @@ public class AjASTConverter extends ASTConverter { if (result == null) { return createFakeEmptyStatement(statement); } - switch(result.getNodeType()) { - case ASTNode.ENUM_DECLARATION: - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - return createFakeEmptyStatement(statement); - case AST.JLS3 : - final TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast); - typeDeclarationStatement.setDeclaration((EnumDeclaration) result); - AbstractTypeDeclaration typeDecl = typeDeclarationStatement.getDeclaration(); - typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength()); - return typeDeclarationStatement; - } - break; - case ASTNode.ANNOTATION_TYPE_DECLARATION : - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - return createFakeEmptyStatement(statement); - case AST.JLS3 : - TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast); - typeDeclarationStatement.setDeclaration((AnnotationTypeDeclaration) result); - AbstractTypeDeclaration typeDecl = typeDeclarationStatement.getDeclaration(); - typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength()); - return typeDeclarationStatement; - } - break; - default: - TypeDeclaration typeDeclaration = (TypeDeclaration) result; - if (typeDeclaration == null) { - return createFakeEmptyStatement(statement); - } else { - TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast); - typeDeclarationStatement.setDeclaration(typeDeclaration); - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - TypeDeclaration typeDecl = typeDeclarationStatement.internalGetTypeDeclaration(); - typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength()); - break; - case AST.JLS3 : - AbstractTypeDeclaration typeDeclAST3 = typeDeclarationStatement.getDeclaration(); - typeDeclarationStatement.setSourceRange(typeDeclAST3.getStartPosition(), typeDeclAST3.getLength()); - break; - } - return typeDeclarationStatement; + switch (result.getNodeType()) { + case ASTNode.ENUM_DECLARATION: + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + return createFakeEmptyStatement(statement); + case AST.JLS3: + final TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast); + typeDeclarationStatement.setDeclaration((EnumDeclaration) result); + AbstractTypeDeclaration typeDecl = typeDeclarationStatement.getDeclaration(); + typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength()); + return typeDeclarationStatement; + } + break; + case ASTNode.ANNOTATION_TYPE_DECLARATION: + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + return createFakeEmptyStatement(statement); + case AST.JLS3: + TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast); + typeDeclarationStatement.setDeclaration((AnnotationTypeDeclaration) result); + AbstractTypeDeclaration typeDecl = typeDeclarationStatement.getDeclaration(); + typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength()); + return typeDeclarationStatement; + } + break; + default: + TypeDeclaration typeDeclaration = (TypeDeclaration) result; + if (typeDeclaration == null) { + return createFakeEmptyStatement(statement); + } else { + TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast); + typeDeclarationStatement.setDeclaration(typeDeclaration); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + TypeDeclaration typeDecl = typeDeclarationStatement.internalGetTypeDeclaration(); + typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength()); + break; + case AST.JLS3: + AbstractTypeDeclaration typeDeclAST3 = typeDeclarationStatement.getDeclaration(); + typeDeclarationStatement.setSourceRange(typeDeclAST3.getStartPosition(), typeDeclAST3.getLength()); + break; } + return typeDeclarationStatement; + } } } if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.WhileStatement) { @@ -2010,7 +2034,7 @@ public class AjASTConverter extends ASTConverter { if (expression instanceof StringLiteralConcatenation) { return convert((StringLiteralConcatenation) expression); } - int length = expression.sourceEnd - expression.sourceStart + 1; + int length = expression.sourceEnd - expression.sourceStart + 1; int sourceStart = expression.sourceStart; StringLiteral literal = new StringLiteral(this.ast); if (this.resolveBindings) { @@ -2020,10 +2044,10 @@ public class AjASTConverter extends ASTConverter { literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); return literal; } - + public SwitchStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.SwitchStatement statement) { SwitchStatement switchStatement = new SwitchStatement(this.ast); - switchStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); + switchStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); switchStatement.setExpression(super.convert(statement.expression)); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = statement.statements; if (statements != null) { @@ -2034,15 +2058,15 @@ public class AjASTConverter extends ASTConverter { } return switchStatement; } - + public SynchronizedStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement statement) { SynchronizedStatement synchronizedStatement = new SynchronizedStatement(this.ast); - synchronizedStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); + synchronizedStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); synchronizedStatement.setBody(convert(statement.block)); synchronizedStatement.setExpression(super.convert(statement.expression)); return synchronizedStatement; } - + public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThisReference reference) { if (reference.isImplicitThis()) { // There is no source associated with an implicit this @@ -2051,7 +2075,7 @@ public class AjASTConverter extends ASTConverter { return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) reference); } else if (reference instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedThisReference) { return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedThisReference) reference); - } else { + } else { ThisExpression thisExpression = new ThisExpression(this.ast); thisExpression.setSourceRange(reference.sourceStart, reference.sourceEnd - reference.sourceStart + 1); if (this.resolveBindings) { @@ -2061,15 +2085,15 @@ public class AjASTConverter extends ASTConverter { return thisExpression; } } - + public ThrowStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThrowStatement statement) { final ThrowStatement throwStatement = new ThrowStatement(this.ast); - throwStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); + throwStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); throwStatement.setExpression(super.convert(statement.exception)); retrieveSemiColonPosition(throwStatement); return throwStatement; } - + public BooleanLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral expression) { final BooleanLiteral literal = new BooleanLiteral(this.ast); literal.setBooleanValue(true); @@ -2077,12 +2101,12 @@ public class AjASTConverter extends ASTConverter { this.recordNodes(literal, expression); } literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); - return literal; + return literal; } - + public TryStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TryStatement statement) { final TryStatement tryStatement = new TryStatement(this.ast); - tryStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); + tryStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); tryStatement.setBody(convert(statement.tryBlock)); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument[] catchArguments = statement.catchArguments; @@ -2093,7 +2117,7 @@ public class AjASTConverter extends ASTConverter { for (int i = 0; i < catchArgumentsLength; i++) { CatchClause catchClause = new CatchClause(this.ast); int catchClauseSourceStart = retrieveStartingCatchPosition(start, catchArguments[i].sourceStart); - catchClause.setSourceRange(catchClauseSourceStart, catchBlocks[i].sourceEnd - catchClauseSourceStart + 1); + catchClause.setSourceRange(catchClauseSourceStart, catchBlocks[i].sourceEnd - catchClauseSourceStart + 1); catchClause.setBody(convert(catchBlocks[i])); catchClause.setException(convert(catchArguments[i])); tryStatement.catchClauses().add(catchClause); @@ -2108,82 +2132,84 @@ public class AjASTConverter extends ASTConverter { public ASTNode convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) { switch (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.kind(typeDeclaration.modifiers)) { - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ENUM_DECL : - if (this.ast.apiLevel == AST.JLS2_INTERNAL) { - return null; - } else { - return convertToEnumDeclaration(typeDeclaration); - } - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ANNOTATION_TYPE_DECL : - if (this.ast.apiLevel == AST.JLS2_INTERNAL) { - return null; - } else { - return convertToAnnotationDeclaration(typeDeclaration); - } + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ENUM_DECL: + if (this.ast.apiLevel == AST.JLS2_INTERNAL) { + return null; + } else { + return convertToEnumDeclaration(typeDeclaration); + } + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ANNOTATION_TYPE_DECL: + if (this.ast.apiLevel == AST.JLS2_INTERNAL) { + return null; + } else { + return convertToAnnotationDeclaration(typeDeclaration); + } } checkCanceled(); TypeDeclaration typeDecl = TypeDeclaration.getTypeDeclaration(this.ast); - - //////////////// ajh02: added - if (typeDeclaration instanceof AspectDeclaration){ - org.aspectj.weaver.patterns.PerClause perClause = ((AspectDeclaration)typeDeclaration).perClause; - boolean isPrivileged = ((AspectDeclaration)typeDeclaration).isPrivileged; - if (perClause == null){ - typeDecl = new org.aspectj.org.eclipse.jdt.core.dom.AspectDeclaration(this.ast,null, isPrivileged); + + // ////////////// ajh02: added + if (typeDeclaration instanceof AspectDeclaration) { + org.aspectj.weaver.patterns.PerClause perClause = ((AspectDeclaration) typeDeclaration).perClause; + boolean isPrivileged = ((AspectDeclaration) typeDeclaration).isPrivileged; + if (perClause == null) { + typeDecl = new org.aspectj.org.eclipse.jdt.core.dom.AspectDeclaration(this.ast, null, isPrivileged); } else { - typeDecl = new org.aspectj.org.eclipse.jdt.core.dom.AspectDeclaration(this.ast,convert(perClause), isPrivileged); + typeDecl = new org.aspectj.org.eclipse.jdt.core.dom.AspectDeclaration(this.ast, convert(perClause), isPrivileged); } } - /////////////////////////////// - + // ///////////////////////////// + if (typeDeclaration.modifiersSourceStart != -1) { setModifiers(typeDecl, typeDeclaration); } - typeDecl.setInterface(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.kind(typeDeclaration.modifiers) == org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.INTERFACE_DECL); + typeDecl + .setInterface(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.kind(typeDeclaration.modifiers) == org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.INTERFACE_DECL); final SimpleName typeName = new SimpleName(this.ast); typeName.internalSetIdentifier(new String(typeDeclaration.name)); typeName.setSourceRange(typeDeclaration.sourceStart, typeDeclaration.sourceEnd - typeDeclaration.sourceStart + 1); typeDecl.setName(typeName); - typeDecl.setSourceRange(typeDeclaration.declarationSourceStart, typeDeclaration.bodyEnd - typeDeclaration.declarationSourceStart + 1); - + typeDecl.setSourceRange(typeDeclaration.declarationSourceStart, typeDeclaration.bodyEnd + - typeDeclaration.declarationSourceStart + 1); + // need to set the superclass and super interfaces here since we cannot distinguish them at // the type references level. if (typeDeclaration.superclass != null) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - typeDecl.internalSetSuperclass(convert(typeDeclaration.superclass)); - break; - case AST.JLS3 : - typeDecl.setSuperclassType(convertType(typeDeclaration.superclass)); - break; + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + typeDecl.internalSetSuperclass(convert(typeDeclaration.superclass)); + break; + case AST.JLS3: + typeDecl.setSuperclassType(convertType(typeDeclaration.superclass)); + break; } } - + org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference[] superInterfaces = typeDeclaration.superInterfaces; if (superInterfaces != null) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - for (int index = 0, length = superInterfaces.length; index < length; index++) { - typeDecl.internalSuperInterfaces().add(convert(superInterfaces[index])); - } - break; - case AST.JLS3 : - for (int index = 0, length = superInterfaces.length; index < length; index++) { - typeDecl.superInterfaceTypes().add(convertType(superInterfaces[index])); - } - } + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + for (int index = 0, length = superInterfaces.length; index < length; index++) { + typeDecl.internalSuperInterfaces().add(convert(superInterfaces[index])); + } + break; + case AST.JLS3: + for (int index = 0, length = superInterfaces.length; index < length; index++) { + typeDecl.superInterfaceTypes().add(convertType(superInterfaces[index])); + } + } } org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = typeDeclaration.typeParameters; if (typeParameters != null) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED); - break; - case AST.JLS3 : - for (int index = 0, length = typeParameters.length; index < length; index++) { - typeDecl.typeParameters().add(convert(typeParameters[index])); - } + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED); + break; + case AST.JLS3: + for (int index = 0, length = typeParameters.length; index < length; index++) { + typeDecl.typeParameters().add(convert(typeParameters[index])); + } } } buildBodyDeclarations(typeDeclaration, typeDecl); @@ -2229,14 +2255,14 @@ public class AjASTConverter extends ASTConverter { } return typeParameter2; } - + public Name convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference) { char[][] typeName = typeReference.getTypeName(); int length = typeName.length; if (length > 1) { // QualifiedName org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference qualifiedTypeReference = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference; - final long[] positions = qualifiedTypeReference.sourcePositions; + final long[] positions = qualifiedTypeReference.sourcePositions; return setQualifiedNameNameAndSourceRanges(typeName, positions, typeReference); } else { final SimpleName name = new SimpleName(this.ast); @@ -2248,10 +2274,9 @@ public class AjASTConverter extends ASTConverter { return name; } } - - - protected FieldDeclaration convertToFieldDeclaration(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDecl) { + protected FieldDeclaration convertToFieldDeclaration( + org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDecl) { VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(fieldDecl); final FieldDeclaration fieldDeclaration = new FieldDeclaration(this.ast); fieldDeclaration.fragments().add(variableDeclarationFragment); @@ -2260,7 +2285,8 @@ public class AjASTConverter extends ASTConverter { recordNodes(variableDeclarationFragment, fieldDecl); binding = variableDeclarationFragment.resolveBinding(); } - fieldDeclaration.setSourceRange(fieldDecl.declarationSourceStart, fieldDecl.declarationEnd - fieldDecl.declarationSourceStart + 1); + fieldDeclaration.setSourceRange(fieldDecl.declarationSourceStart, fieldDecl.declarationEnd + - fieldDecl.declarationSourceStart + 1); Type type = convertType(fieldDecl.type); setTypeForField(fieldDeclaration, type, variableDeclarationFragment.getExtraDimensions()); setModifiers(fieldDeclaration, fieldDecl); @@ -2270,43 +2296,48 @@ public class AjASTConverter extends ASTConverter { return fieldDeclaration; } -// public ParenthesizedExpression convertToParenthesizedExpression(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression) { -// final ParenthesizedExpression parenthesizedExpression = new ParenthesizedExpression(this.ast); -// if (this.resolveBindings) { -// recordNodes(parenthesizedExpression, expression); -// } -// parenthesizedExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); -// adjustSourcePositionsForParent(expression); -// trimWhiteSpacesAndComments(expression); -// // decrement the number of parenthesis -// int numberOfParenthesis = (expression.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) >> org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedSHIFT; -// expression.bits &= ~org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK; -// expression.bits |= (numberOfParenthesis - 1) << org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedSHIFT; -// parenthesizedExpression.setExpression(convert(expression)); -// return parenthesizedExpression; -// } - -// public Type convertToType(org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference reference) { -// Name name = convert(reference); -// final SimpleType type = new SimpleType(this.ast); -// type.setName(name); -// type.setSourceRange(name.getStartPosition(), name.getLength()); -// if (this.resolveBindings) { -// this.recordNodes(type, reference); -// } -// return type; -// } - - protected VariableDeclarationExpression convertToVariableDeclarationExpression(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) { + // public ParenthesizedExpression convertToParenthesizedExpression(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression + // expression) { + // final ParenthesizedExpression parenthesizedExpression = new ParenthesizedExpression(this.ast); + // if (this.resolveBindings) { + // recordNodes(parenthesizedExpression, expression); + // } + // parenthesizedExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); + // adjustSourcePositionsForParent(expression); + // trimWhiteSpacesAndComments(expression); + // // decrement the number of parenthesis + // int numberOfParenthesis = (expression.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) >> + // org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedSHIFT; + // expression.bits &= ~org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK; + // expression.bits |= (numberOfParenthesis - 1) << org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedSHIFT; + // parenthesizedExpression.setExpression(convert(expression)); + // return parenthesizedExpression; + // } + + // public Type convertToType(org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference reference) { + // Name name = convert(reference); + // final SimpleType type = new SimpleType(this.ast); + // type.setName(name); + // type.setSourceRange(name.getStartPosition(), name.getLength()); + // if (this.resolveBindings) { + // this.recordNodes(type, reference); + // } + // return type; + // } + + protected VariableDeclarationExpression convertToVariableDeclarationExpression( + org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) { final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration); final VariableDeclarationExpression variableDeclarationExpression = new VariableDeclarationExpression(this.ast); variableDeclarationExpression.fragments().add(variableDeclarationFragment); if (this.resolveBindings) { recordNodes(variableDeclarationFragment, localDeclaration); } - variableDeclarationExpression.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1); + variableDeclarationExpression.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd + - localDeclaration.declarationSourceStart + 1); Type type = convertType(localDeclaration.type); - setTypeForVariableDeclarationExpression(variableDeclarationExpression, type, variableDeclarationFragment.getExtraDimensions()); + setTypeForVariableDeclarationExpression(variableDeclarationExpression, type, variableDeclarationFragment + .getExtraDimensions()); if (localDeclaration.modifiersSourceStart != -1) { setModifiers(variableDeclarationExpression, localDeclaration); } @@ -2328,11 +2359,11 @@ public class AjASTConverter extends ASTConverter { int typeEnd = type.getStartPosition() + type.getLength() - 1; int rightEnd = Math.max(typeEnd, localDeclaration.declarationSourceEnd); /* - * There is extra work to do to set the proper type positions - * See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284 + * There is extra work to do to set the proper type positions See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284 */ setTypeForSingleVariableDeclaration(variableDecl, type, extraDimensions); - variableDecl.setSourceRange(localDeclaration.declarationSourceStart, rightEnd - localDeclaration.declarationSourceStart + 1); + variableDecl + .setSourceRange(localDeclaration.declarationSourceStart, rightEnd - localDeclaration.declarationSourceStart + 1); if (this.resolveBindings) { recordNodes(name, localDeclaration); recordNodes(variableDecl, localDeclaration); @@ -2340,7 +2371,7 @@ public class AjASTConverter extends ASTConverter { } return variableDecl; } - + protected VariableDeclarationFragment convertToVariableDeclarationFragment(InterTypeFieldDeclaration fieldDeclaration) { // ajh02: method added final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment(this.ast); @@ -2356,12 +2387,14 @@ public class AjASTConverter extends ASTConverter { } int end = retrievePositionBeforeNextCommaOrSemiColon(start, fieldDeclaration.declarationSourceEnd); if (end == -1) { - variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, fieldDeclaration.declarationSourceEnd - fieldDeclaration.sourceStart + 1); + variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, fieldDeclaration.declarationSourceEnd + - fieldDeclaration.sourceStart + 1); variableDeclarationFragment.setFlags(variableDeclarationFragment.getFlags() | ASTNode.MALFORMED); } else { variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, end - fieldDeclaration.sourceStart + 1); } - variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(fieldDeclaration.sourceEnd + 1, fieldDeclaration.declarationSourceEnd )); + variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(fieldDeclaration.sourceEnd + 1, + fieldDeclaration.declarationSourceEnd)); if (this.resolveBindings) { recordNodes(name, fieldDeclaration); recordNodes(variableDeclarationFragment, fieldDeclaration); @@ -2369,8 +2402,9 @@ public class AjASTConverter extends ASTConverter { } return variableDeclarationFragment; } - - protected VariableDeclarationFragment convertToVariableDeclarationFragment(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) { + + protected VariableDeclarationFragment convertToVariableDeclarationFragment( + org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) { final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment(this.ast); final SimpleName name = new SimpleName(this.ast); name.internalSetIdentifier(new String(fieldDeclaration.name)); @@ -2384,12 +2418,14 @@ public class AjASTConverter extends ASTConverter { } int end = retrievePositionBeforeNextCommaOrSemiColon(start, fieldDeclaration.declarationSourceEnd); if (end == -1) { - variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, fieldDeclaration.declarationSourceEnd - fieldDeclaration.sourceStart + 1); + variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, fieldDeclaration.declarationSourceEnd + - fieldDeclaration.sourceStart + 1); variableDeclarationFragment.setFlags(variableDeclarationFragment.getFlags() | ASTNode.MALFORMED); } else { variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, end - fieldDeclaration.sourceStart + 1); } - variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(fieldDeclaration.sourceEnd + 1, fieldDeclaration.declarationSourceEnd )); + variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(fieldDeclaration.sourceEnd + 1, + fieldDeclaration.declarationSourceEnd)); if (this.resolveBindings) { recordNodes(name, fieldDeclaration); recordNodes(variableDeclarationFragment, fieldDeclaration); @@ -2398,7 +2434,8 @@ public class AjASTConverter extends ASTConverter { return variableDeclarationFragment; } - protected VariableDeclarationFragment convertToVariableDeclarationFragment(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) { + protected VariableDeclarationFragment convertToVariableDeclarationFragment( + org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) { final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment(this.ast); final SimpleName name = new SimpleName(this.ast); name.internalSetIdentifier(new String(localDeclaration.name)); @@ -2413,14 +2450,17 @@ public class AjASTConverter extends ASTConverter { int end = retrievePositionBeforeNextCommaOrSemiColon(start, localDeclaration.declarationSourceEnd); if (end == -1) { if (localDeclaration.initialization != null) { - variableDeclarationFragment.setSourceRange(localDeclaration.sourceStart, localDeclaration.initialization.sourceEnd - localDeclaration.sourceStart + 1); + variableDeclarationFragment.setSourceRange(localDeclaration.sourceStart, localDeclaration.initialization.sourceEnd + - localDeclaration.sourceStart + 1); } else { - variableDeclarationFragment.setSourceRange(localDeclaration.sourceStart, localDeclaration.sourceEnd - localDeclaration.sourceStart + 1); + variableDeclarationFragment.setSourceRange(localDeclaration.sourceStart, localDeclaration.sourceEnd + - localDeclaration.sourceStart + 1); } } else { variableDeclarationFragment.setSourceRange(localDeclaration.sourceStart, end - localDeclaration.sourceStart + 1); } - variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(localDeclaration.sourceEnd + 1, this.compilationUnitSourceLength)); + variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(localDeclaration.sourceEnd + 1, + this.compilationUnitSourceLength)); if (this.resolveBindings) { recordNodes(variableDeclarationFragment, localDeclaration); recordNodes(name, localDeclaration); @@ -2429,14 +2469,16 @@ public class AjASTConverter extends ASTConverter { return variableDeclarationFragment; } - protected VariableDeclarationStatement convertToVariableDeclarationStatement(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) { + protected VariableDeclarationStatement convertToVariableDeclarationStatement( + org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) { final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration); final VariableDeclarationStatement variableDeclarationStatement = new VariableDeclarationStatement(this.ast); variableDeclarationStatement.fragments().add(variableDeclarationFragment); if (this.resolveBindings) { recordNodes(variableDeclarationFragment, localDeclaration); } - variableDeclarationStatement.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1); + variableDeclarationStatement.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd + - localDeclaration.declarationSourceStart + 1); Type type = convertType(localDeclaration.type); setTypeForVariableDeclarationStatement(variableDeclarationStatement, type, variableDeclarationFragment.getExtraDimensions()); if (localDeclaration.modifiersSourceStart != -1) { @@ -2464,7 +2506,7 @@ public class AjASTConverter extends ASTConverter { } return wildcardType; } - Type type = null; + Type type = null; int sourceStart = -1; int length = 0; int dimensions = typeReference.dimensions(); @@ -2478,7 +2520,7 @@ public class AjASTConverter extends ASTConverter { int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length); if (end == -1) { end = sourceStart + length - 1; - } + } final PrimitiveType primitiveType = new PrimitiveType(this.ast); primitiveType.setPrimitiveTypeCode(getPrimitiveTypeCode(name)); primitiveType.setSourceRange(sourceStart, end - sourceStart + 1); @@ -2492,41 +2534,41 @@ public class AjASTConverter extends ASTConverter { end = sourceStart + length - 1; } simpleName.setSourceRange(sourceStart, end - sourceStart + 1); - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - SimpleType simpleType = new SimpleType(this.ast); - simpleType.setName(simpleName); - simpleType.setFlags(simpleType.getFlags() | ASTNode.MALFORMED); - simpleType.setSourceRange(sourceStart, end - sourceStart + 1); - type = simpleType; - if (this.resolveBindings) { - this.recordNodes(simpleName, typeReference); - } - break; - case AST.JLS3 : - simpleType = new SimpleType(this.ast); - simpleType.setName(simpleName); - simpleType.setSourceRange(simpleName.getStartPosition(), simpleName.getLength()); - final ParameterizedType parameterizedType = new ParameterizedType(this.ast); - parameterizedType.setType(simpleType); - type = parameterizedType; - TypeReference[] typeArguments = parameterizedSingleTypeReference.typeArguments; - if (typeArguments != null) { - Type type2 = null; - for (int i = 0, max = typeArguments.length; i < max; i++) { - type2 = convertType(typeArguments[i]); - ((ParameterizedType) type).typeArguments().add(type2); - end = type2.getStartPosition() + type2.getLength() - 1; - } - end = retrieveClosingAngleBracketPosition(end + 1); - type.setSourceRange(sourceStart, end - sourceStart + 1); - } else { - type.setSourceRange(sourceStart, end - sourceStart + 1); - } - if (this.resolveBindings) { - this.recordNodes(simpleName, typeReference); - this.recordNodes(simpleType, typeReference); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + SimpleType simpleType = new SimpleType(this.ast); + simpleType.setName(simpleName); + simpleType.setFlags(simpleType.getFlags() | ASTNode.MALFORMED); + simpleType.setSourceRange(sourceStart, end - sourceStart + 1); + type = simpleType; + if (this.resolveBindings) { + this.recordNodes(simpleName, typeReference); + } + break; + case AST.JLS3: + simpleType = new SimpleType(this.ast); + simpleType.setName(simpleName); + simpleType.setSourceRange(simpleName.getStartPosition(), simpleName.getLength()); + final ParameterizedType parameterizedType = new ParameterizedType(this.ast); + parameterizedType.setType(simpleType); + type = parameterizedType; + TypeReference[] typeArguments = parameterizedSingleTypeReference.typeArguments; + if (typeArguments != null) { + Type type2 = null; + for (int i = 0, max = typeArguments.length; i < max; i++) { + type2 = convertType(typeArguments[i]); + ((ParameterizedType) type).typeArguments().add(type2); + end = type2.getStartPosition() + type2.getLength() - 1; } + end = retrieveClosingAngleBracketPosition(end + 1); + type.setSourceRange(sourceStart, end - sourceStart + 1); + } else { + type.setSourceRange(sourceStart, end - sourceStart + 1); + } + if (this.resolveBindings) { + this.recordNodes(simpleName, typeReference); + this.recordNodes(simpleType, typeReference); + } } } else { final SimpleName simpleName = new SimpleName(this.ast); @@ -2569,128 +2611,130 @@ public class AjASTConverter extends ASTConverter { char[][] tokens = parameterizedQualifiedTypeReference.tokens; TypeReference[][] typeArguments = parameterizedQualifiedTypeReference.typeArguments; long[] positions = parameterizedQualifiedTypeReference.sourcePositions; - sourceStart = (int)(positions[0]>>>32); - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : { - char[][] name = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference).getTypeName(); - int nameLength = name.length; - sourceStart = (int)(positions[0]>>>32); - length = (int)(positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1; - Name qualifiedName = this.setQualifiedNameNameAndSourceRanges(name, positions, typeReference); - final SimpleType simpleType = new SimpleType(this.ast); - simpleType.setName(qualifiedName); - simpleType.setSourceRange(sourceStart, length); - type = simpleType; + sourceStart = (int) (positions[0] >>> 32); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: { + char[][] name = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference) + .getTypeName(); + int nameLength = name.length; + sourceStart = (int) (positions[0] >>> 32); + length = (int) (positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1; + Name qualifiedName = this.setQualifiedNameNameAndSourceRanges(name, positions, typeReference); + final SimpleType simpleType = new SimpleType(this.ast); + simpleType.setName(qualifiedName); + simpleType.setSourceRange(sourceStart, length); + type = simpleType; + } + break; + case AST.JLS3: + if (typeArguments != null) { + int numberOfEnclosingType = 0; + int startingIndex = 0; + int endingIndex = 0; + for (int i = 0, max = typeArguments.length; i < max; i++) { + if (typeArguments[i] != null) { + numberOfEnclosingType++; + } else if (numberOfEnclosingType == 0) { + endingIndex++; + } } - break; - case AST.JLS3 : - if (typeArguments != null) { - int numberOfEnclosingType = 0; - int startingIndex = 0; - int endingIndex = 0; - for (int i = 0, max = typeArguments.length; i < max; i++) { - if (typeArguments[i] != null) { - numberOfEnclosingType++; - } else if (numberOfEnclosingType == 0) { - endingIndex++; - } + Name name = null; + if (endingIndex - startingIndex == 0) { + final SimpleName simpleName = new SimpleName(this.ast); + simpleName.internalSetIdentifier(new String(tokens[startingIndex])); + recordPendingNameScopeResolution(simpleName); + int start = (int) (positions[startingIndex] >>> 32); + int end = (int) positions[startingIndex]; + simpleName.setSourceRange(start, end - start + 1); + simpleName.index = 1; + name = simpleName; + if (this.resolveBindings) { + recordNodes(simpleName, typeReference); + } + } else { + name = this.setQualifiedNameNameAndSourceRanges(tokens, positions, endingIndex, typeReference); + } + SimpleType simpleType = new SimpleType(this.ast); + simpleType.setName(name); + int start = (int) (positions[startingIndex] >>> 32); + int end = (int) positions[endingIndex]; + simpleType.setSourceRange(start, end - start + 1); + ParameterizedType parameterizedType = new ParameterizedType(this.ast); + parameterizedType.setType(simpleType); + if (this.resolveBindings) { + recordNodes(simpleType, typeReference); + recordNodes(parameterizedType, typeReference); + } + start = simpleType.getStartPosition(); + end = start + simpleType.getLength() - 1; + for (int i = 0, max = typeArguments[endingIndex].length; i < max; i++) { + final Type type2 = convertType(typeArguments[endingIndex][i]); + parameterizedType.typeArguments().add(type2); + end = type2.getStartPosition() + type2.getLength() - 1; + } + int indexOfEnclosingType = 1; + parameterizedType.index = indexOfEnclosingType; + end = retrieveClosingAngleBracketPosition(end + 1); + length = end + 1; + parameterizedType.setSourceRange(start, end - start + 1); + startingIndex = endingIndex + 1; + Type currentType = parameterizedType; + while (startingIndex < typeArguments.length) { + SimpleName simpleName = new SimpleName(this.ast); + simpleName.internalSetIdentifier(new String(tokens[startingIndex])); + simpleName.index = startingIndex + 1; + start = (int) (positions[startingIndex] >>> 32); + end = (int) positions[startingIndex]; + simpleName.setSourceRange(start, end - start + 1); + recordPendingNameScopeResolution(simpleName); + QualifiedType qualifiedType = new QualifiedType(this.ast); + qualifiedType.setQualifier(currentType); + qualifiedType.setName(simpleName); + if (this.resolveBindings) { + recordNodes(simpleName, typeReference); + recordNodes(qualifiedType, typeReference); } - Name name = null; - if (endingIndex - startingIndex == 0) { - final SimpleName simpleName = new SimpleName(this.ast); - simpleName.internalSetIdentifier(new String(tokens[startingIndex])); - recordPendingNameScopeResolution(simpleName); - int start = (int)(positions[startingIndex]>>>32); - int end = (int) positions[startingIndex]; - simpleName.setSourceRange(start, end - start + 1); - simpleName.index = 1; - name = simpleName; + start = currentType.getStartPosition(); + end = simpleName.getStartPosition() + simpleName.getLength() - 1; + qualifiedType.setSourceRange(start, end - start + 1); + indexOfEnclosingType++; + if (typeArguments[startingIndex] != null) { + qualifiedType.index = indexOfEnclosingType; + ParameterizedType parameterizedType2 = new ParameterizedType(this.ast); + parameterizedType2.setType(qualifiedType); + parameterizedType2.index = indexOfEnclosingType; if (this.resolveBindings) { - recordNodes(simpleName, typeReference); + recordNodes(parameterizedType2, typeReference); } - } else { - name = this.setQualifiedNameNameAndSourceRanges(tokens, positions, endingIndex, typeReference); - } - SimpleType simpleType = new SimpleType(this.ast); - simpleType.setName(name); - int start = (int)(positions[startingIndex]>>>32); - int end = (int) positions[endingIndex]; - simpleType.setSourceRange(start, end - start + 1); - ParameterizedType parameterizedType = new ParameterizedType(this.ast); - parameterizedType.setType(simpleType); - if (this.resolveBindings) { - recordNodes(simpleType, typeReference); - recordNodes(parameterizedType, typeReference); - } - start = simpleType.getStartPosition(); - end = start + simpleType.getLength() - 1; - for (int i = 0, max = typeArguments[endingIndex].length; i < max; i++) { - final Type type2 = convertType(typeArguments[endingIndex][i]); - parameterizedType.typeArguments().add(type2); - end = type2.getStartPosition() + type2.getLength() - 1; - } - int indexOfEnclosingType = 1; - parameterizedType.index = indexOfEnclosingType; - end = retrieveClosingAngleBracketPosition(end + 1); - length = end + 1; - parameterizedType.setSourceRange(start, end - start + 1); - startingIndex = endingIndex + 1; - Type currentType = parameterizedType; - while(startingIndex < typeArguments.length) { - SimpleName simpleName = new SimpleName(this.ast); - simpleName.internalSetIdentifier(new String(tokens[startingIndex])); - simpleName.index = startingIndex + 1; - start = (int)(positions[startingIndex]>>>32); - end = (int) positions[startingIndex]; - simpleName.setSourceRange(start, end - start + 1); - recordPendingNameScopeResolution(simpleName); - QualifiedType qualifiedType = new QualifiedType(this.ast); - qualifiedType.setQualifier(currentType); - qualifiedType.setName(simpleName); - if (this.resolveBindings) { - recordNodes(simpleName, typeReference); - recordNodes(qualifiedType, typeReference); - } - start = currentType.getStartPosition(); - end = simpleName.getStartPosition() + simpleName.getLength() - 1; - qualifiedType.setSourceRange(start, end - start + 1); - indexOfEnclosingType++; - if (typeArguments[startingIndex] != null) { - qualifiedType.index = indexOfEnclosingType; - ParameterizedType parameterizedType2 = new ParameterizedType(this.ast); - parameterizedType2.setType(qualifiedType); - parameterizedType2.index = indexOfEnclosingType; - if (this.resolveBindings) { - recordNodes(parameterizedType2, typeReference); - } - for (int i = 0, max = typeArguments[startingIndex].length; i < max; i++) { - final Type type2 = convertType(typeArguments[startingIndex][i]); - parameterizedType2.typeArguments().add(type2); - end = type2.getStartPosition() + type2.getLength() - 1; - } - end = retrieveClosingAngleBracketPosition(end + 1); - length = end + 1; - parameterizedType2.setSourceRange(start, end - start + 1); - currentType = parameterizedType2; - } else { - currentType = qualifiedType; - qualifiedType.index = indexOfEnclosingType; + for (int i = 0, max = typeArguments[startingIndex].length; i < max; i++) { + final Type type2 = convertType(typeArguments[startingIndex][i]); + parameterizedType2.typeArguments().add(type2); + end = type2.getStartPosition() + type2.getLength() - 1; } - startingIndex++; - } - if (this.resolveBindings) { - this.recordNodes(currentType, typeReference); + end = retrieveClosingAngleBracketPosition(end + 1); + length = end + 1; + parameterizedType2.setSourceRange(start, end - start + 1); + currentType = parameterizedType2; + } else { + currentType = qualifiedType; + qualifiedType.index = indexOfEnclosingType; } - type = currentType; - length -= sourceStart; + startingIndex++; + } + if (this.resolveBindings) { + this.recordNodes(currentType, typeReference); } + type = currentType; + length -= sourceStart; + } } } else { - char[][] name = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference).getTypeName(); + char[][] name = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference) + .getTypeName(); int nameLength = name.length; long[] positions = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference).sourcePositions; - sourceStart = (int)(positions[0]>>>32); - length = (int)(positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1; + sourceStart = (int) (positions[0] >>> 32); + length = (int) (positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1; final Name qualifiedName = this.setQualifiedNameNameAndSourceRanges(name, positions, typeReference); final SimpleType simpleType = new SimpleType(this.ast); simpleType.setName(qualifiedName); @@ -2703,7 +2747,7 @@ public class AjASTConverter extends ASTConverter { if (this.resolveBindings) { completeRecord((ArrayType) type, typeReference); } - int end = retrieveEndOfDimensionsPosition(sourceStart+length, this.compilationUnitSourceLength); + int end = retrieveEndOfDimensionsPosition(sourceStart + length, this.compilationUnitSourceLength); if (end != -1) { type.setSourceRange(sourceStart, end - sourceStart + 1); } else { @@ -2730,13 +2774,14 @@ public class AjASTConverter extends ASTConverter { Comment comment = null; int start = positions[0]; int end = positions[1]; - if (positions[1]>0) { // Javadoc comments have positive end position + if (positions[1] > 0) { // Javadoc comments have positive end position Javadoc docComment = this.docParser.parse(positions); - if (docComment == null) return null; + if (docComment == null) + return null; comment = docComment; } else { end = -end; - if (positions[0]>0) { // Block comment have positive start position + if (positions[0] > 0) { // Block comment have positive start position comment = new BlockComment(this.ast); } else { // Line comment have negative start and end position start = -start; @@ -2746,7 +2791,7 @@ public class AjASTConverter extends ASTConverter { } return comment; } - + protected Statement createFakeEmptyStatement(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement statement) { EmptyStatement emptyStatement = new EmptyStatement(this.ast); emptyStatement.setFlags(emptyStatement.getFlags() | ASTNode.MALFORMED); @@ -2755,6 +2800,7 @@ public class AjASTConverter extends ASTConverter { emptyStatement.setSourceRange(start, end - start + 1); return emptyStatement; } + /** * @return a new modifier */ @@ -2766,226 +2812,168 @@ public class AjASTConverter extends ASTConverter { modifier.setSourceRange(start, end - start + 1); return modifier; } - + protected InfixExpression.Operator getOperatorFor(int operatorID) { switch (operatorID) { - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.EQUAL_EQUAL : - return InfixExpression.Operator.EQUALS; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS_EQUAL : - return InfixExpression.Operator.LESS_EQUALS; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER_EQUAL : - return InfixExpression.Operator.GREATER_EQUALS; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.NOT_EQUAL : - return InfixExpression.Operator.NOT_EQUALS; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT : - return InfixExpression.Operator.LEFT_SHIFT; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT : - return InfixExpression.Operator.RIGHT_SHIFT_SIGNED; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT : - return InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR_OR : - return InfixExpression.Operator.CONDITIONAL_OR; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND_AND : - return InfixExpression.Operator.CONDITIONAL_AND; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS : - return InfixExpression.Operator.PLUS; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS : - return InfixExpression.Operator.MINUS; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER : - return InfixExpression.Operator.REMAINDER; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR : - return InfixExpression.Operator.XOR; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND : - return InfixExpression.Operator.AND; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY : - return InfixExpression.Operator.TIMES; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR : - return InfixExpression.Operator.OR; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE : - return InfixExpression.Operator.DIVIDE; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER : - return InfixExpression.Operator.GREATER; - case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS : - return InfixExpression.Operator.LESS; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.EQUAL_EQUAL: + return InfixExpression.Operator.EQUALS; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS_EQUAL: + return InfixExpression.Operator.LESS_EQUALS; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER_EQUAL: + return InfixExpression.Operator.GREATER_EQUALS; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.NOT_EQUAL: + return InfixExpression.Operator.NOT_EQUALS; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT: + return InfixExpression.Operator.LEFT_SHIFT; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT: + return InfixExpression.Operator.RIGHT_SHIFT_SIGNED; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT: + return InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR_OR: + return InfixExpression.Operator.CONDITIONAL_OR; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND_AND: + return InfixExpression.Operator.CONDITIONAL_AND; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS: + return InfixExpression.Operator.PLUS; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS: + return InfixExpression.Operator.MINUS; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER: + return InfixExpression.Operator.REMAINDER; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR: + return InfixExpression.Operator.XOR; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND: + return InfixExpression.Operator.AND; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY: + return InfixExpression.Operator.TIMES; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR: + return InfixExpression.Operator.OR; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE: + return InfixExpression.Operator.DIVIDE; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER: + return InfixExpression.Operator.GREATER; + case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS: + return InfixExpression.Operator.LESS; } return null; } - + protected PrimitiveType.Code getPrimitiveTypeCode(char[] name) { - switch(name[0]) { - case 'i' : - if (name.length == 3 && name[1] == 'n' && name[2] == 't') { - return PrimitiveType.INT; - } - break; - case 'l' : - if (name.length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g') { - return PrimitiveType.LONG; - } - break; - case 'd' : - if (name.length == 6 - && name[1] == 'o' - && name[2] == 'u' - && name[3] == 'b' - && name[4] == 'l' - && name[5] == 'e') { - return PrimitiveType.DOUBLE; - } - break; - case 'f' : - if (name.length == 5 - && name[1] == 'l' - && name[2] == 'o' - && name[3] == 'a' - && name[4] == 't') { - return PrimitiveType.FLOAT; - } - break; - case 'b' : - if (name.length == 4 - && name[1] == 'y' - && name[2] == 't' - && name[3] == 'e') { - return PrimitiveType.BYTE; - } else - if (name.length == 7 - && name[1] == 'o' - && name[2] == 'o' - && name[3] == 'l' - && name[4] == 'e' - && name[5] == 'a' - && name[6] == 'n') { - return PrimitiveType.BOOLEAN; - } - break; - case 'c' : - if (name.length == 4 - && name[1] == 'h' - && name[2] == 'a' - && name[3] == 'r') { - return PrimitiveType.CHAR; - } - break; - case 's' : - if (name.length == 5 - && name[1] == 'h' - && name[2] == 'o' - && name[3] == 'r' - && name[4] == 't') { - return PrimitiveType.SHORT; - } - break; - case 'v' : - if (name.length == 4 - && name[1] == 'o' - && name[2] == 'i' - && name[3] == 'd') { - return PrimitiveType.VOID; - } + switch (name[0]) { + case 'i': + if (name.length == 3 && name[1] == 'n' && name[2] == 't') { + return PrimitiveType.INT; + } + break; + case 'l': + if (name.length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g') { + return PrimitiveType.LONG; + } + break; + case 'd': + if (name.length == 6 && name[1] == 'o' && name[2] == 'u' && name[3] == 'b' && name[4] == 'l' && name[5] == 'e') { + return PrimitiveType.DOUBLE; + } + break; + case 'f': + if (name.length == 5 && name[1] == 'l' && name[2] == 'o' && name[3] == 'a' && name[4] == 't') { + return PrimitiveType.FLOAT; + } + break; + case 'b': + if (name.length == 4 && name[1] == 'y' && name[2] == 't' && name[3] == 'e') { + return PrimitiveType.BYTE; + } else if (name.length == 7 && name[1] == 'o' && name[2] == 'o' && name[3] == 'l' && name[4] == 'e' && name[5] == 'a' + && name[6] == 'n') { + return PrimitiveType.BOOLEAN; + } + break; + case 'c': + if (name.length == 4 && name[1] == 'h' && name[2] == 'a' && name[3] == 'r') { + return PrimitiveType.CHAR; + } + break; + case 's': + if (name.length == 5 && name[1] == 'h' && name[2] == 'o' && name[3] == 'r' && name[4] == 't') { + return PrimitiveType.SHORT; + } + break; + case 'v': + if (name.length == 4 && name[1] == 'o' && name[2] == 'i' && name[3] == 'd') { + return PrimitiveType.VOID; + } } return null; // cannot be reached } - + protected boolean isPrimitiveType(char[] name) { - switch(name[0]) { - case 'i' : - if (name.length == 3 && name[1] == 'n' && name[2] == 't') { - return true; - } - return false; - case 'l' : - if (name.length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g') { - return true; - } - return false; - case 'd' : - if (name.length == 6 - && name[1] == 'o' - && name[2] == 'u' - && name[3] == 'b' - && name[4] == 'l' - && name[5] == 'e') { - return true; - } - return false; - case 'f' : - if (name.length == 5 - && name[1] == 'l' - && name[2] == 'o' - && name[3] == 'a' - && name[4] == 't') { - return true; - } - return false; - case 'b' : - if (name.length == 4 - && name[1] == 'y' - && name[2] == 't' - && name[3] == 'e') { - return true; - } else - if (name.length == 7 - && name[1] == 'o' - && name[2] == 'o' - && name[3] == 'l' - && name[4] == 'e' - && name[5] == 'a' - && name[6] == 'n') { - return true; - } - return false; - case 'c' : - if (name.length == 4 - && name[1] == 'h' - && name[2] == 'a' - && name[3] == 'r') { - return true; - } - return false; - case 's' : - if (name.length == 5 - && name[1] == 'h' - && name[2] == 'o' - && name[3] == 'r' - && name[4] == 't') { - return true; - } - return false; - case 'v' : - if (name.length == 4 - && name[1] == 'o' - && name[2] == 'i' - && name[3] == 'd') { - return true; - } - return false; + switch (name[0]) { + case 'i': + if (name.length == 3 && name[1] == 'n' && name[2] == 't') { + return true; + } + return false; + case 'l': + if (name.length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g') { + return true; + } + return false; + case 'd': + if (name.length == 6 && name[1] == 'o' && name[2] == 'u' && name[3] == 'b' && name[4] == 'l' && name[5] == 'e') { + return true; + } + return false; + case 'f': + if (name.length == 5 && name[1] == 'l' && name[2] == 'o' && name[3] == 'a' && name[4] == 't') { + return true; + } + return false; + case 'b': + if (name.length == 4 && name[1] == 'y' && name[2] == 't' && name[3] == 'e') { + return true; + } else if (name.length == 7 && name[1] == 'o' && name[2] == 'o' && name[3] == 'l' && name[4] == 'e' && name[5] == 'a' + && name[6] == 'n') { + return true; + } + return false; + case 'c': + if (name.length == 4 && name[1] == 'h' && name[2] == 'a' && name[3] == 'r') { + return true; + } + return false; + case 's': + if (name.length == 5 && name[1] == 'h' && name[2] == 'o' && name[3] == 'r' && name[4] == 't') { + return true; + } + return false; + case 'v': + if (name.length == 4 && name[1] == 'o' && name[2] == 'i' && name[3] == 'd') { + return true; + } + return false; } return false; } - + private void lookupForScopes() { if (this.pendingNameScopeResolution != null) { - for (Iterator iterator = this.pendingNameScopeResolution.iterator(); iterator.hasNext(); ) { + for (Iterator iterator = this.pendingNameScopeResolution.iterator(); iterator.hasNext();) { Name name = (Name) iterator.next(); this.ast.getBindingResolver().recordScope(name, lookupScope(name)); } } if (this.pendingThisExpressionScopeResolution != null) { - for (Iterator iterator = this.pendingThisExpressionScopeResolution.iterator(); iterator.hasNext(); ) { + for (Iterator iterator = this.pendingThisExpressionScopeResolution.iterator(); iterator.hasNext();) { ThisExpression thisExpression = (ThisExpression) iterator.next(); this.ast.getBindingResolver().recordScope(thisExpression, lookupScope(thisExpression)); } } - + } - + private BlockScope lookupScope(ASTNode node) { ASTNode currentNode = node; - while(currentNode != null - &&!(currentNode instanceof MethodDeclaration) - && !(currentNode instanceof Initializer) - && !(currentNode instanceof FieldDeclaration)) { + while (currentNode != null && !(currentNode instanceof MethodDeclaration) && !(currentNode instanceof Initializer) + && !(currentNode instanceof FieldDeclaration)) { currentNode = currentNode.getParent(); } if (currentNode == null) { @@ -2993,13 +2981,13 @@ public class AjASTConverter extends ASTConverter { } if (currentNode instanceof Initializer) { Initializer initializer = (Initializer) currentNode; - while(!(currentNode instanceof AbstractTypeDeclaration)) { + while (!(currentNode instanceof AbstractTypeDeclaration)) { currentNode = currentNode.getParent(); } - if (currentNode instanceof TypeDeclaration - || currentNode instanceof EnumDeclaration - || currentNode instanceof AnnotationTypeDeclaration) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.ast.getBindingResolver().getCorrespondingNode(currentNode); + if (currentNode instanceof TypeDeclaration || currentNode instanceof EnumDeclaration + || currentNode instanceof AnnotationTypeDeclaration) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.ast + .getBindingResolver().getCorrespondingNode(currentNode); if ((initializer.getModifiers() & Modifier.STATIC) != 0) { return typeDecl.staticInitializerScope; } else { @@ -3008,13 +2996,13 @@ public class AjASTConverter extends ASTConverter { } } else if (currentNode instanceof FieldDeclaration) { FieldDeclaration fieldDeclaration = (FieldDeclaration) currentNode; - while(!(currentNode instanceof AbstractTypeDeclaration)) { + while (!(currentNode instanceof AbstractTypeDeclaration)) { currentNode = currentNode.getParent(); } - if (currentNode instanceof TypeDeclaration - || currentNode instanceof EnumDeclaration + if (currentNode instanceof TypeDeclaration || currentNode instanceof EnumDeclaration || currentNode instanceof AnnotationTypeDeclaration) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.ast.getBindingResolver().getCorrespondingNode(currentNode); + org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.ast + .getBindingResolver().getCorrespondingNode(currentNode); if ((fieldDeclaration.getModifiers() & Modifier.STATIC) != 0) { return typeDecl.staticInitializerScope; } else { @@ -3022,7 +3010,8 @@ public class AjASTConverter extends ASTConverter { } } } - AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) this.ast.getBindingResolver().getCorrespondingNode(currentNode); + AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) this.ast.getBindingResolver() + .getCorrespondingNode(currentNode); return abstractMethodDeclaration.scope; } @@ -3043,11 +3032,11 @@ public class AjASTConverter extends ASTConverter { } } } - + protected void recordNodes(ASTNode node, org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode oldASTNode) { this.ast.getBindingResolver().store(node, oldASTNode); } - + protected void recordNodes(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, TagElement tagElement) { Iterator fragments = tagElement.fragments().listIterator(); while (fragments.hasNext()) { @@ -3058,7 +3047,7 @@ public class AjASTConverter extends ASTConverter { // get compiler node and record nodes int start = name.getStartPosition(); org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(start); - if (compilerNode!= null) { + if (compilerNode != null) { recordNodes(name, compilerNode); recordNodes(node, compilerNode); } @@ -3066,13 +3055,12 @@ public class AjASTConverter extends ASTConverter { if (memberRef.getQualifier() != null) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = null; if (compilerNode instanceof JavadocFieldReference) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocFieldReference)compilerNode).receiver; + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocFieldReference) compilerNode).receiver; if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) { typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression; } - } - else if (compilerNode instanceof JavadocMessageSend) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocMessageSend)compilerNode).receiver; + } else if (compilerNode instanceof JavadocMessageSend) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocMessageSend) compilerNode).receiver; if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) { typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression; } @@ -3094,11 +3082,11 @@ public class AjASTConverter extends ASTConverter { // get type ref org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = null; if (compilerNode instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression) { - typeRef = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression)compilerNode).type; - if (typeRef != null) recordNodes(name, compilerNode); - } - else if (compilerNode instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend)compilerNode).receiver; + typeRef = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression) compilerNode).type; + if (typeRef != null) + recordNodes(name, compilerNode); + } else if (compilerNode instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend) compilerNode).receiver; if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) { typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression; } @@ -3114,29 +3102,31 @@ public class AjASTConverter extends ASTConverter { Iterator parameters = methodRef.parameters().listIterator(); while (parameters.hasNext()) { MethodRefParameter param = (MethodRefParameter) parameters.next(); - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) javadoc.getNodeStartingAt(param.getStartPosition()); + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) javadoc + .getNodeStartingAt(param.getStartPosition()); if (expression != null) { recordNodes(param, expression); if (expression instanceof JavadocArgumentExpression) { JavadocArgumentExpression argExpr = (JavadocArgumentExpression) expression; org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = argExpr.argument.type; - if (this.ast.apiLevel >= AST.JLS3) param.setVarargs(argExpr.argument.isVarArgs()); + if (this.ast.apiLevel >= AST.JLS3) + param.setVarargs(argExpr.argument.isVarArgs()); recordNodes(param.getType(), typeRef); if (param.getType().isSimpleType()) { - recordName(((SimpleType)param.getType()).getName(), typeRef); + recordName(((SimpleType) param.getType()).getName(), typeRef); } else if (param.getType().isArrayType()) { Type type = ((ArrayType) param.getType()).getElementType(); recordNodes(type, typeRef); if (type.isSimpleType()) { - recordName(((SimpleType)type).getName(), typeRef); + recordName(((SimpleType) type).getName(), typeRef); } } } } } - } else if (node.getNodeType() == ASTNode.SIMPLE_NAME || - node.getNodeType() == ASTNode.QUALIFIED_NAME) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(node.getStartPosition()); + } else if (node.getNodeType() == ASTNode.SIMPLE_NAME || node.getNodeType() == ASTNode.QUALIFIED_NAME) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(node + .getStartPosition()); recordName((Name) node, compilerNode); } else if (node.getNodeType() == ASTNode.TAG_ELEMENT) { // resolve member and method references binding @@ -3144,68 +3134,68 @@ public class AjASTConverter extends ASTConverter { } } } - + protected void recordPendingNameScopeResolution(Name name) { if (this.pendingNameScopeResolution == null) { this.pendingNameScopeResolution = new HashSet(); } this.pendingNameScopeResolution.add(name); } - + protected void recordPendingThisExpressionScopeResolution(ThisExpression thisExpression) { if (this.pendingThisExpressionScopeResolution == null) { this.pendingThisExpressionScopeResolution = new HashSet(); } this.pendingThisExpressionScopeResolution.add(thisExpression); } - - /** - * Remove whitespaces and comments before and after the expression. - */ - private void trimWhiteSpacesAndComments(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression) { - int start = expression.sourceStart; - int end = expression.sourceEnd; - int token; - int trimLeftPosition = expression.sourceStart; - int trimRightPosition = expression.sourceEnd; - boolean first = true; - Scanner removeBlankScanner = this.ast.scanner; - try { - removeBlankScanner.setSource(this.compilationUnitSource); - removeBlankScanner.resetTo(start, end); - while (true) { - token = removeBlankScanner.getNextToken(); - switch (token) { - case TerminalTokens.TokenNameCOMMENT_JAVADOC : - case TerminalTokens.TokenNameCOMMENT_LINE : - case TerminalTokens.TokenNameCOMMENT_BLOCK : - if (first) { - trimLeftPosition = removeBlankScanner.currentPosition; - } - break; - case TerminalTokens.TokenNameWHITESPACE : - if (first) { - trimLeftPosition = removeBlankScanner.currentPosition; - } - break; - case TerminalTokens.TokenNameEOF : - expression.sourceStart = trimLeftPosition; - expression.sourceEnd = trimRightPosition; - return; - default : - /* - * if we find something else than a whitespace or a comment, - * then we reset the trimRigthPosition to the expression - * source end. - */ - trimRightPosition = removeBlankScanner.currentPosition - 1; - first = false; - } - } - } catch (InvalidInputException e){ - // ignore - } - } + + // /** + // * Remove whitespaces and comments before and after the expression. + // */ + // private void trimWhiteSpacesAndComments(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression) { + // int start = expression.sourceStart; + // int end = expression.sourceEnd; + // int token; + // int trimLeftPosition = expression.sourceStart; + // int trimRightPosition = expression.sourceEnd; + // boolean first = true; + // Scanner removeBlankScanner = this.ast.scanner; + // try { + // removeBlankScanner.setSource(this.compilationUnitSource); + // removeBlankScanner.resetTo(start, end); + // while (true) { + // token = removeBlankScanner.getNextToken(); + // switch (token) { + // case TerminalTokens.TokenNameCOMMENT_JAVADOC : + // case TerminalTokens.TokenNameCOMMENT_LINE : + // case TerminalTokens.TokenNameCOMMENT_BLOCK : + // if (first) { + // trimLeftPosition = removeBlankScanner.currentPosition; + // } + // break; + // case TerminalTokens.TokenNameWHITESPACE : + // if (first) { + // trimLeftPosition = removeBlankScanner.currentPosition; + // } + // break; + // case TerminalTokens.TokenNameEOF : + // expression.sourceStart = trimLeftPosition; + // expression.sourceEnd = trimRightPosition; + // return; + // default : + // /* + // * if we find something else than a whitespace or a comment, + // * then we reset the trimRigthPosition to the expression + // * source end. + // */ + // trimRightPosition = removeBlankScanner.currentPosition - 1; + // first = false; + // } + // } + // } catch (InvalidInputException e){ + // // ignore + // } + // } protected int retrieveEndingSemiColonPosition(int start, int end) { int count = 0; @@ -3213,42 +3203,41 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameSEMICOLON: - if (count == 0) { - return this.scanner.currentPosition - 1; - } - break; - case TerminalTokens.TokenNameLBRACE : - count++; - break; - case TerminalTokens.TokenNameRBRACE : - count--; - break; - case TerminalTokens.TokenNameLPAREN : - count++; - break; - case TerminalTokens.TokenNameRPAREN : - count--; - break; - case TerminalTokens.TokenNameLBRACKET : - count++; - break; - case TerminalTokens.TokenNameRBRACKET : - count--; + switch (token) { + case TerminalTokens.TokenNameSEMICOLON: + if (count == 0) { + return this.scanner.currentPosition - 1; + } + break; + case TerminalTokens.TokenNameLBRACE: + count++; + break; + case TerminalTokens.TokenNameRBRACE: + count--; + break; + case TerminalTokens.TokenNameLPAREN: + count++; + break; + case TerminalTokens.TokenNameRPAREN: + count--; + break; + case TerminalTokens.TokenNameLBRACKET: + count++; + break; + case TerminalTokens.TokenNameRBRACKET: + count--; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; } /** - * This method is used to retrieve the ending position for a type declaration when the dimension is right after the type - * name. - * For example: - * int[] i; => return 5, but int i[] => return -1; + * This method is used to retrieve the ending position for a type declaration when the dimension is right after the type name. + * For example: int[] i; => return 5, but int i[] => return -1; + * * @return int the dimension found */ protected int retrieveEndOfDimensionsPosition(int start, int end) { @@ -3257,20 +3246,20 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameLBRACKET: - case TerminalTokens.TokenNameCOMMENT_BLOCK: - case TerminalTokens.TokenNameCOMMENT_JAVADOC: - case TerminalTokens.TokenNameCOMMENT_LINE: - break; - case TerminalTokens.TokenNameRBRACKET://166 - foundPosition = this.scanner.currentPosition - 1; - break; - default: - return foundPosition; + switch (token) { + case TerminalTokens.TokenNameLBRACKET: + case TerminalTokens.TokenNameCOMMENT_BLOCK: + case TerminalTokens.TokenNameCOMMENT_JAVADOC: + case TerminalTokens.TokenNameCOMMENT_LINE: + break; + case TerminalTokens.TokenNameRBRACKET:// 166 + foundPosition = this.scanner.currentPosition - 1; + break; + default: + return foundPosition; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return foundPosition; @@ -3278,6 +3267,7 @@ public class AjASTConverter extends ASTConverter { /** * This method is used to retrieve the position just before the left bracket. + * * @return int the dimension found, -1 if none */ protected int retrieveEndOfElementTypeNamePosition(int start, int end) { @@ -3285,20 +3275,20 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameIdentifier: - case TerminalTokens.TokenNamebyte: - case TerminalTokens.TokenNamechar: - case TerminalTokens.TokenNamedouble: - case TerminalTokens.TokenNamefloat: - case TerminalTokens.TokenNameint: - case TerminalTokens.TokenNamelong: - case TerminalTokens.TokenNameshort: - case TerminalTokens.TokenNameboolean: - return this.scanner.currentPosition - 1; + switch (token) { + case TerminalTokens.TokenNameIdentifier: + case TerminalTokens.TokenNamebyte: + case TerminalTokens.TokenNamechar: + case TerminalTokens.TokenNamedouble: + case TerminalTokens.TokenNamefloat: + case TerminalTokens.TokenNameint: + case TerminalTokens.TokenNamelong: + case TerminalTokens.TokenNameshort: + case TerminalTokens.TokenNameboolean: + return this.scanner.currentPosition - 1; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; @@ -3306,6 +3296,7 @@ public class AjASTConverter extends ASTConverter { /** * This method is used to retrieve the position after the right parenthesis. + * * @return int the position found */ protected int retrieveEndOfRightParenthesisPosition(int start, int end) { @@ -3313,23 +3304,21 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameRPAREN: - return this.scanner.currentPosition; + switch (token) { + case TerminalTokens.TokenNameRPAREN: + return this.scanner.currentPosition; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; } /** - * This method is used to retrieve the array dimension declared after the - * name of a local or a field declaration. - * For example: - * int i, j[] = null, k[][] = {{}}; - * It should return 0 for i, 1 for j and 2 for k. + * This method is used to retrieve the array dimension declared after the name of a local or a field declaration. For example: + * int i, j[] = null, k[][] = {{}}; It should return 0 for i, 1 for j and 2 for k. + * * @return int the dimension found */ protected int retrieveExtraDimension(int start, int end) { @@ -3338,20 +3327,20 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameLBRACKET: - case TerminalTokens.TokenNameCOMMENT_BLOCK: - case TerminalTokens.TokenNameCOMMENT_JAVADOC: - case TerminalTokens.TokenNameCOMMENT_LINE: - break; - case TerminalTokens.TokenNameRBRACKET://166 - dimensions++; - break; - default: - return dimensions; + switch (token) { + case TerminalTokens.TokenNameLBRACKET: + case TerminalTokens.TokenNameCOMMENT_BLOCK: + case TerminalTokens.TokenNameCOMMENT_JAVADOC: + case TerminalTokens.TokenNameCOMMENT_LINE: + break; + case TerminalTokens.TokenNameRBRACKET:// 166 + dimensions++; + break; + default: + return dimensions; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return dimensions; @@ -3361,7 +3350,7 @@ public class AjASTConverter extends ASTConverter { this.scanner.resetTo(start, end); int token; try { - while((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { + while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { if (token == TerminalTokens.TokenNameIdentifier) { int startName = this.scanner.startPosition; int endName = this.scanner.currentPosition - 1; @@ -3369,13 +3358,14 @@ public class AjASTConverter extends ASTConverter { return; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } } - + /** * This method is used to retrieve the start position of the block. + * * @return int the dimension found, -1 if none */ protected int retrieveIdentifierEndPosition(int start, int end) { @@ -3383,19 +3373,20 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameIdentifier://110 - return this.scanner.getCurrentTokenEndPosition(); + switch (token) { + case TerminalTokens.TokenNameIdentifier:// 110 + return this.scanner.getCurrentTokenEndPosition(); } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; - } + } /** * This method is used to retrieve position before the next comma or semi-colon. + * * @return int the position found. */ protected int retrievePositionBeforeNextCommaOrSemiColon(int start, int end) { @@ -3404,33 +3395,33 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameLBRACE : - braceCounter++; - break; - case TerminalTokens.TokenNameRBRACE : - braceCounter--; - break; - case TerminalTokens.TokenNameLPAREN : - braceCounter++; - break; - case TerminalTokens.TokenNameRPAREN : - braceCounter--; - break; - case TerminalTokens.TokenNameLBRACKET : - braceCounter++; - break; - case TerminalTokens.TokenNameRBRACKET : - braceCounter--; - break; - case TerminalTokens.TokenNameCOMMA : - case TerminalTokens.TokenNameSEMICOLON : - if (braceCounter == 0) { - return this.scanner.startPosition - 1; - } + switch (token) { + case TerminalTokens.TokenNameLBRACE: + braceCounter++; + break; + case TerminalTokens.TokenNameRBRACE: + braceCounter--; + break; + case TerminalTokens.TokenNameLPAREN: + braceCounter++; + break; + case TerminalTokens.TokenNameRPAREN: + braceCounter--; + break; + case TerminalTokens.TokenNameLBRACKET: + braceCounter++; + break; + case TerminalTokens.TokenNameRBRACKET: + braceCounter--; + break; + case TerminalTokens.TokenNameCOMMA: + case TerminalTokens.TokenNameSEMICOLON: + if (braceCounter == 0) { + return this.scanner.startPosition - 1; + } } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; @@ -3441,15 +3432,15 @@ public class AjASTConverter extends ASTConverter { try { int token, count = 0; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameRBRACKET: - count++; - if (count == bracketNumber) { - return this.scanner.currentPosition - 1; - } + switch (token) { + case TerminalTokens.TokenNameRBRACKET: + count++; + if (count == bracketNumber) { + return this.scanner.currentPosition - 1; + } } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; @@ -3457,6 +3448,7 @@ public class AjASTConverter extends ASTConverter { /** * This method is used to retrieve position before the next right brace or semi-colon. + * * @return int the position found. */ protected int retrieveRightBraceOrSemiColonPosition(int start, int end) { @@ -3464,14 +3456,14 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameRBRACE : - return this.scanner.currentPosition - 1; - case TerminalTokens.TokenNameSEMICOLON : - return this.scanner.currentPosition - 1; + switch (token) { + case TerminalTokens.TokenNameRBRACE: + return this.scanner.currentPosition - 1; + case TerminalTokens.TokenNameSEMICOLON: + return this.scanner.currentPosition - 1; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; @@ -3479,6 +3471,7 @@ public class AjASTConverter extends ASTConverter { /** * This method is used to retrieve position before the next right brace or semi-colon. + * * @return int the position found. */ protected int retrieveRightBrace(int start, int end) { @@ -3486,19 +3479,20 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameRBRACE : - return this.scanner.currentPosition - 1; + switch (token) { + case TerminalTokens.TokenNameRBRACE: + return this.scanner.currentPosition - 1; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; } - + /** * This method is used to retrieve the position of the right bracket. + * * @return int the dimension found, -1 if none */ protected int retrieveRightBracketPosition(int start, int end) { @@ -3506,21 +3500,20 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameRBRACKET: - return this.scanner.currentPosition - 1; + switch (token) { + case TerminalTokens.TokenNameRBRACKET: + return this.scanner.currentPosition - 1; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; } - + /* - * This method is used to set the right end position for expression - * statement. The actual AST nodes don't include the trailing semicolon. - * This method fixes the length of the corresponding node. + * This method is used to set the right end position for expression statement. The actual AST nodes don't include the trailing + * semicolon. This method fixes the length of the corresponding node. */ protected void retrieveSemiColonPosition(ASTNode node) { int start = node.getStartPosition(); @@ -3531,39 +3524,40 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameSEMICOLON: - if (count == 0) { - node.setSourceRange(start, this.scanner.currentPosition - start); - return; - } - break; - case TerminalTokens.TokenNameLBRACE : - count++; - break; - case TerminalTokens.TokenNameRBRACE : - count--; - break; - case TerminalTokens.TokenNameLPAREN : - count++; - break; - case TerminalTokens.TokenNameRPAREN : - count--; - break; - case TerminalTokens.TokenNameLBRACKET : - count++; - break; - case TerminalTokens.TokenNameRBRACKET : - count--; + switch (token) { + case TerminalTokens.TokenNameSEMICOLON: + if (count == 0) { + node.setSourceRange(start, this.scanner.currentPosition - start); + return; + } + break; + case TerminalTokens.TokenNameLBRACE: + count++; + break; + case TerminalTokens.TokenNameRBRACE: + count--; + break; + case TerminalTokens.TokenNameLPAREN: + count++; + break; + case TerminalTokens.TokenNameRPAREN: + count--; + break; + case TerminalTokens.TokenNameLBRACKET: + count++; + break; + case TerminalTokens.TokenNameRBRACKET: + count--; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } } - + /** * This method is used to retrieve the start position of the block. + * * @return int the dimension found, -1 if none */ protected int retrieveStartBlockPosition(int start, int end) { @@ -3571,12 +3565,12 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNameLBRACE://110 - return this.scanner.startPosition; + switch (token) { + case TerminalTokens.TokenNameLBRACE:// 110 + return this.scanner.startPosition; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; @@ -3584,6 +3578,7 @@ public class AjASTConverter extends ASTConverter { /** * This method is used to retrieve the starting position of the catch keyword. + * * @return int the dimension found, -1 if none */ protected int retrieveStartingCatchPosition(int start, int end) { @@ -3591,28 +3586,30 @@ public class AjASTConverter extends ASTConverter { try { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - switch(token) { - case TerminalTokens.TokenNamecatch://225 - return this.scanner.startPosition; + switch (token) { + case TerminalTokens.TokenNamecatch:// 225 + return this.scanner.startPosition; } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } return -1; } - + public void setAST(AST ast) { this.ast = ast; this.docParser = new DocCommentParser(this.ast, this.scanner, this.insideComments); } - protected void setModifiers(AnnotationTypeDeclaration typeDecl, org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) { + protected void setModifiers(AnnotationTypeDeclaration typeDecl, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) { this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart); this.setModifiers(typeDecl, typeDeclaration.annotations); } - - protected void setModifiers(AnnotationTypeMemberDeclaration annotationTypeMemberDecl, org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) { + + protected void setModifiers(AnnotationTypeMemberDeclaration annotationTypeMemberDecl, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) { this.scanner.resetTo(annotationTypeMemberDeclaration.declarationSourceStart, annotationTypeMemberDeclaration.sourceStart); this.setModifiers(annotationTypeMemberDecl, annotationTypeMemberDeclaration.annotations); } @@ -3620,174 +3617,182 @@ public class AjASTConverter extends ASTConverter { /** * @param bodyDeclaration */ - protected void setModifiers(BodyDeclaration bodyDeclaration, org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations) { + protected void setModifiers(BodyDeclaration bodyDeclaration, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations) { try { int token; int indexInAnnotations = 0; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { IExtendedModifier modifier = null; - switch(token) { - case TerminalTokens.TokenNameabstract: - modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); - break; - case TerminalTokens.TokenNamepublic: - modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); - break; - case TerminalTokens.TokenNamestatic: - modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); - break; - case TerminalTokens.TokenNameprotected: - modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); - break; - case TerminalTokens.TokenNameprivate: - modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); - break; - case TerminalTokens.TokenNamefinal: - modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); - break; - case TerminalTokens.TokenNamenative: - modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); - break; - case TerminalTokens.TokenNamesynchronized: - modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); - break; - case TerminalTokens.TokenNametransient: - modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); - break; - case TerminalTokens.TokenNamevolatile: - modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); - break; - case TerminalTokens.TokenNamestrictfp: - modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); - break; - case TerminalTokens.TokenNameAT : - // we have an annotation - if (annotations != null && indexInAnnotations < annotations.length) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; - modifier = super.convert(annotation); - this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); - } - break; - case TerminalTokens.TokenNameCOMMENT_BLOCK : - case TerminalTokens.TokenNameCOMMENT_LINE : - case TerminalTokens.TokenNameCOMMENT_JAVADOC : - break; - default : - return; + switch (token) { + case TerminalTokens.TokenNameabstract: + modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); + break; + case TerminalTokens.TokenNamepublic: + modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); + break; + case TerminalTokens.TokenNamestatic: + modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); + break; + case TerminalTokens.TokenNameprotected: + modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); + break; + case TerminalTokens.TokenNameprivate: + modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); + break; + case TerminalTokens.TokenNamefinal: + modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); + break; + case TerminalTokens.TokenNamenative: + modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); + break; + case TerminalTokens.TokenNamesynchronized: + modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); + break; + case TerminalTokens.TokenNametransient: + modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); + break; + case TerminalTokens.TokenNamevolatile: + modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); + break; + case TerminalTokens.TokenNamestrictfp: + modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); + break; + case TerminalTokens.TokenNameAT: + // we have an annotation + if (annotations != null && indexInAnnotations < annotations.length) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; + modifier = super.convert(annotation); + this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); + } + break; + case TerminalTokens.TokenNameCOMMENT_BLOCK: + case TerminalTokens.TokenNameCOMMENT_LINE: + case TerminalTokens.TokenNameCOMMENT_JAVADOC: + break; + default: + return; } if (modifier != null) { bodyDeclaration.modifiers().add(modifier); } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } } - - - protected void setModifiers(EnumDeclaration enumDeclaration, org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enumDeclaration2) { + + protected void setModifiers(EnumDeclaration enumDeclaration, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enumDeclaration2) { this.scanner.resetTo(enumDeclaration2.declarationSourceStart, enumDeclaration2.sourceStart); this.setModifiers(enumDeclaration, enumDeclaration2.annotations); } - - protected void setModifiers(EnumConstantDeclaration enumConstantDeclaration, org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - enumConstantDeclaration.internalSetModifiers(fieldDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); - if (fieldDeclaration.annotations != null) { - enumConstantDeclaration.setFlags(enumConstantDeclaration.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(fieldDeclaration.declarationSourceStart, fieldDeclaration.sourceStart); - this.setModifiers(enumConstantDeclaration, fieldDeclaration.annotations); + + protected void setModifiers(EnumConstantDeclaration enumConstantDeclaration, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) { + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + enumConstantDeclaration.internalSetModifiers(fieldDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); + if (fieldDeclaration.annotations != null) { + enumConstantDeclaration.setFlags(enumConstantDeclaration.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(fieldDeclaration.declarationSourceStart, fieldDeclaration.sourceStart); + this.setModifiers(enumConstantDeclaration, fieldDeclaration.annotations); } } - + /** * @param fieldDeclaration * @param fieldDecl */ - protected void setModifiers(FieldDeclaration fieldDeclaration, org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDecl) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - fieldDeclaration.internalSetModifiers(fieldDecl.modifiers & ExtraCompilerModifiers.AccJustFlag); - if (fieldDecl.annotations != null) { - fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart); - this.setModifiers(fieldDeclaration, fieldDecl.annotations); + protected void setModifiers(FieldDeclaration fieldDeclaration, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDecl) { + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + fieldDeclaration.internalSetModifiers(fieldDecl.modifiers & ExtraCompilerModifiers.AccJustFlag); + if (fieldDecl.annotations != null) { + fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart); + this.setModifiers(fieldDeclaration, fieldDecl.annotations); } } - - protected void setModifiers(org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration fieldDeclaration, InterTypeFieldDeclaration fieldDecl) { + + protected void setModifiers(org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration fieldDeclaration, + InterTypeFieldDeclaration fieldDecl) { // ajh02: method added - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - fieldDeclaration.internalSetModifiers(fieldDecl.declaredModifiers & ExtraCompilerModifiers.AccJustFlag); - if (fieldDecl.annotations != null) { - fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart); - this.setModifiers(fieldDeclaration, fieldDecl.annotations); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + fieldDeclaration.internalSetModifiers(fieldDecl.declaredModifiers & ExtraCompilerModifiers.AccJustFlag); + if (fieldDecl.annotations != null) { + fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart); + this.setModifiers(fieldDeclaration, fieldDecl.annotations); } } - + /** * @param initializer * @param oldInitializer */ - protected void setModifiers(Initializer initializer, org.aspectj.org.eclipse.jdt.internal.compiler.ast.Initializer oldInitializer) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL: - initializer.internalSetModifiers(oldInitializer.modifiers & ExtraCompilerModifiers.AccJustFlag); - if (oldInitializer.annotations != null) { - initializer.setFlags(initializer.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(oldInitializer.declarationSourceStart, oldInitializer.bodyStart); - this.setModifiers(initializer, oldInitializer.annotations); + protected void setModifiers(Initializer initializer, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Initializer oldInitializer) { + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + initializer.internalSetModifiers(oldInitializer.modifiers & ExtraCompilerModifiers.AccJustFlag); + if (oldInitializer.annotations != null) { + initializer.setFlags(initializer.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(oldInitializer.declarationSourceStart, oldInitializer.bodyStart); + this.setModifiers(initializer, oldInitializer.annotations); } } + /** * @param methodDecl * @param methodDeclaration */ protected void setModifiers(MethodDeclaration methodDecl, AbstractMethodDeclaration methodDeclaration) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - if (methodDeclaration instanceof InterTypeDeclaration) { - methodDecl.internalSetModifiers(((InterTypeDeclaration)methodDeclaration).declaredModifiers & ExtraCompilerModifiers.AccJustFlag); - } else { - methodDecl.internalSetModifiers(methodDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); - } - if (methodDeclaration.annotations != null) { - methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(methodDeclaration.declarationSourceStart, methodDeclaration.sourceStart); - this.setModifiers(methodDecl, methodDeclaration.annotations); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + if (methodDeclaration instanceof InterTypeDeclaration) { + methodDecl.internalSetModifiers(((InterTypeDeclaration) methodDeclaration).declaredModifiers + & ExtraCompilerModifiers.AccJustFlag); + } else { + methodDecl.internalSetModifiers(methodDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); + } + if (methodDeclaration.annotations != null) { + methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(methodDeclaration.declarationSourceStart, methodDeclaration.sourceStart); + this.setModifiers(methodDecl, methodDeclaration.annotations); } } - - protected void setModifiers(org.aspectj.org.eclipse.jdt.core.dom.PointcutDeclaration pointcutDecl, PointcutDeclaration pointcutDeclaration) { + + protected void setModifiers(org.aspectj.org.eclipse.jdt.core.dom.PointcutDeclaration pointcutDecl, + PointcutDeclaration pointcutDeclaration) { // ajh02: method added - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - pointcutDecl.internalSetModifiers(pointcutDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); - if (pointcutDeclaration.annotations != null) { - pointcutDecl.setFlags(pointcutDecl.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(pointcutDeclaration.declarationSourceStart, pointcutDeclaration.sourceStart); - this.setModifiers(pointcutDecl, pointcutDeclaration.annotations); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + pointcutDecl.internalSetModifiers(pointcutDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); + if (pointcutDeclaration.annotations != null) { + pointcutDecl.setFlags(pointcutDecl.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(pointcutDeclaration.declarationSourceStart, pointcutDeclaration.sourceStart); + this.setModifiers(pointcutDecl, pointcutDeclaration.annotations); } } @@ -3796,89 +3801,89 @@ public class AjASTConverter extends ASTConverter { * @param argument */ protected void setModifiers(SingleVariableDeclaration variableDecl, Argument argument) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - variableDecl.internalSetModifiers(argument.modifiers & ExtraCompilerModifiers.AccJustFlag); - if (argument.annotations != null) { - variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(argument.declarationSourceStart, argument.sourceStart); - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = argument.annotations; - int indexInAnnotations = 0; - try { - int token; - while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - IExtendedModifier modifier = null; - switch(token) { - case TerminalTokens.TokenNameabstract: - modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); - break; - case TerminalTokens.TokenNamepublic: - modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); - break; - case TerminalTokens.TokenNamestatic: - modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); - break; - case TerminalTokens.TokenNameprotected: - modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); - break; - case TerminalTokens.TokenNameprivate: - modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); - break; - case TerminalTokens.TokenNamefinal: - modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); - break; - case TerminalTokens.TokenNamenative: - modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); - break; - case TerminalTokens.TokenNamesynchronized: - modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); - break; - case TerminalTokens.TokenNametransient: - modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); - break; - case TerminalTokens.TokenNamevolatile: - modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); - break; - case TerminalTokens.TokenNamestrictfp: - modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); - break; - case TerminalTokens.TokenNameAT : - // we have an annotation - if (annotations != null && indexInAnnotations < annotations.length) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; - modifier = super.convert(annotation); - this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); - } - break; - case TerminalTokens.TokenNameCOMMENT_BLOCK : - case TerminalTokens.TokenNameCOMMENT_LINE : - case TerminalTokens.TokenNameCOMMENT_JAVADOC : - break; - default : - return; - } - if (modifier != null) { - variableDecl.modifiers().add(modifier); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + variableDecl.internalSetModifiers(argument.modifiers & ExtraCompilerModifiers.AccJustFlag); + if (argument.annotations != null) { + variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(argument.declarationSourceStart, argument.sourceStart); + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = argument.annotations; + int indexInAnnotations = 0; + try { + int token; + while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { + IExtendedModifier modifier = null; + switch (token) { + case TerminalTokens.TokenNameabstract: + modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); + break; + case TerminalTokens.TokenNamepublic: + modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); + break; + case TerminalTokens.TokenNamestatic: + modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); + break; + case TerminalTokens.TokenNameprotected: + modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); + break; + case TerminalTokens.TokenNameprivate: + modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); + break; + case TerminalTokens.TokenNamefinal: + modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); + break; + case TerminalTokens.TokenNamenative: + modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); + break; + case TerminalTokens.TokenNamesynchronized: + modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); + break; + case TerminalTokens.TokenNametransient: + modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); + break; + case TerminalTokens.TokenNamevolatile: + modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); + break; + case TerminalTokens.TokenNamestrictfp: + modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); + break; + case TerminalTokens.TokenNameAT: + // we have an annotation + if (annotations != null && indexInAnnotations < annotations.length) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; + modifier = super.convert(annotation); + this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); } + break; + case TerminalTokens.TokenNameCOMMENT_BLOCK: + case TerminalTokens.TokenNameCOMMENT_LINE: + case TerminalTokens.TokenNameCOMMENT_JAVADOC: + break; + default: + return; + } + if (modifier != null) { + variableDecl.modifiers().add(modifier); } - } catch(InvalidInputException e) { - // ignore } + } catch (InvalidInputException e) { + // ignore + } } } - + protected void setModifiers(SingleVariableDeclaration variableDecl, LocalDeclaration localDeclaration) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: variableDecl.internalSetModifiers(localDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); if (localDeclaration.annotations != null) { variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3 : + case AST.JLS3: this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations; int indexInAnnotations = 0; @@ -3886,60 +3891,60 @@ public class AjASTConverter extends ASTConverter { int token; while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { IExtendedModifier modifier = null; - switch(token) { - case TerminalTokens.TokenNameabstract: - modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); - break; - case TerminalTokens.TokenNamepublic: - modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); - break; - case TerminalTokens.TokenNamestatic: - modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); - break; - case TerminalTokens.TokenNameprotected: - modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); - break; - case TerminalTokens.TokenNameprivate: - modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); - break; - case TerminalTokens.TokenNamefinal: - modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); - break; - case TerminalTokens.TokenNamenative: - modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); - break; - case TerminalTokens.TokenNamesynchronized: - modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); - break; - case TerminalTokens.TokenNametransient: - modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); - break; - case TerminalTokens.TokenNamevolatile: - modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); - break; - case TerminalTokens.TokenNamestrictfp: - modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); - break; - case TerminalTokens.TokenNameAT : - // we have an annotation - if (annotations != null && indexInAnnotations < annotations.length) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; - modifier = super.convert(annotation); - this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); - } - break; - case TerminalTokens.TokenNameCOMMENT_BLOCK : - case TerminalTokens.TokenNameCOMMENT_LINE : - case TerminalTokens.TokenNameCOMMENT_JAVADOC : - break; - default : - return; + switch (token) { + case TerminalTokens.TokenNameabstract: + modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); + break; + case TerminalTokens.TokenNamepublic: + modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); + break; + case TerminalTokens.TokenNamestatic: + modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); + break; + case TerminalTokens.TokenNameprotected: + modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); + break; + case TerminalTokens.TokenNameprivate: + modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); + break; + case TerminalTokens.TokenNamefinal: + modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); + break; + case TerminalTokens.TokenNamenative: + modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); + break; + case TerminalTokens.TokenNamesynchronized: + modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); + break; + case TerminalTokens.TokenNametransient: + modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); + break; + case TerminalTokens.TokenNamevolatile: + modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); + break; + case TerminalTokens.TokenNamestrictfp: + modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); + break; + case TerminalTokens.TokenNameAT: + // we have an annotation + if (annotations != null && indexInAnnotations < annotations.length) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; + modifier = super.convert(annotation); + this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); + } + break; + case TerminalTokens.TokenNameCOMMENT_BLOCK: + case TerminalTokens.TokenNameCOMMENT_LINE: + case TerminalTokens.TokenNameCOMMENT_JAVADOC: + break; + default: + return; } if (modifier != null) { variableDecl.modifiers().add(modifier); } } - } catch(InvalidInputException e) { + } catch (InvalidInputException e) { // ignore } } @@ -3949,102 +3954,103 @@ public class AjASTConverter extends ASTConverter { * @param typeDecl * @param typeDeclaration */ - protected void setModifiers(TypeDeclaration typeDecl, org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - int modifiers = typeDeclaration.modifiers; - modifiers &= ~ClassFileConstants.AccInterface; // remove AccInterface flags - modifiers &= ExtraCompilerModifiers.AccJustFlag; - typeDecl.internalSetModifiers(modifiers); - if (typeDeclaration.annotations != null) { - typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart); - this.setModifiers(typeDecl, typeDeclaration.annotations); + protected void setModifiers(TypeDeclaration typeDecl, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) { + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + int modifiers = typeDeclaration.modifiers; + modifiers &= ~ClassFileConstants.AccInterface; // remove AccInterface flags + modifiers &= ExtraCompilerModifiers.AccJustFlag; + typeDecl.internalSetModifiers(modifiers); + if (typeDeclaration.annotations != null) { + typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart); + this.setModifiers(typeDecl, typeDeclaration.annotations); } } - + /** * @param variableDeclarationExpression * @param localDeclaration */ protected void setModifiers(VariableDeclarationExpression variableDeclarationExpression, LocalDeclaration localDeclaration) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - int modifiers = localDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag; - modifiers &= ~ExtraCompilerModifiers.AccBlankFinal; - variableDeclarationExpression.internalSetModifiers(modifiers); - if (localDeclaration.annotations != null) { - variableDeclarationExpression.setFlags(variableDeclarationExpression.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart); - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations; - int indexInAnnotations = 0; - try { - int token; - while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - IExtendedModifier modifier = null; - switch(token) { - case TerminalTokens.TokenNameabstract: - modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); - break; - case TerminalTokens.TokenNamepublic: - modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); - break; - case TerminalTokens.TokenNamestatic: - modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); - break; - case TerminalTokens.TokenNameprotected: - modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); - break; - case TerminalTokens.TokenNameprivate: - modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); - break; - case TerminalTokens.TokenNamefinal: - modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); - break; - case TerminalTokens.TokenNamenative: - modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); - break; - case TerminalTokens.TokenNamesynchronized: - modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); - break; - case TerminalTokens.TokenNametransient: - modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); - break; - case TerminalTokens.TokenNamevolatile: - modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); - break; - case TerminalTokens.TokenNamestrictfp: - modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); - break; - case TerminalTokens.TokenNameAT : - // we have an annotation - if (annotations != null && indexInAnnotations < annotations.length) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; - modifier = super.convert(annotation); - this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); - } - break; - case TerminalTokens.TokenNameCOMMENT_BLOCK : - case TerminalTokens.TokenNameCOMMENT_LINE : - case TerminalTokens.TokenNameCOMMENT_JAVADOC : - break; - default : - return; - } - if (modifier != null) { - variableDeclarationExpression.modifiers().add(modifier); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + int modifiers = localDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag; + modifiers &= ~ExtraCompilerModifiers.AccBlankFinal; + variableDeclarationExpression.internalSetModifiers(modifiers); + if (localDeclaration.annotations != null) { + variableDeclarationExpression.setFlags(variableDeclarationExpression.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart); + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations; + int indexInAnnotations = 0; + try { + int token; + while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { + IExtendedModifier modifier = null; + switch (token) { + case TerminalTokens.TokenNameabstract: + modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); + break; + case TerminalTokens.TokenNamepublic: + modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); + break; + case TerminalTokens.TokenNamestatic: + modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); + break; + case TerminalTokens.TokenNameprotected: + modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); + break; + case TerminalTokens.TokenNameprivate: + modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); + break; + case TerminalTokens.TokenNamefinal: + modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); + break; + case TerminalTokens.TokenNamenative: + modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); + break; + case TerminalTokens.TokenNamesynchronized: + modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); + break; + case TerminalTokens.TokenNametransient: + modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); + break; + case TerminalTokens.TokenNamevolatile: + modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); + break; + case TerminalTokens.TokenNamestrictfp: + modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); + break; + case TerminalTokens.TokenNameAT: + // we have an annotation + if (annotations != null && indexInAnnotations < annotations.length) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; + modifier = super.convert(annotation); + this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); } + break; + case TerminalTokens.TokenNameCOMMENT_BLOCK: + case TerminalTokens.TokenNameCOMMENT_LINE: + case TerminalTokens.TokenNameCOMMENT_JAVADOC: + break; + default: + return; + } + if (modifier != null) { + variableDeclarationExpression.modifiers().add(modifier); } - } catch(InvalidInputException e) { - // ignore } - } + } catch (InvalidInputException e) { + // ignore + } + } } /** @@ -4052,96 +4058,97 @@ public class AjASTConverter extends ASTConverter { * @param localDeclaration */ protected void setModifiers(VariableDeclarationStatement variableDeclarationStatement, LocalDeclaration localDeclaration) { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - int modifiers = localDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag; - modifiers &= ~ExtraCompilerModifiers.AccBlankFinal; - variableDeclarationStatement.internalSetModifiers(modifiers); - if (localDeclaration.annotations != null) { - variableDeclarationStatement.setFlags(variableDeclarationStatement.getFlags() | ASTNode.MALFORMED); - } - break; - case AST.JLS3 : - this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart); - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations; - int indexInAnnotations = 0; - try { - int token; - while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { - IExtendedModifier modifier = null; - switch(token) { - case TerminalTokens.TokenNameabstract: - modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); - break; - case TerminalTokens.TokenNamepublic: - modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); - break; - case TerminalTokens.TokenNamestatic: - modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); - break; - case TerminalTokens.TokenNameprotected: - modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); - break; - case TerminalTokens.TokenNameprivate: - modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); - break; - case TerminalTokens.TokenNamefinal: - modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); - break; - case TerminalTokens.TokenNamenative: - modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); - break; - case TerminalTokens.TokenNamesynchronized: - modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); - break; - case TerminalTokens.TokenNametransient: - modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); - break; - case TerminalTokens.TokenNamevolatile: - modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); - break; - case TerminalTokens.TokenNamestrictfp: - modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); - break; - case TerminalTokens.TokenNameAT : - // we have an annotation - if (annotations != null && indexInAnnotations < annotations.length) { - org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; - modifier = super.convert(annotation); - this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); - } - break; - case TerminalTokens.TokenNameCOMMENT_BLOCK : - case TerminalTokens.TokenNameCOMMENT_LINE : - case TerminalTokens.TokenNameCOMMENT_JAVADOC : - break; - default : - return; - } - if (modifier != null) { - variableDeclarationStatement.modifiers().add(modifier); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + int modifiers = localDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag; + modifiers &= ~ExtraCompilerModifiers.AccBlankFinal; + variableDeclarationStatement.internalSetModifiers(modifiers); + if (localDeclaration.annotations != null) { + variableDeclarationStatement.setFlags(variableDeclarationStatement.getFlags() | ASTNode.MALFORMED); + } + break; + case AST.JLS3: + this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart); + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations; + int indexInAnnotations = 0; + try { + int token; + while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) { + IExtendedModifier modifier = null; + switch (token) { + case TerminalTokens.TokenNameabstract: + modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); + break; + case TerminalTokens.TokenNamepublic: + modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); + break; + case TerminalTokens.TokenNamestatic: + modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD); + break; + case TerminalTokens.TokenNameprotected: + modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD); + break; + case TerminalTokens.TokenNameprivate: + modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD); + break; + case TerminalTokens.TokenNamefinal: + modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD); + break; + case TerminalTokens.TokenNamenative: + modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD); + break; + case TerminalTokens.TokenNamesynchronized: + modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD); + break; + case TerminalTokens.TokenNametransient: + modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD); + break; + case TerminalTokens.TokenNamevolatile: + modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD); + break; + case TerminalTokens.TokenNamestrictfp: + modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD); + break; + case TerminalTokens.TokenNameAT: + // we have an annotation + if (annotations != null && indexInAnnotations < annotations.length) { + org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; + modifier = super.convert(annotation); + this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength); } + break; + case TerminalTokens.TokenNameCOMMENT_BLOCK: + case TerminalTokens.TokenNameCOMMENT_LINE: + case TerminalTokens.TokenNameCOMMENT_JAVADOC: + break; + default: + return; + } + if (modifier != null) { + variableDeclarationStatement.modifiers().add(modifier); } - } catch(InvalidInputException e) { - // ignore } - } + } catch (InvalidInputException e) { + // ignore + } + } } - protected QualifiedName setQualifiedNameNameAndSourceRanges(char[][] typeName, long[] positions, org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode node) { + protected QualifiedName setQualifiedNameNameAndSourceRanges(char[][] typeName, long[] positions, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode node) { int length = typeName.length; final SimpleName firstToken = new SimpleName(this.ast); firstToken.internalSetIdentifier(new String(typeName[0])); firstToken.index = 1; - int start0 = (int)(positions[0]>>>32); + int start0 = (int) (positions[0] >>> 32); int start = start0; - int end = (int)(positions[0] & 0xFFFFFFFF); + int end = (int) (positions[0] & 0xFFFFFFFF); firstToken.setSourceRange(start, end - start + 1); final SimpleName secondToken = new SimpleName(this.ast); secondToken.internalSetIdentifier(new String(typeName[1])); secondToken.index = 2; - start = (int)(positions[1]>>>32); - end = (int)(positions[1] & 0xFFFFFFFF); + start = (int) (positions[1] >>> 32); + end = (int) (positions[1] & 0xFFFFFFFF); secondToken.setSourceRange(start, end - start + 1); QualifiedName qualifiedName = new QualifiedName(this.ast); qualifiedName.setQualifier(firstToken); @@ -4161,9 +4168,9 @@ public class AjASTConverter extends ASTConverter { newPart = new SimpleName(this.ast); newPart.internalSetIdentifier(new String(typeName[i])); newPart.index = i + 1; - start = (int)(positions[i]>>>32); - end = (int)(positions[i] & 0xFFFFFFFF); - newPart.setSourceRange(start, end - start + 1); + start = (int) (positions[i] >>> 32); + end = (int) (positions[i] & 0xFFFFFFFF); + newPart.setSourceRange(start, end - start + 1); QualifiedName qualifiedName2 = new QualifiedName(this.ast); qualifiedName2.setQualifier(qualifiedName); qualifiedName2.setName(newPart); @@ -4172,7 +4179,7 @@ public class AjASTConverter extends ASTConverter { qualifiedName.setSourceRange(start0, end - start0 + 1); if (this.resolveBindings) { recordNodes(qualifiedName, node); - recordNodes(newPart, node); + recordNodes(newPart, node); recordPendingNameScopeResolution(qualifiedName); recordPendingNameScopeResolution(newPart); } @@ -4184,20 +4191,21 @@ public class AjASTConverter extends ASTConverter { } return name; } - - protected QualifiedName setQualifiedNameNameAndSourceRanges(char[][] typeName, long[] positions, int endingIndex, org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode node) { - int length = endingIndex + 1; + + protected QualifiedName setQualifiedNameNameAndSourceRanges(char[][] typeName, long[] positions, int endingIndex, + org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode node) { + int length = endingIndex + 1; final SimpleName firstToken = new SimpleName(this.ast); firstToken.internalSetIdentifier(new String(typeName[0])); firstToken.index = 1; - int start0 = (int)(positions[0]>>>32); + int start0 = (int) (positions[0] >>> 32); int start = start0; int end = (int) positions[0]; firstToken.setSourceRange(start, end - start + 1); final SimpleName secondToken = new SimpleName(this.ast); secondToken.internalSetIdentifier(new String(typeName[1])); secondToken.index = 2; - start = (int)(positions[1]>>>32); + start = (int) (positions[1] >>> 32); end = (int) positions[1]; secondToken.setSourceRange(start, end - start + 1); QualifiedName qualifiedName = new QualifiedName(this.ast); @@ -4218,9 +4226,9 @@ public class AjASTConverter extends ASTConverter { newPart = new SimpleName(this.ast); newPart.internalSetIdentifier(new String(typeName[i])); newPart.index = i + 1; - start = (int)(positions[i]>>>32); + start = (int) (positions[i] >>> 32); end = (int) positions[i]; - newPart.setSourceRange(start, end - start + 1); + newPart.setSourceRange(start, end - start + 1); QualifiedName qualifiedName2 = new QualifiedName(this.ast); qualifiedName2.setQualifier(qualifiedName); qualifiedName2.setName(newPart); @@ -4229,19 +4237,20 @@ public class AjASTConverter extends ASTConverter { qualifiedName.setSourceRange(start0, end - start0 + 1); if (this.resolveBindings) { recordNodes(qualifiedName, node); - recordNodes(newPart, node); + recordNodes(newPart, node); recordPendingNameScopeResolution(qualifiedName); recordPendingNameScopeResolution(newPart); } } - if (newPart == null && this.resolveBindings) { - recordNodes(qualifiedName, node); - recordPendingNameScopeResolution(qualifiedName); - } + if (newPart == null && this.resolveBindings) { + recordNodes(qualifiedName, node); + recordPendingNameScopeResolution(qualifiedName); + } return qualifiedName; } - - protected void setTypeNameForAnnotation(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation compilerAnnotation, Annotation annotation) { + + protected void setTypeNameForAnnotation(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation compilerAnnotation, + Annotation annotation) { TypeReference typeReference = compilerAnnotation.type; if (typeReference instanceof QualifiedTypeReference) { QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) typeReference; @@ -4262,13 +4271,13 @@ public class AjASTConverter extends ASTConverter { } } } - + protected void setTypeForField(FieldDeclaration fieldDeclaration, Type type, int extraDimension) { if (extraDimension != 0) { if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; int remainingDimensions = arrayType.getDimensions() - extraDimension; - if (remainingDimensions == 0) { + if (remainingDimensions == 0) { // the dimensions are after the name so the type of the fieldDeclaration is a simpleType Type elementType = arrayType.getElementType(); // cut the child loose from its parent (without creating garbage) @@ -4303,36 +4312,36 @@ public class AjASTConverter extends ASTConverter { fieldDeclaration.setType(type); } } - + protected void setTypeForAroundAdviceDeclaration(AroundAdviceDeclaration adviceDeclaration, Type type) { // ajh02: method added - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - adviceDeclaration.internalSetReturnType(type); - break; - case AST.JLS3 : - adviceDeclaration.setReturnType2(type); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + adviceDeclaration.internalSetReturnType(type); + break; + case AST.JLS3: + adviceDeclaration.setReturnType2(type); break; } } - + protected void setTypeForMethodDeclaration(MethodDeclaration methodDeclaration, Type type, int extraDimension) { if (extraDimension != 0) { if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; int remainingDimensions = arrayType.getDimensions() - extraDimension; - if (remainingDimensions == 0) { + if (remainingDimensions == 0) { // the dimensions are after the name so the type of the fieldDeclaration is a simpleType Type elementType = arrayType.getElementType(); // cut the child loose from its parent (without creating garbage) elementType.setParent(null, null); this.ast.getBindingResolver().updateKey(type, elementType); - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - methodDeclaration.internalSetReturnType(elementType); - break; - case AST.JLS3 : - methodDeclaration.setReturnType2(elementType); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + methodDeclaration.internalSetReturnType(elementType); + break; + case AST.JLS3: + methodDeclaration.setReturnType2(elementType); break; } } else { @@ -4348,48 +4357,50 @@ public class AjASTConverter extends ASTConverter { // cut the child loose from its parent (without creating garbage) subarrayType.setParent(null, null); updateInnerPositions(subarrayType, remainingDimensions); - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - methodDeclaration.internalSetReturnType(subarrayType); - break; - case AST.JLS3 : - methodDeclaration.setReturnType2(subarrayType); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + methodDeclaration.internalSetReturnType(subarrayType); + break; + case AST.JLS3: + methodDeclaration.setReturnType2(subarrayType); break; } this.ast.getBindingResolver().updateKey(type, subarrayType); } } else { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - methodDeclaration.internalSetReturnType(type); - break; - case AST.JLS3 : - methodDeclaration.setReturnType2(type); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + methodDeclaration.internalSetReturnType(type); + break; + case AST.JLS3: + methodDeclaration.setReturnType2(type); break; } } } else { - switch(this.ast.apiLevel) { - case AST.JLS2_INTERNAL : - methodDeclaration.internalSetReturnType(type); - break; - case AST.JLS3 : - methodDeclaration.setReturnType2(type); + switch (this.ast.apiLevel) { + case AST.JLS2_INTERNAL: + methodDeclaration.internalSetReturnType(type); + break; + case AST.JLS3: + methodDeclaration.setReturnType2(type); break; } } } - - protected void setTypeForMethodDeclaration(AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration, Type type, int extraDimension) { + + protected void setTypeForMethodDeclaration(AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration, Type type, + int extraDimension) { annotationTypeMemberDeclaration.setType(type); } - protected void setTypeForSingleVariableDeclaration(SingleVariableDeclaration singleVariableDeclaration, Type type, int extraDimension) { + protected void setTypeForSingleVariableDeclaration(SingleVariableDeclaration singleVariableDeclaration, Type type, + int extraDimension) { if (extraDimension != 0) { if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; int remainingDimensions = arrayType.getDimensions() - extraDimension; - if (remainingDimensions == 0) { + if (remainingDimensions == 0) { // the dimensions are after the name so the type of the fieldDeclaration is a simpleType Type elementType = arrayType.getElementType(); // cut the child loose from its parent (without creating garbage) @@ -4420,12 +4431,13 @@ public class AjASTConverter extends ASTConverter { } } - protected void setTypeForVariableDeclarationExpression(VariableDeclarationExpression variableDeclarationExpression, Type type, int extraDimension) { + protected void setTypeForVariableDeclarationExpression(VariableDeclarationExpression variableDeclarationExpression, Type type, + int extraDimension) { if (extraDimension != 0) { if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; int remainingDimensions = arrayType.getDimensions() - extraDimension; - if (remainingDimensions == 0) { + if (remainingDimensions == 0) { // the dimensions are after the name so the type of the fieldDeclaration is a simpleType Type elementType = arrayType.getElementType(); // cut the child loose from its parent (without creating garbage) @@ -4456,12 +4468,13 @@ public class AjASTConverter extends ASTConverter { } } - protected void setTypeForVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, Type type, int extraDimension) { + protected void setTypeForVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, Type type, + int extraDimension) { if (extraDimension != 0) { if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; int remainingDimensions = arrayType.getDimensions() - extraDimension; - if (remainingDimensions == 0) { + if (remainingDimensions == 0) { // the dimensions are after the name so the type of the fieldDeclaration is a simpleType Type elementType = arrayType.getElementType(); // cut the child loose from its parent (without creating garbage) @@ -4504,8 +4517,7 @@ public class AjASTConverter extends ASTConverter { currentComponentType.setSourceRange(start, rightBracketEndPosition - start + 1); currentComponentType = ((ArrayType) currentComponentType).getComponentType(); searchedDimension--; - } + } } } } - diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java index a95c76589..ff1a2d1ac 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java @@ -17,24 +17,22 @@ import java.util.List; /** * AspectDeclaration DOM AST node. * - * Has everything an AjTypeDeclaration has plus: - * an ASTNode called 'perClause' - * a boolean called 'privileged' + * Has everything an AjTypeDeclaration has plus: an ASTNode called 'perClause' a boolean called 'privileged' * * @author ajh02 - * + * */ public class AspectDeclaration extends AjTypeDeclaration { - - public static final ChildPropertyDescriptor PERCLAUSE_PROPERTY = - new ChildPropertyDescriptor(AspectDeclaration.class, "perClause", ASTNode.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$ - public static final SimplePropertyDescriptor PRIVILEGED_PROPERTY = - new SimplePropertyDescriptor(AspectDeclaration.class, "privileged", boolean.class, MANDATORY); //$NON-NLS-1$ + public static final ChildPropertyDescriptor PERCLAUSE_PROPERTY = new ChildPropertyDescriptor(AspectDeclaration.class, + "perClause", ASTNode.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$ + + public static final SimplePropertyDescriptor PRIVILEGED_PROPERTY = new SimplePropertyDescriptor(AspectDeclaration.class, + "privileged", boolean.class, MANDATORY); //$NON-NLS-1$ protected static List aspectPROPERTY_DESCRIPTORS_2_0; protected static List aspectPROPERTY_DESCRIPTORS_3_0; - + static { List temporary = new ArrayList(); createPropertyList(AspectDeclaration.class, temporary); @@ -42,7 +40,7 @@ public class AspectDeclaration extends AjTypeDeclaration { addProperty(PERCLAUSE_PROPERTY, temporary); addProperty(PRIVILEGED_PROPERTY, temporary); aspectPROPERTY_DESCRIPTORS_2_0 = reapPropertyList(temporary); - + temporary.clear(); createPropertyList(AspectDeclaration.class, temporary); temporary.addAll(ajPROPERTY_DESCRIPTORS_3_0); @@ -50,43 +48,39 @@ public class AspectDeclaration extends AjTypeDeclaration { addProperty(PRIVILEGED_PROPERTY, temporary); aspectPROPERTY_DESCRIPTORS_3_0 = reapPropertyList(temporary); } - + protected ASTNode perClause = null; // stays null if the aspect is an _implicit_ persingleton() /** - * <code>true</code> for a privileged aspect, <code>false</code> otherwise. - * Defaults to not privileged. + * <code>true</code> for a privileged aspect, <code>false</code> otherwise. Defaults to not privileged. */ private boolean isPrivileged = false; AspectDeclaration(AST ast) { super(ast); } - + AspectDeclaration(AST ast, ASTNode perClause) { this(ast); this.perClause = perClause; setAspect(true); } - + AspectDeclaration(AST ast, ASTNode perClause, boolean isPrivileged) { this(ast, perClause); this.isPrivileged = isPrivileged; } - - /* (omit javadoc for this method) - * Method declared on ASTNode. + + /* + * (omit javadoc for this method) Method declared on ASTNode. */ ASTNode clone0(AST target) { AspectDeclaration result = new AspectDeclaration(target, perClause); result.setSourceRange(this.getStartPosition(), this.getLength()); - result.setJavadoc( - (Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.setJavadoc((Javadoc) ASTNode.copySubtree(target, getJavadoc())); if (this.ast.apiLevel == AST.JLS2_INTERNAL) { result.internalSetModifiers(getModifiers()); - result.setSuperclass( - (Name) ASTNode.copySubtree(target, getSuperclass())); - result.superInterfaces().addAll( - ASTNode.copySubtrees(target, superInterfaces())); + result.setSuperclass((Name) ASTNode.copySubtree(target, getSuperclass())); + result.superInterfaces().addAll(ASTNode.copySubtrees(target, superInterfaces())); } result.setInterface(isInterface()); result.setAspect(isAspect()); @@ -94,21 +88,17 @@ public class AspectDeclaration extends AjTypeDeclaration { result.setName((SimpleName) getName().clone(target)); if (this.ast.apiLevel >= AST.JLS3) { result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); - result.typeParameters().addAll( - ASTNode.copySubtrees(target, typeParameters())); - result.setSuperclassType( - (Type) ASTNode.copySubtree(target, getSuperclassType())); - result.superInterfaceTypes().addAll( - ASTNode.copySubtrees(target, superInterfaceTypes())); + result.typeParameters().addAll(ASTNode.copySubtrees(target, typeParameters())); + result.setSuperclassType((Type) ASTNode.copySubtree(target, getSuperclassType())); + result.superInterfaceTypes().addAll(ASTNode.copySubtrees(target, superInterfaceTypes())); } - result.bodyDeclarations().addAll( - ASTNode.copySubtrees(target, bodyDeclarations())); - result.setPerClause((ASTNode)getPerClause().clone(target)); + result.bodyDeclarations().addAll(ASTNode.copySubtrees(target, bodyDeclarations())); + result.setPerClause(getPerClause().clone(target)); return result; } - - /* (omit javadoc for this method) - * Method declared on ASTNode. + + /* + * (omit javadoc for this method) Method declared on ASTNode. */ void accept0(ASTVisitor visitor) { boolean visitChildren = visitor.visit(this); @@ -135,9 +125,9 @@ public class AspectDeclaration extends AjTypeDeclaration { } visitor.endVisit(this); } - - /* (omit javadoc for this method) - * Method declared on ASTNode and AjTypeDeclaration. + + /* + * (omit javadoc for this method) Method declared on ASTNode and AjTypeDeclaration. */ final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { if (property == PRIVILEGED_PROPERTY) { @@ -150,33 +140,29 @@ public class AspectDeclaration extends AjTypeDeclaration { } // allow default implementation to flag the error return super.internalGetSetBooleanProperty(property, get, value); - } - + } + /* - * (omit javadoc for this method) - * Method declared on ASTNode. + * (omit javadoc for this method) Method declared on ASTNode. */ - final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property,boolean get, ASTNode child) { + final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == PERCLAUSE_PROPERTY) { if (get) { return getPerClause(); } else { - setPerClause((ASTNode) child); + setPerClause(child); return null; } } - return super.internalGetSetChildProperty(property,get,child); + return super.internalGetSetChildProperty(property, get, child); } - + /** - * Returns a list of structural property descriptors for this node type. - * Clients must not modify the result. + * Returns a list of structural property descriptors for this node type. Clients must not modify the result. * - * @param apiLevel the API level; one of the - * <code>AST.JLS*</code> constants - - * @return a list of property descriptors (element type: - * {@link StructuralPropertyDescriptor}) + * @param apiLevel the API level; one of the <code>AST.JLS*</code> constants + * + * @return a list of property descriptors (element type: {@link StructuralPropertyDescriptor}) * @since 3.0 */ public static List propertyDescriptors(int apiLevel) { @@ -186,8 +172,8 @@ public class AspectDeclaration extends AjTypeDeclaration { return aspectPROPERTY_DESCRIPTORS_3_0; } } - - public ASTNode getPerClause(){ + + public ASTNode getPerClause() { return perClause; } @@ -200,33 +186,32 @@ public class AspectDeclaration extends AjTypeDeclaration { this.perClause = perClause; postReplaceChild(oldChild, perClause, PERCLAUSE_PROPERTY); } - + /** * Returns whether this aspect is a privileged one. * - * @return <code>true</code> if this is a privileged aspect - * declaration, and <code>false</code> otherwise. - */ + * @return <code>true</code> if this is a privileged aspect declaration, and <code>false</code> otherwise. + */ public boolean isPrivileged() { return this.isPrivileged; } + /** * Sets whether this aspect is a privileged one * - * @param isPrivileged <code>true</code> if this is a privileged aspect - * declaration, and <code>false</code> otherwise. - */ + * @param isPrivileged <code>true</code> if this is a privileged aspect declaration, and <code>false</code> otherwise. + */ public void setPrivileged(boolean isPrivileged) { preValueChange(PRIVILEGED_PROPERTY); - this.isPrivileged = isPrivileged; + this.isPrivileged = isPrivileged; postValueChange(PRIVILEGED_PROPERTY); - } - + } + public List getAdvice() { // ajh02: method added List bd = bodyDeclarations(); List advice = new ArrayList(); - for (Iterator it = bd.listIterator(); it.hasNext(); ) { + for (Iterator it = bd.listIterator(); it.hasNext();) { Object decl = it.next(); if (decl instanceof AdviceDeclaration) { advice.add(decl); @@ -234,26 +219,26 @@ public class AspectDeclaration extends AjTypeDeclaration { } return advice; } - -// public PointcutDeclaration[] getPointcuts() { -// // ajh02: method added, currently returning none :-/ -// List bd = bodyDeclarations(); -// // ajh02: 0 bodyDeclarations :-/ -// int pointcutCount = 0; -// for (Iterator it = bd.listIterator(); it.hasNext(); ) { -// if (it.next() instanceof PointcutDeclaration) { -// pointcutCount++; -// } -// } -// PointcutDeclaration[] pointcuts = new PointcutDeclaration[pointcutCount]; -// int next = 0; -// for (Iterator it = bd.listIterator(); it.hasNext(); ) { -// Object decl = it.next(); -// if (decl instanceof PointcutDeclaration) { -// pointcuts[next++] = (PointcutDeclaration) decl; -// } -// } -// return pointcuts; -// } + + // public PointcutDeclaration[] getPointcuts() { + // // ajh02: method added, currently returning none :-/ + // List bd = bodyDeclarations(); + // // ajh02: 0 bodyDeclarations :-/ + // int pointcutCount = 0; + // for (Iterator it = bd.listIterator(); it.hasNext(); ) { + // if (it.next() instanceof PointcutDeclaration) { + // pointcutCount++; + // } + // } + // PointcutDeclaration[] pointcuts = new PointcutDeclaration[pointcutCount]; + // int next = 0; + // for (Iterator it = bd.listIterator(); it.hasNext(); ) { + // Object decl = it.next(); + // if (decl instanceof PointcutDeclaration) { + // pointcuts[next++] = (PointcutDeclaration) decl; + // } + // } + // return pointcuts; + // } }
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultPointcut.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultPointcut.java index b0567f9a2..bb05896fb 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultPointcut.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultPointcut.java @@ -13,56 +13,64 @@ package org.aspectj.org.eclipse.jdt.core.dom; import java.util.ArrayList; import java.util.List; -import org.aspectj.org.eclipse.jdt.core.dom.AST; -import org.aspectj.org.eclipse.jdt.core.dom.ASTNode; - /** - * DefaultPointcut DOM AST node. - * has: - * nothing - * - * This class is a stub and should be deleted when concrete subclasses - * exist for all the different types of pointcuts in AspectJ. + * DefaultPointcut DOM AST node. has: nothing + * + * This class is a stub and should be deleted when concrete subclasses exist for all the different types of pointcuts in AspectJ. + * * @author ajh02 */ public class DefaultPointcut extends PointcutDesignator { private String detail; - DefaultPointcut(AST ast,String d) { + + DefaultPointcut(AST ast, String d) { super(ast); this.detail = d; } - public String getDetail() { return detail;} + + public String getDetail() { + return detail; + } + public void setDetail(String d) { this.detail = d; } + public static List propertyDescriptors(int apiLevel) { List propertyList = new ArrayList(0); createPropertyList(DefaultPointcut.class, propertyList); return reapPropertyList(propertyList); } + final List internalStructuralPropertiesForType(int apiLevel) { return propertyDescriptors(apiLevel); } + final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); } + ASTNode clone0(AST target) { - DefaultPointcut result = new DefaultPointcut(target,getDetail()); + DefaultPointcut result = new DefaultPointcut(target, getDetail()); result.setSourceRange(this.getStartPosition(), this.getLength()); return result; } + final boolean subtreeMatch0(ASTMatcher matcher, Object other) { // dispatch to correct overloaded match method - return ((AjASTMatcher)matcher).match(this, other); + return ((AjASTMatcher) matcher).match(this, other); } + void accept0(ASTVisitor visitor) { if (visitor instanceof AjASTVisitor) { - boolean visitChildren = ((AjASTVisitor)visitor).visit(this); - ((AjASTVisitor)visitor).endVisit(this); + // boolean visitChildren = + ((AjASTVisitor) visitor).visit(this); + ((AjASTVisitor) visitor).endVisit(this); } } + int treeSize() { return memSize(); } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultTypePattern.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultTypePattern.java index a52d6e2c3..b9ca939e1 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultTypePattern.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultTypePattern.java @@ -14,51 +14,61 @@ import java.util.ArrayList; import java.util.List; /** - * DefaultTypePattern DOM AST node. - * has: - * nothing - * - * This class is a stub and should be deleted when concrete subclasses - * exist for all the different TypePattern's in AspectJ. + * DefaultTypePattern DOM AST node. has: nothing + * + * This class is a stub and should be deleted when concrete subclasses exist for all the different TypePattern's in AspectJ. */ public class DefaultTypePattern extends TypePattern { private String detail; - DefaultTypePattern(AST ast,String d) { + + DefaultTypePattern(AST ast, String d) { super(ast); this.detail = d; } - public String getDetail() { return detail;} + + public String getDetail() { + return detail; + } + public void setDetail(String d) { this.detail = d; } + public static List propertyDescriptors(int apiLevel) { List propertyList = new ArrayList(0); createPropertyList(DefaultTypePattern.class, propertyList); return reapPropertyList(propertyList); } + final List internalStructuralPropertiesForType(int apiLevel) { return propertyDescriptors(apiLevel); } + final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); } + ASTNode clone0(AST target) { - DefaultTypePattern result = new DefaultTypePattern(target,getDetail()); + DefaultTypePattern result = new DefaultTypePattern(target, getDetail()); result.setSourceRange(this.getStartPosition(), this.getLength()); return result; } + final boolean subtreeMatch0(ASTMatcher matcher, Object other) { // dispatch to correct overloaded match method - return ((AjASTMatcher)matcher).match(this, other); + return ((AjASTMatcher) matcher).match(this, other); } + void accept0(ASTVisitor visitor) { if (visitor instanceof AjASTVisitor) { - boolean visitChildren = ((AjASTVisitor)visitor).visit(this); - ((AjASTVisitor)visitor).endVisit(this); + // boolean visitChildren = + ((AjASTVisitor) visitor).visit(this); + ((AjASTVisitor) visitor).endVisit(this); } } + int treeSize() { return memSize(); } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/SignaturePattern.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/SignaturePattern.java index a33a8847b..77a875ac2 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/SignaturePattern.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/SignaturePattern.java @@ -14,52 +14,61 @@ import java.util.ArrayList; import java.util.List; /** - * SignaturePattern DOM AST node. - * has: - * nothing - * - * For the moment this does nothing except enable us to - * set a SignaturePattern for the declare annotation - * declarations + * SignaturePattern DOM AST node. has: nothing + * + * For the moment this does nothing except enable us to set a SignaturePattern for the declare annotation declarations */ public class SignaturePattern extends PatternNode { private String detail; - SignaturePattern(AST ast,String d) { + + SignaturePattern(AST ast, String d) { super(ast); this.detail = d; } - public String getDetail() { return detail;} + + public String getDetail() { + return detail; + } + public void setDetail(String d) { this.detail = d; } + public static List propertyDescriptors(int apiLevel) { List propertyList = new ArrayList(0); createPropertyList(SignaturePattern.class, propertyList); return reapPropertyList(propertyList); } + final List internalStructuralPropertiesForType(int apiLevel) { return propertyDescriptors(apiLevel); } + final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); } + ASTNode clone0(AST target) { - SignaturePattern result = new SignaturePattern(target,getDetail()); + SignaturePattern result = new SignaturePattern(target, getDetail()); result.setSourceRange(this.getStartPosition(), this.getLength()); return result; } + final boolean subtreeMatch0(ASTMatcher matcher, Object other) { // dispatch to correct overloaded match method - return ((AjASTMatcher)matcher).match(this, other); + return ((AjASTMatcher) matcher).match(this, other); } + void accept0(ASTVisitor visitor) { if (visitor instanceof AjASTVisitor) { - boolean visitChildren = ((AjASTVisitor)visitor).visit(this); - ((AjASTVisitor)visitor).endVisit(this); + // boolean visitChildren = + ((AjASTVisitor) visitor).visit(this); + ((AjASTVisitor) visitor).endVisit(this); } } + int treeSize() { return memSize(); } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java b/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java index 77d8bc0dd..effb8f8b8 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java @@ -10,8 +10,6 @@ * PARC initial implementation * ******************************************************************/ - - package org.aspectj.tools.ajc; import java.io.File; @@ -41,74 +39,65 @@ import org.aspectj.util.LangUtil; import org.aspectj.weaver.Dump; /** - * Programmatic and command-line interface to AspectJ compiler. - * The compiler is an ICommand obtained by reflection. - * Not thread-safe. - * By default, messages are printed as they are emitted; - * info messages go to the output stream, and - * warnings and errors go to the error stream. + * Programmatic and command-line interface to AspectJ compiler. The compiler is an ICommand obtained by reflection. Not thread-safe. + * By default, messages are printed as they are emitted; info messages go to the output stream, and warnings and errors go to the + * error stream. * <p> * Clients can handle all messages by registering a holder: - * <pre>Main main = new Main(); + * + * <pre> + * Main main = new Main(); * IMessageHolder holder = new MessageHandler(); - * main.setHolder(holder);</pre> - * Clients can get control after each command completes - * by installing a Runnable: - * <pre>main.setCompletionRunner(new Runnable() {..});</pre> + * main.setHolder(holder); + * </pre> + * + * Clients can get control after each command completes by installing a Runnable: + * + * <pre> + * main.setCompletionRunner(new Runnable() {..}); + * </pre> * */ public class Main { /** Header used when rendering exceptions for users */ - public static final String THROWN_PREFIX - = "Exception thrown from AspectJ "+ Version.text + LangUtil.EOL - + ""+ LangUtil.EOL - + "This might be logged as a bug already -- find current bugs at" + LangUtil.EOL - + " http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler" + LangUtil.EOL - + "" + LangUtil.EOL - + "Bugs for exceptions thrown have titles File:line from the top stack, " + LangUtil.EOL - + "e.g., \"SomeFile.java:243\"" + LangUtil.EOL - + "" + LangUtil.EOL - + "If you don't find the exception below in a bug, please add a new bug" + LangUtil.EOL - + "at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ" + LangUtil.EOL - + "To make the bug a priority, please include a test program" + LangUtil.EOL - + "that can reproduce this exception." + LangUtil.EOL; - - private static final String OUT_OF_MEMORY_MSG - = "AspectJ " + Version.text + " ran out of memory during compilation:" + LangUtil.EOL + LangUtil.EOL - + "Please increase the memory available to ajc by editing the ajc script " + LangUtil.EOL - + "found in your AspectJ installation directory. The -Xmx parameter value" + LangUtil.EOL - + "should be increased from 64M (default) to 128M or even 256M." + LangUtil.EOL + LangUtil.EOL - + "See the AspectJ FAQ available from the documentation link" + LangUtil.EOL - + "on the AspectJ home page at http://www.eclipse.org/aspectj"; + public static final String THROWN_PREFIX = "Exception thrown from AspectJ " + Version.text + LangUtil.EOL + "" + LangUtil.EOL + + "This might be logged as a bug already -- find current bugs at" + LangUtil.EOL + + " http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler" + LangUtil.EOL + "" + LangUtil.EOL + + "Bugs for exceptions thrown have titles File:line from the top stack, " + LangUtil.EOL + + "e.g., \"SomeFile.java:243\"" + LangUtil.EOL + "" + LangUtil.EOL + + "If you don't find the exception below in a bug, please add a new bug" + LangUtil.EOL + + "at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ" + LangUtil.EOL + + "To make the bug a priority, please include a test program" + LangUtil.EOL + "that can reproduce this exception." + + LangUtil.EOL; + + private static final String OUT_OF_MEMORY_MSG = "AspectJ " + Version.text + " ran out of memory during compilation:" + + LangUtil.EOL + LangUtil.EOL + "Please increase the memory available to ajc by editing the ajc script " + LangUtil.EOL + + "found in your AspectJ installation directory. The -Xmx parameter value" + LangUtil.EOL + + "should be increased from 64M (default) to 128M or even 256M." + LangUtil.EOL + LangUtil.EOL + + "See the AspectJ FAQ available from the documentation link" + LangUtil.EOL + + "on the AspectJ home page at http://www.eclipse.org/aspectj"; private static final String MESSAGE_HOLDER_OPTION = "-messageHolder"; - - /** @param args the String[] of command-line arguments */ - public static void main(String[] args) throws IOException { - new Main().runMain(args, true); - } - + + /** @param args the String[] of command-line arguments */ + public static void main(String[] args) throws IOException { + new Main().runMain(args, true); + } + /** - * Convenience method to run ajc and collect String lists of messages. - * This can be reflectively invoked with the - * List collecting parameters supplied by a parent class loader. - * The String messages take the same form as command-line messages. + * Convenience method to run ajc and collect String lists of messages. This can be reflectively invoked with the List collecting + * parameters supplied by a parent class loader. The String messages take the same form as command-line messages. + * * @param args the String[] args to pass to the compiler * @param useSystemExit if true and errors, return System.exit(errs) - * @param fails the List sink, if any, for String failure (or worse) messages + * @param fails the List sink, if any, for String failure (or worse) messages * @param errors the List sink, if any, for String error messages * @param warnings the List sink, if any, for String warning messages * @param info the List sink, if any, for String info messages * @return number of messages reported with level ERROR or above - * @throws any unchecked exceptions the compiler does + * @throws any unchecked exceptions the compiler does */ - public static int bareMain( - String[] args, - boolean useSystemExit, - List fails, - List errors, - List warnings, - List infos) { + public static int bareMain(String[] args, boolean useSystemExit, List fails, List errors, List warnings, List infos) { Main main = new Main(); MessageHandler holder = new MessageHandler(); main.setHolder(holder); @@ -123,12 +112,8 @@ public class Main { return holder.numMessages(IMessage.ERROR, true); } - /** Read messages of a given kind into a List as String */ - private static void readMessages( - IMessageHolder holder, - IMessage.Kind kind, - boolean orGreater, - List sink) { + /** Read messages of a given kind into a List as String */ + private static void readMessages(IMessageHolder holder, IMessage.Kind kind, boolean orGreater, List sink) { if ((null == sink) || (null == holder)) { return; } @@ -139,161 +124,153 @@ public class Main { } } } - - /** - * @return String rendering throwable as compiler error for user/console, - * including information on how to report as a bug. - * @throws NullPointerException if thrown is null - */ - public static String renderExceptionForUser(Throwable thrown) { - String m = thrown.getMessage(); - return THROWN_PREFIX - + (null != m ? m + "\n": "") - + "\n" + CompilationAndWeavingContext.getCurrentContext() - + LangUtil.renderException(thrown, true); - } - - - private static String parmInArgs(String flag, String[] args) { - int loc = 1+(null == args ? -1 :Arrays.asList(args).indexOf(flag)); - return ((0 == loc) || (args.length <= loc)?null:args[loc]); - } - - private static boolean flagInArgs(String flag, String[] args) { - return ((null != args) && (Arrays.asList(args).indexOf(flag) != -1)); - } - - /** append nothing if numItems is 0, - * numItems + label + (numItems > 1? "s" : "") otherwise, - * prefixing with " " if sink has content - */ - private static void appendNLabel(StringBuffer sink, String label, int numItems) { - if (0 == numItems) { - return; - } - if (0 < sink.length()) { - sink.append(", "); - } - sink.append(numItems + " "); - if (!LangUtil.isEmpty(label)) { - sink.append(label); - } - if (1 < numItems) { - sink.append("s"); - } - } - - /** control iteration/continuation for command (compiler) */ - protected CommandController controller; - - /** ReflectionFactory identifier for command (compiler) */ - protected String commandName; - - /** client-set message sink */ - private IMessageHolder clientHolder; - - /** internally-set message sink */ - protected final MessageHandler ourHandler; - - private int lastFails; - private int lastErrors; - - /** if not null, run this synchronously after each compile completes */ - private Runnable completionRunner; - - public Main() { - controller = new CommandController(); - commandName = ReflectionFactory.ECLIPSE; - ourHandler = new MessageHandler(true); - } - - public MessageHandler getMessageHandler() { - return ourHandler; - } - - // for unit testing... - void setController(CommandController controller) { - this.controller = controller; - } - - /** - * Run without throwing exceptions but optionally using System.exit(..). - * This sets up a message handler which emits messages immediately, - * so report(boolean, IMessageHandler) only reports total number - * of errors or warnings. - * @param args the String[] command line for the compiler - * @param useSystemExit if true, use System.exit(int) to complete - * unless one of the args is -noExit. - * and signal result (0 no exceptions/error, <0 exceptions, >0 compiler errors). - */ - public void runMain(String[] args, boolean useSystemExit) { - // Urk - default no check for AJDT, enabled here for Ant, command-line - AjBuildManager.enableRuntimeVersionCheck(this); - final boolean verbose = flagInArgs("-verbose", args); - final boolean timers = flagInArgs("-timers", args); - if (null == this.clientHolder) { - this.clientHolder = checkForCustomMessageHolder(args); - } - IMessageHolder holder = clientHolder; - if (null == holder) { - holder = ourHandler; - if (verbose) { - ourHandler.setInterceptor(MessagePrinter.VERBOSE); - } else { - ourHandler.ignore(IMessage.INFO); - ourHandler.setInterceptor(MessagePrinter.TERSE); - } - } - - // make sure we handle out of memory gracefully... - try { - // byte[] b = new byte[100000000]; for testing OoME only! - long stime = System.currentTimeMillis(); - // uncomment next line to pause before startup (attach jconsole) -// try {Thread.sleep(5000); }catch(Exception e) {} - run(args, holder); - long etime = System.currentTimeMillis(); - if (timers) { - System.out.println("Compiler took "+(etime-stime)+"ms"); - } - holder.handleMessage(MessageUtil.info("Compiler took "+(etime-stime)+"ms")); - // uncomment next line to pause at end (keeps jconsole alive!) -// try { System.in.read(); } catch (Exception e) {} - } - catch (OutOfMemoryError outOfMemory) { - IMessage outOfMemoryMessage = new Message(OUT_OF_MEMORY_MSG,null,true); - holder.handleMessage(outOfMemoryMessage); - systemExit(holder); // we can't reasonably continue from this point. - } - finally { - CompilationAndWeavingContext.reset(); - Dump.reset(); - } - - boolean skipExit = false; - if (useSystemExit && !LangUtil.isEmpty(args)) { // sigh - pluck -noExit - for (int i = 0; i < args.length; i++) { + + /** + * @return String rendering throwable as compiler error for user/console, including information on how to report as a bug. + * @throws NullPointerException if thrown is null + */ + public static String renderExceptionForUser(Throwable thrown) { + String m = thrown.getMessage(); + return THROWN_PREFIX + (null != m ? m + "\n" : "") + "\n" + CompilationAndWeavingContext.getCurrentContext() + + LangUtil.renderException(thrown, true); + } + + private static String parmInArgs(String flag, String[] args) { + int loc = 1 + (null == args ? -1 : Arrays.asList(args).indexOf(flag)); + return ((0 == loc) || (args.length <= loc) ? null : args[loc]); + } + + private static boolean flagInArgs(String flag, String[] args) { + return ((null != args) && (Arrays.asList(args).indexOf(flag) != -1)); + } + + /** + * append nothing if numItems is 0, numItems + label + (numItems > 1? "s" : "") otherwise, prefixing with " " if sink has + * content + */ + private static void appendNLabel(StringBuffer sink, String label, int numItems) { + if (0 == numItems) { + return; + } + if (0 < sink.length()) { + sink.append(", "); + } + sink.append(numItems + " "); + if (!LangUtil.isEmpty(label)) { + sink.append(label); + } + if (1 < numItems) { + sink.append("s"); + } + } + + /** control iteration/continuation for command (compiler) */ + protected CommandController controller; + + /** ReflectionFactory identifier for command (compiler) */ + protected String commandName; + + /** client-set message sink */ + private IMessageHolder clientHolder; + + /** internally-set message sink */ + protected final MessageHandler ourHandler; + + private int lastFails; + private int lastErrors; + + /** if not null, run this synchronously after each compile completes */ + private Runnable completionRunner; + + public Main() { + controller = new CommandController(); + commandName = ReflectionFactory.ECLIPSE; + ourHandler = new MessageHandler(true); + } + + public MessageHandler getMessageHandler() { + return ourHandler; + } + + // for unit testing... + void setController(CommandController controller) { + this.controller = controller; + } + + /** + * Run without throwing exceptions but optionally using System.exit(..). This sets up a message handler which emits messages + * immediately, so report(boolean, IMessageHandler) only reports total number of errors or warnings. + * + * @param args the String[] command line for the compiler + * @param useSystemExit if true, use System.exit(int) to complete unless one of the args is -noExit. and signal result (0 no + * exceptions/error, <0 exceptions, >0 compiler errors). + */ + public void runMain(String[] args, boolean useSystemExit) { + // Urk - default no check for AJDT, enabled here for Ant, command-line + AjBuildManager.enableRuntimeVersionCheck(this); + final boolean verbose = flagInArgs("-verbose", args); + final boolean timers = flagInArgs("-timers", args); + if (null == this.clientHolder) { + this.clientHolder = checkForCustomMessageHolder(args); + } + IMessageHolder holder = clientHolder; + if (null == holder) { + holder = ourHandler; + if (verbose) { + ourHandler.setInterceptor(MessagePrinter.VERBOSE); + } else { + ourHandler.ignore(IMessage.INFO); + ourHandler.setInterceptor(MessagePrinter.TERSE); + } + } + + // make sure we handle out of memory gracefully... + try { + // byte[] b = new byte[100000000]; for testing OoME only! + long stime = System.currentTimeMillis(); + // uncomment next line to pause before startup (attach jconsole) + // try {Thread.sleep(5000); }catch(Exception e) {} + run(args, holder); + long etime = System.currentTimeMillis(); + if (timers) { + System.out.println("Compiler took " + (etime - stime) + "ms"); + } + holder.handleMessage(MessageUtil.info("Compiler took " + (etime - stime) + "ms")); + // uncomment next line to pause at end (keeps jconsole alive!) + // try { System.in.read(); } catch (Exception e) {} + } catch (OutOfMemoryError outOfMemory) { + IMessage outOfMemoryMessage = new Message(OUT_OF_MEMORY_MSG, null, true); + holder.handleMessage(outOfMemoryMessage); + systemExit(holder); // we can't reasonably continue from this point. + } finally { + CompilationAndWeavingContext.reset(); + Dump.reset(); + } + + boolean skipExit = false; + if (useSystemExit && !LangUtil.isEmpty(args)) { // sigh - pluck -noExit + for (int i = 0; i < args.length; i++) { if ("-noExit".equals(args[i])) { - skipExit = true; - break; - } + skipExit = true; + break; + } } - } - if (useSystemExit && !skipExit) { - systemExit(holder); - } - } - - // put calls around run() call above to allowing connecting jconsole -// private void pause(int ms) { -// try { -// System.err.println("Pausing for "+ms+"ms"); -// System.gc(); -// Thread.sleep(ms); -// System.gc(); -// System.err.println("Continuing"); -// } catch (Exception e) {} -// } + } + if (useSystemExit && !skipExit) { + systemExit(holder); + } + } + + // put calls around run() call above to allowing connecting jconsole + // private void pause(int ms) { + // try { + // System.err.println("Pausing for "+ms+"ms"); + // System.gc(); + // Thread.sleep(ms); + // System.gc(); + // System.err.println("Continuing"); + // } catch (Exception e) {} + // } /** * @param args @@ -304,565 +281,551 @@ public class Main { if (customMessageHolder != null) { try { holder = (IMessageHolder) Class.forName(customMessageHolder).newInstance(); - } - catch(Exception ex) { + } catch (Exception ex) { holder = ourHandler; - throw new AbortException("Failed to create custom message holder of class '" + - customMessageHolder + "' : " + ex); + throw new AbortException("Failed to create custom message holder of class '" + customMessageHolder + "' : " + ex); } } return holder; } - /** - * Run without using System.exit(..), putting all messages in holder: - * <ul> - * <li>ERROR: compiler error</li> - * <li>WARNING: compiler warning</li> - * <li>FAIL: command error (bad arguments, exception thrown)</li> - * </ul> - * This handles incremental behavior: - * <ul> - * <li>If args include "-incremental", repeat for every input char - * until 'q' is entered.<li> - * <li>If args include "-incrementalTagFile {file}", repeat every time - * we detect that {file} modification time has changed. </li> - * <li>Either way, list files recompiled each time if args includes "-verbose".</li> - * <li>Exit when the commmand/compiler throws any Throwable.</li> - * </ul> - * When complete, this contains all the messages of the final - * run of the command and/or any FAIL messages produced in running - * the command, including any Throwable thrown by the command itself. - * - * @param args the String[] command line for the compiler - * @param holder the MessageHandler sink for messages. - */ - public void run(String[] args, IMessageHolder holder) { + /** + * Run without using System.exit(..), putting all messages in holder: + * <ul> + * <li>ERROR: compiler error</li> <li>WARNING: compiler warning</li> <li>FAIL: command error (bad arguments, exception thrown) + * </li> + * </ul> + * This handles incremental behavior: + * <ul> + * <li>If args include "-incremental", repeat for every input char until 'q' is entered.<li> <li>If args include + * "-incrementalTagFile {file}", repeat every time we detect that {file} modification time has changed. </li> <li>Either way, + * list files recompiled each time if args includes "-verbose".</li> <li>Exit when the commmand/compiler throws any Throwable. + * </li> + * </ul> + * When complete, this contains all the messages of the final run of the command and/or any FAIL messages produced in running + * the command, including any Throwable thrown by the command itself. + * + * @param args the String[] command line for the compiler + * @param holder the MessageHandler sink for messages. + */ + public void run(String[] args, IMessageHolder holder) { PrintStream logStream = null; FileOutputStream fos = null; - String logFileName = parmInArgs("-log", args); - if (null != logFileName){ + String logFileName = parmInArgs("-log", args); + if (null != logFileName) { File logFile = new File(logFileName); - try{ + try { logFile.createNewFile(); fos = new FileOutputStream(logFileName, true); - logStream = new PrintStream(fos,true); - } catch(Exception e){ - fail(holder, "Couldn't open log file: " + logFileName, e); + logStream = new PrintStream(fos, true); + } catch (Exception e) { + fail(holder, "Couldn't open log file: " + logFileName, e); } Date now = new Date(); logStream.println(now.toString()); if (flagInArgs("-verbose", args)) { - ourHandler.setInterceptor(new LogModeMessagePrinter(true,logStream)); - } else { - ourHandler.ignore(IMessage.INFO); - ourHandler.setInterceptor(new LogModeMessagePrinter(false,logStream)); - } + ourHandler.setInterceptor(new LogModeMessagePrinter(true, logStream)); + } else { + ourHandler.ignore(IMessage.INFO); + ourHandler.setInterceptor(new LogModeMessagePrinter(false, logStream)); + } holder = ourHandler; } - + if (LangUtil.isEmpty(args)) { - args = new String[] { "-?" }; - } else if (controller.running()) { - fail(holder, "already running with controller: " + controller, null); - return; - } - args = controller.init(args, holder); - if (0 < holder.numMessages(IMessage.ERROR, true)) { - return; - } - ICommand command = ReflectionFactory.makeCommand(commandName, holder); - if (0 < holder.numMessages(IMessage.ERROR, true)) { - return; - } - try { - outer: - while (true) { - boolean passed = command.runCommand(args, holder); - if (report(passed, holder) && controller.incremental()) { - while (controller.doRepeatCommand(command)) { - holder.clearMessages(); - if (controller.buildFresh()) { - continue outer; - } else { - passed = command.repeatCommand(holder); - } - if (!report(passed, holder)) { - break; - } - } - } - break; - } - } catch (AbortException ae) { - if (ae.isSilent()) { - quit(); - } else { - IMessage message = ae.getIMessage(); - Throwable thrown = ae.getThrown(); - if (null == thrown) { // toss AbortException wrapper - if (null != message) { - holder.handleMessage(message); - } else { - fail(holder, "abort without message", ae); - } - } else if (null == message) { - fail(holder, "aborted", thrown); - } else { - String mssg = MessageUtil.MESSAGE_MOST.renderToString(message); - fail(holder, mssg, thrown); - } - } - } catch (Throwable t) { - fail(holder, "unexpected exception", t); - } finally{ - if (logStream != null){ + args = new String[] { "-?" }; + } else if (controller.running()) { + fail(holder, "already running with controller: " + controller, null); + return; + } + args = controller.init(args, holder); + if (0 < holder.numMessages(IMessage.ERROR, true)) { + return; + } + ICommand command = ReflectionFactory.makeCommand(commandName, holder); + if (0 < holder.numMessages(IMessage.ERROR, true)) { + return; + } + try { + outer: while (true) { + boolean passed = command.runCommand(args, holder); + if (report(passed, holder) && controller.incremental()) { + while (controller.doRepeatCommand(command)) { + holder.clearMessages(); + if (controller.buildFresh()) { + continue outer; + } else { + passed = command.repeatCommand(holder); + } + if (!report(passed, holder)) { + break; + } + } + } + break; + } + } catch (AbortException ae) { + if (ae.isSilent()) { + quit(); + } else { + IMessage message = ae.getIMessage(); + Throwable thrown = ae.getThrown(); + if (null == thrown) { // toss AbortException wrapper + if (null != message) { + holder.handleMessage(message); + } else { + fail(holder, "abort without message", ae); + } + } else if (null == message) { + fail(holder, "aborted", thrown); + } else { + String mssg = MessageUtil.MESSAGE_MOST.renderToString(message); + fail(holder, mssg, thrown); + } + } + } catch (Throwable t) { + fail(holder, "unexpected exception", t); + } finally { + if (logStream != null) { logStream.close(); logStream = null; } - if (fos != null){ + if (fos != null) { try { fos.close(); - } catch (IOException e){ + } catch (IOException e) { fail(holder, "unexpected exception", e); } fos = null; } - } - } - - /** call this to stop after the next iteration of incremental compile */ - public void quit() { - controller.quit(); - } - - /** - * Set holder to be passed all messages. - * When holder is set, messages will not be printed by default. - * @param holder the IMessageHolder sink for all messages - * (use null to restore default behavior) - */ - public void setHolder(IMessageHolder holder) { - clientHolder = holder; - } - - public IMessageHolder getHolder() { - return clientHolder; - } - - /** - * Install a Runnable to be invoked synchronously - * after each compile completes. - * @param runner the Runnable to invoke - null to disable - */ - public void setCompletionRunner(Runnable runner) { - this.completionRunner = runner; - } - - /** - * Call System.exit(int) with values derived from the number - * of failures/aborts or errors in messages. - * @param messages the IMessageHolder to interrogate. - * @param messages - */ - protected void systemExit(IMessageHolder messages) { - int num = lastFails; // messages.numMessages(IMessage.FAIL, true); - if (0 < num) { - System.exit(-num); - } - num = lastErrors; // messages.numMessages(IMessage.ERROR, false); - if (0 < num) { - System.exit(num); - } - System.exit(0); - } - - /** Messages to the user */ - protected void outMessage(String message) { // XXX coordinate with MessagePrinter - System.out.print(message); - System.out.flush(); - } - - /** - * Report results from a (possibly-incremental) compile run. - * This delegates to any reportHandler or otherwise - * prints summary counts of errors/warnings to System.err (if any errors) - * or System.out (if only warnings). - * WARNING: this silently ignores other messages like FAIL, - * but clears the handler of all messages when returning true. XXX false - * - * This implementation ignores the pass parameter but - * clears the holder after reporting - * on the assumption messages were handled/printed already. - * (ignoring UnsupportedOperationException from holder.clearMessages()). - * @param pass true result of the command - * @param holder IMessageHolder with messages from the command - * @see reportCommandResults(IMessageHolder) - * @return false if the process should abort - */ - protected boolean report(boolean pass, IMessageHolder holder) { - lastFails = holder.numMessages(IMessage.FAIL, true); - boolean result = (0 == lastFails); - final Runnable runner = completionRunner; - if (null != runner) { - runner.run(); - } - if (holder == ourHandler) { - lastErrors = holder.numMessages(IMessage.ERROR, false); - int warnings = holder.numMessages(IMessage.WARNING, false); - StringBuffer sb = new StringBuffer(); - appendNLabel(sb, "fail|abort", lastFails); - appendNLabel(sb, "error", lastErrors); - appendNLabel(sb, "warning", warnings); - if (0 < sb.length()) { - PrintStream out = (0 < (lastErrors + lastFails) - ? System.err - : System.out); - out.println(""); // XXX "wrote class file" messages no eol? - out.println(sb.toString()); - } - } - return result; - } - - /** convenience API to make fail messages (without MessageUtils's fail prefix) */ - protected static void fail(IMessageHandler handler, String message, Throwable thrown) { - handler.handleMessage(new Message(message, IMessage.FAIL, thrown, null)); - } - - /** - * interceptor IMessageHandler to print as we go. - * This formats all messages to the user. - */ - public static class MessagePrinter implements IMessageHandler { - - public static final IMessageHandler VERBOSE - = new MessagePrinter(true); - public static final IMessageHandler TERSE - = new MessagePrinter(false); - - final boolean verbose; + } + } + + /** call this to stop after the next iteration of incremental compile */ + public void quit() { + controller.quit(); + } + + /** + * Set holder to be passed all messages. When holder is set, messages will not be printed by default. + * + * @param holder the IMessageHolder sink for all messages (use null to restore default behavior) + */ + public void setHolder(IMessageHolder holder) { + clientHolder = holder; + } + + public IMessageHolder getHolder() { + return clientHolder; + } + + /** + * Install a Runnable to be invoked synchronously after each compile completes. + * + * @param runner the Runnable to invoke - null to disable + */ + public void setCompletionRunner(Runnable runner) { + this.completionRunner = runner; + } + + /** + * Call System.exit(int) with values derived from the number of failures/aborts or errors in messages. + * + * @param messages the IMessageHolder to interrogate. + * @param messages + */ + protected void systemExit(IMessageHolder messages) { + int num = lastFails; // messages.numMessages(IMessage.FAIL, true); + if (0 < num) { + System.exit(-num); + } + num = lastErrors; // messages.numMessages(IMessage.ERROR, false); + if (0 < num) { + System.exit(num); + } + System.exit(0); + } + + /** Messages to the user */ + protected void outMessage(String message) { // XXX coordinate with MessagePrinter + System.out.print(message); + System.out.flush(); + } + + /** + * Report results from a (possibly-incremental) compile run. This delegates to any reportHandler or otherwise prints summary + * counts of errors/warnings to System.err (if any errors) or System.out (if only warnings). WARNING: this silently ignores + * other messages like FAIL, but clears the handler of all messages when returning true. XXX false + * + * This implementation ignores the pass parameter but clears the holder after reporting on the assumption messages were + * handled/printed already. (ignoring UnsupportedOperationException from holder.clearMessages()). + * + * @param pass true result of the command + * @param holder IMessageHolder with messages from the command + * @see reportCommandResults(IMessageHolder) + * @return false if the process should abort + */ + protected boolean report(boolean pass, IMessageHolder holder) { + lastFails = holder.numMessages(IMessage.FAIL, true); + boolean result = (0 == lastFails); + final Runnable runner = completionRunner; + if (null != runner) { + runner.run(); + } + if (holder == ourHandler) { + lastErrors = holder.numMessages(IMessage.ERROR, false); + int warnings = holder.numMessages(IMessage.WARNING, false); + StringBuffer sb = new StringBuffer(); + appendNLabel(sb, "fail|abort", lastFails); + appendNLabel(sb, "error", lastErrors); + appendNLabel(sb, "warning", warnings); + if (0 < sb.length()) { + PrintStream out = (0 < (lastErrors + lastFails) ? System.err : System.out); + out.println(""); // XXX "wrote class file" messages no eol? + out.println(sb.toString()); + } + } + return result; + } + + /** convenience API to make fail messages (without MessageUtils's fail prefix) */ + protected static void fail(IMessageHandler handler, String message, Throwable thrown) { + handler.handleMessage(new Message(message, IMessage.FAIL, thrown, null)); + } + + /** + * interceptor IMessageHandler to print as we go. This formats all messages to the user. + */ + public static class MessagePrinter implements IMessageHandler { + + public static final IMessageHandler VERBOSE = new MessagePrinter(true); + public static final IMessageHandler TERSE = new MessagePrinter(false); + + final boolean verbose; + protected MessagePrinter(boolean verbose) { - this.verbose = verbose; - } - - /** - * Print errors and warnings to System.err, - * and optionally info to System.out, - * rendering message String only. - * @return false always - */ - public boolean handleMessage(IMessage message) { + this.verbose = verbose; + } + + /** + * Print errors and warnings to System.err, and optionally info to System.out, rendering message String only. + * + * @return false always + */ + public boolean handleMessage(IMessage message) { if (null != message) { - PrintStream out = getStreamFor(message.getKind()); - if (null != out) { - out.println(render(message)); - } - } - return false; - } - - /** - * Render message differently. - * If abort, then prefix stack trace with feedback request. - * If the actual message is empty, then use toString on the whole. - * Prefix message part with file:line; - * If it has context, suffix message with context. - * @param message the IMessage to render - * @return String rendering IMessage (never null) - */ - public static String render(IMessage message) { -// IMessage.Kind kind = message.getKind(); - - StringBuffer sb = new StringBuffer(); - String text = message.getMessage(); - if (text.equals(AbortException.NO_MESSAGE_TEXT)) { - text = null; - } - boolean toString = (LangUtil.isEmpty(text)); - if (toString) { - text = message.toString(); - } - ISourceLocation loc = message.getSourceLocation(); - String context = null; - if (null != loc) { - File file = loc.getSourceFile(); - if (null != file) { - String name = file.getName(); - if (!toString || (-1 == text.indexOf(name))) { - sb.append(FileUtil.getBestPath(file)); - if (loc.getLine() > 0) { - sb.append(":" + loc.getLine()); - } - int col = loc.getColumn(); - if (0 < col) { - sb.append(":" + col); - } - sb.append(" "); - } - } - context = loc.getContext(); - } - - // per Wes' suggestion on dev... - if (message.getKind() == IMessage.ERROR) { - sb.append("[error] "); - } else if (message.getKind() == IMessage.WARNING) { - sb.append("[warning] "); - } - - sb.append(text); - if (null != context) { - sb.append(LangUtil.EOL); - sb.append(context); - } - - String details = message.getDetails(); - if (details != null) { - sb.append(LangUtil.EOL); - sb.append('\t'); - sb.append(details); - } - Throwable thrown = message.getThrown(); - if (null != thrown) { - sb.append(LangUtil.EOL); - sb.append(Main.renderExceptionForUser(thrown)); - } - - if (message.getExtraSourceLocations().isEmpty()) { + PrintStream out = getStreamFor(message.getKind()); + if (null != out) { + out.println(render(message)); + } + } + return false; + } + + /** + * Render message differently. If abort, then prefix stack trace with feedback request. If the actual message is empty, then + * use toString on the whole. Prefix message part with file:line; If it has context, suffix message with context. + * + * @param message the IMessage to render + * @return String rendering IMessage (never null) + */ + public static String render(IMessage message) { + // IMessage.Kind kind = message.getKind(); + + StringBuffer sb = new StringBuffer(); + String text = message.getMessage(); + if (text.equals(AbortException.NO_MESSAGE_TEXT)) { + text = null; + } + boolean toString = (LangUtil.isEmpty(text)); + if (toString) { + text = message.toString(); + } + ISourceLocation loc = message.getSourceLocation(); + String context = null; + if (null != loc) { + File file = loc.getSourceFile(); + if (null != file) { + String name = file.getName(); + if (!toString || (-1 == text.indexOf(name))) { + sb.append(FileUtil.getBestPath(file)); + if (loc.getLine() > 0) { + sb.append(":" + loc.getLine()); + } + int col = loc.getColumn(); + if (0 < col) { + sb.append(":" + col); + } + sb.append(" "); + } + } + context = loc.getContext(); + } + + // per Wes' suggestion on dev... + if (message.getKind() == IMessage.ERROR) { + sb.append("[error] "); + } else if (message.getKind() == IMessage.WARNING) { + sb.append("[warning] "); + } + + sb.append(text); + if (null != context) { + sb.append(LangUtil.EOL); + sb.append(context); + } + + String details = message.getDetails(); + if (details != null) { + sb.append(LangUtil.EOL); + sb.append('\t'); + sb.append(details); + } + Throwable thrown = message.getThrown(); + if (null != thrown) { + sb.append(LangUtil.EOL); + sb.append(Main.renderExceptionForUser(thrown)); + } + + if (message.getExtraSourceLocations().isEmpty()) { return sb.toString(); - } else { - return MessageUtil.addExtraSourceLocations(message, sb.toString()); - } - - } + } else { + return MessageUtil.addExtraSourceLocations(message, sb.toString()); + } - public boolean isIgnoring(IMessage.Kind kind) { + } + + public boolean isIgnoring(IMessage.Kind kind) { return (null != getStreamFor(kind)); } - /** - * No-op - * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind) - * @param kind - */ - public void dontIgnore(IMessage.Kind kind) { - ; - } - - /** @return System.err for FAIL, ABORT, ERROR, and WARNING, - * System.out for INFO if -verbose and WEAVEINFO if -showWeaveInfo. - */ - protected PrintStream getStreamFor(IMessage.Kind kind) { - if (IMessage.WARNING.isSameOrLessThan(kind)) { - return System.err; - } else if (verbose && IMessage.INFO.equals(kind)) { - return System.out; - } else if (IMessage.WEAVEINFO.equals(kind)) { - return System.out; - } else { - return null; - } - } - - /** - * No-op - * @see org.aspectj.bridge.IMessageHandler#ignore(org.aspectj.bridge.IMessage.Kind) - * @param kind - */ + /** + * No-op + * + * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind) + * @param kind + */ + public void dontIgnore(IMessage.Kind kind) { + + } + + /** + * @return System.err for FAIL, ABORT, ERROR, and WARNING, System.out for INFO if -verbose and WEAVEINFO if -showWeaveInfo. + */ + protected PrintStream getStreamFor(IMessage.Kind kind) { + if (IMessage.WARNING.isSameOrLessThan(kind)) { + return System.err; + } else if (verbose && IMessage.INFO.equals(kind)) { + return System.out; + } else if (IMessage.WEAVEINFO.equals(kind)) { + return System.out; + } else { + return null; + } + } + + /** + * No-op + * + * @see org.aspectj.bridge.IMessageHandler#ignore(org.aspectj.bridge.IMessage.Kind) + * @param kind + */ public void ignore(Kind kind) { } - } - + } + public static class LogModeMessagePrinter extends MessagePrinter { - + protected final PrintStream logStream; - public LogModeMessagePrinter(boolean verbose, PrintStream logStream) { - super(verbose); + + public LogModeMessagePrinter(boolean verbose, PrintStream logStream) { + super(verbose); this.logStream = logStream; - } - + } + protected PrintStream getStreamFor(IMessage.Kind kind) { - if (IMessage.WARNING.isSameOrLessThan(kind)) { - return logStream; - } else if (verbose && IMessage.INFO.equals(kind)) { - return logStream; - } else if (IMessage.WEAVEINFO.equals(kind)) { - return logStream; - } else { - return null; - } - } - + if (IMessage.WARNING.isSameOrLessThan(kind)) { + return logStream; + } else if (verbose && IMessage.INFO.equals(kind)) { + return logStream; + } else if (IMessage.WEAVEINFO.equals(kind)) { + return logStream; + } else { + return null; + } + } + + } + + /** controller for repeatable command delays until input or file changed or removed */ + public static class CommandController { + public static String TAG_FILE_OPTION = "-XincrementalFile"; + public static String INCREMENTAL_OPTION = "-incremental"; + + /** maximum 10-minute delay between filesystem checks */ + public static long MAX_DELAY = 1000 * 600; + + /** default 5-second delay between filesystem checks */ + public static long DEFAULT_DELAY = 1000 * 5; + + /** @see init(String[]) */ + private static String[][] OPTIONS = new String[][] { new String[] { INCREMENTAL_OPTION }, + new String[] { TAG_FILE_OPTION, null } }; + + /** true between init(String[]) and doRepeatCommand() that returns false */ + private boolean running; + + /** true after quit() called */ + private boolean quit; + + /** true if incremental mode, waiting for input other than 'q' */ + private boolean incremental; + + /** true if incremental mode, waiting for file to change (repeat) or disappear (quit) */ + private File tagFile; + + /** last modification time for tagFile as of last command - 0 to start */ + private long fileModTime; + + /** delay between filesystem checks for tagFile modification time */ + private long delay; + + /** true just after user types 'r' for rebuild */ + private boolean buildFresh; + + public CommandController() { + delay = DEFAULT_DELAY; + } + + /** + * @param argList read and strip incremental args from this + * @param sink IMessageHandler for error messages + * @return String[] remainder of args + */ + public String[] init(String[] args, IMessageHandler sink) { + running = true; + // String[] unused; + if (!LangUtil.isEmpty(args)) { + String[][] options = LangUtil.copyStrings(OPTIONS); + /* unused = */LangUtil.extractOptions(args, options); + incremental = (null != options[0][0]); + if (null != options[1][0]) { + File file = new File(options[1][1]); + if (!file.exists()) { + MessageUtil.abort(sink, "tag file does not exist: " + file); + } else { + tagFile = file; + fileModTime = tagFile.lastModified(); + } + } + } + return args; + } + + /** + * @return true if init(String[]) called but doRepeatCommand has not returned false + */ + public boolean running() { + return running; + } + + /** @param delay milliseconds between filesystem checks */ + public void setDelay(long delay) { + if ((delay > -1) && (delay < MAX_DELAY)) { + this.delay = delay; + } + } + + /** @return true if INCREMENTAL_OPTION or TAG_FILE_OPTION was in args */ + public boolean incremental() { + return (incremental || (null != tagFile)); + } + + /** @return true if INCREMENTAL_OPTION was in args */ + public boolean commandLineIncremental() { + return incremental; + } + + public void quit() { + if (!quit) { + quit = true; + } + } + + /** @return true just after user typed 'r' */ + boolean buildFresh() { + return buildFresh; + } + + /** @return false if we should quit, true to do another command */ + boolean doRepeatCommand(ICommand command) { + if (!running) { + return false; + } + boolean result = false; + if (quit) { + result = false; + } else if (incremental) { + try { + if (buildFresh) { // reset before input request + buildFresh = false; + } + System.out.println(" press enter to recompile, r to rebuild, q to quit: "); + System.out.flush(); + // boolean doMore = false; + // seek for one q or a series of [\n\r]... + do { + int input = System.in.read(); + if ('q' == input) { + break; // result = false; + } else if ('r' == input) { + buildFresh = true; + result = true; + } else if (('\n' == input) || ('\r' == input)) { + result = true; + } // else eat anything else + } while (!result); + System.in.skip(Integer.MAX_VALUE); + } catch (IOException e) { // XXX silence for error? + result = false; + } + } else if (null != tagFile) { + long curModTime; + while (true) { + if (!tagFile.exists()) { + result = false; + break; + } else if (fileModTime == (curModTime = tagFile.lastModified())) { + fileCheckDelay(); + } else { + fileModTime = curModTime; + result = true; + break; + } + } + } // else, not incremental - false + if (!result && running) { + running = false; + } + return result; + } + + /** delay between filesystem checks, returning if quit is set */ + protected void fileCheckDelay() { + // final Thread thread = Thread.currentThread(); + long targetTime = System.currentTimeMillis() + delay; + // long curTime; + while (targetTime > System.currentTimeMillis()) { + if (quit) { + return; + } + try { + Thread.sleep(300); + } // 1/3-second delta for quit check + catch (InterruptedException e) { + } + } + } } - - /** controller for repeatable command delays until input or file changed or removed */ - public static class CommandController { - public static String TAG_FILE_OPTION = "-XincrementalFile"; - public static String INCREMENTAL_OPTION = "-incremental"; - - /** maximum 10-minute delay between filesystem checks */ - public static long MAX_DELAY = 1000 * 600; - - /** default 5-second delay between filesystem checks */ - public static long DEFAULT_DELAY = 1000 * 5; - - /** @see init(String[]) */ - private static String[][] OPTIONS = new String[][] - { new String[] { INCREMENTAL_OPTION }, - new String[] { TAG_FILE_OPTION, null } }; - - - /** true between init(String[]) and doRepeatCommand() that returns false */ - private boolean running; - - /** true after quit() called */ - private boolean quit; - - /** true if incremental mode, waiting for input other than 'q' */ - private boolean incremental; - - /** true if incremental mode, waiting for file to change (repeat) or disappear (quit) */ - private File tagFile; - - /** last modification time for tagFile as of last command - 0 to start */ - private long fileModTime; - - /** delay between filesystem checks for tagFile modification time */ - private long delay; - - /** true just after user types 'r' for rebuild */ - private boolean buildFresh; - - public CommandController() { - delay = DEFAULT_DELAY; - } - - /** - * @param argList read and strip incremental args from this - * @param sink IMessageHandler for error messages - * @return String[] remainder of args - */ - public String[] init(String[] args, IMessageHandler sink) { - running = true; -// String[] unused; - if (!LangUtil.isEmpty(args)) { - String[][] options = LangUtil.copyStrings(OPTIONS); - /*unused = */LangUtil.extractOptions(args, options); - incremental = (null != options[0][0]); - if (null != options[1][0]) { - File file = new File(options[1][1]); - if (!file.exists()) { - MessageUtil.abort(sink, "tag file does not exist: " + file); - } else { - tagFile = file; - fileModTime = tagFile.lastModified(); - } - } - } - return args; - } - - /** @return true if init(String[]) called but doRepeatCommand has not - * returned false */ - public boolean running() { - return running; - } - - /** @param delay milliseconds between filesystem checks */ - public void setDelay(long delay) { - if ((delay > -1) && (delay < MAX_DELAY)) { - this.delay = delay; - } - } - - /** @return true if INCREMENTAL_OPTION or TAG_FILE_OPTION was in args */ - public boolean incremental() { - return (incremental || (null != tagFile)); - } - - - /** @return true if INCREMENTAL_OPTION was in args */ - public boolean commandLineIncremental() { - return incremental; - } - - public void quit() { - if (!quit) { - quit = true; - } - } - /** @return true just after user typed 'r' */ - boolean buildFresh() { - return buildFresh; - } - - /** @return false if we should quit, true to do another command */ - boolean doRepeatCommand(ICommand command) { - if (!running) { - return false; - } - boolean result = false; - if (quit) { - result = false; - } else if (incremental) { - try { - if (buildFresh) { // reset before input request - buildFresh = false; - } - System.out.println(" press enter to recompile, r to rebuild, q to quit: "); - System.out.flush(); -// boolean doMore = false; - // seek for one q or a series of [\n\r]... - do { - int input = System.in.read(); - if ('q' == input) { - break; // result = false; - } else if ('r' == input) { - buildFresh = true; - result = true; - } else if (('\n' == input) || ('\r' == input)) { - result = true; - } // else eat anything else - } while (!result); - System.in.skip(Integer.MAX_VALUE); - } catch (IOException e) { // XXX silence for error? - result = false; - } - } else if (null != tagFile) { - long curModTime; - while (true) { - if (!tagFile.exists()) { - result = false; - break; - } else if (fileModTime == (curModTime = tagFile.lastModified())) { - fileCheckDelay(); - } else { - fileModTime = curModTime; - result = true; - break; - } - } - } // else, not incremental - false - if (!result && running) { - running = false; - } - return result; - } - - /** delay between filesystem checks, returning if quit is set */ - protected void fileCheckDelay() { -// final Thread thread = Thread.currentThread(); - long targetTime = System.currentTimeMillis() + delay; -// long curTime; - while (targetTime > System.currentTimeMillis()) { - if (quit) { - return; - } - try { Thread.sleep(300); } // 1/3-second delta for quit check - catch (InterruptedException e) {} - } - } - } } diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjASTTest.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjASTTest.java index 6b588513b..298040112 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjASTTest.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjASTTest.java @@ -372,7 +372,8 @@ public class AjASTTest extends AjASTTestCase { public void testPropertyDescriptorsForPointcutDeclaration() { AjAST ajast = createAjAST(); - PointcutDeclaration d = ajast.newPointcutDeclaration(); + // PointcutDeclaration d = + ajast.newPointcutDeclaration(); List props = PointcutDeclaration.propertyDescriptors(AST.JLS3); boolean foundJavadoc = false; boolean foundModifiers = false; @@ -484,7 +485,8 @@ public class AjASTTest extends AjASTTestCase { public void testPropertyDescriptorsForAspectDeclaration() { AjAST ajast = createAjAST(); - AspectDeclaration d = ajast.newAspectDeclaration(); + // AspectDeclaration d = + ajast.newAspectDeclaration(); List props = AspectDeclaration.propertyDescriptors(AST.JLS3); boolean foundJavadoc = false; boolean foundPerClause = false; @@ -745,13 +747,15 @@ public class AjASTTest extends AjASTTestCase { // associated with the AjTypeDeclaration public void testPropertyDescriptorsForAjTypeDeclaration2() { AjAST ajast = createAjAST(); - AspectDeclaration ad = ajast.newAspectDeclaration(); - List aspectProps = AspectDeclaration.propertyDescriptors(AST.JLS3); - AjTypeDeclaration d = ajast.newAjTypeDeclaration(); + // AspectDeclaration ad = + ajast.newAspectDeclaration(); + // List aspectProps = AspectDeclaration.propertyDescriptors(AST.JLS3); + // AjTypeDeclaration d = + ajast.newAjTypeDeclaration(); List props = AjTypeDeclaration.propertyDescriptors(AST.JLS3); boolean foundPrivileged = false; boolean foundPerClause = false; - boolean foundAspect = false; + // boolean foundAspect = false; for (Iterator iter = props.iterator(); iter.hasNext();) { Object o = iter.next(); if (o instanceof SimplePropertyDescriptor) { @@ -776,9 +780,12 @@ public class AjASTTest extends AjASTTestCase { // associated with the TypeDeclaration public void testPropertyDescriptorsForAjTypeDeclaration3() { AjAST ajast = createAjAST(); - AjTypeDeclaration d = ajast.newAjTypeDeclaration(); - List ajProps = AjTypeDeclaration.propertyDescriptors(AST.JLS3); - TypeDeclaration td = ajast.newTypeDeclaration(); + // AjTypeDeclaration d = + ajast.newAjTypeDeclaration(); + // List ajProps = + AjTypeDeclaration.propertyDescriptors(AST.JLS3); + // TypeDeclaration td = + ajast.newTypeDeclaration(); List props = TypeDeclaration.propertyDescriptors(AST.JLS3); boolean foundAspect = false; for (Iterator iter = props.iterator(); iter.hasNext();) { @@ -804,7 +811,8 @@ public class AjASTTest extends AjASTTestCase { public void testPropertyDescriptorsForDeclareAtField() { AjAST ajast = createAjAST(); - DeclareAtFieldDeclaration d = ajast.newDeclareAtFieldDeclaration(); + // DeclareAtFieldDeclaration d = + ajast.newDeclareAtFieldDeclaration(); List props = DeclareAtFieldDeclaration.propertyDescriptors(AST.JLS3); boolean foundJavadoc = false; boolean foundPattern = false; @@ -1097,7 +1105,8 @@ public class AjASTTest extends AjASTTestCase { public void testPropertyDescriptorsForDeclareAtType() { AjAST ajast = createAjAST(); - DeclareAtTypeDeclaration d = ajast.newDeclareAtTypeDeclaration(); + // DeclareAtTypeDeclaration d = + ajast.newDeclareAtTypeDeclaration(); List props = DeclareAtTypeDeclaration.propertyDescriptors(AST.JLS3); boolean foundJavadoc = false; boolean foundPattern = false; @@ -1194,7 +1203,8 @@ public class AjASTTest extends AjASTTestCase { public void testPropertyDescriptorsForDeclareErrorDeclaration() { AjAST ajast = createAjAST(); - DeclareErrorDeclaration d = ajast.newDeclareErrorDeclaration(); + // DeclareErrorDeclaration d = + ajast.newDeclareErrorDeclaration(); List props = DeclareErrorDeclaration.propertyDescriptors(AST.JLS3); boolean foundJavadoc = false; boolean foundPointcut = false; |