Update 'org.aspectj.ajdt.core' code to use genericstags/V1_9_19
options.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); | options.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); | ||||
} | } | ||||
private Collection collectSourceRootFiles(File dir) { | |||||
private Collection<File> collectSourceRootFiles(File dir) { | |||||
return Arrays.asList(FileUtil.listFiles(dir, FileUtil.aspectjSourceFileFilter)); | return Arrays.asList(FileUtil.listFiles(dir, FileUtil.aspectjSourceFileFilter)); | ||||
} | } | ||||
* in order to prevent wierd bootstrap issues (refer to bug#39959). | * in order to prevent wierd bootstrap issues (refer to bug#39959). | ||||
*/ | */ | ||||
public List getClasspath(AjcConfigParser parser) { | public List getClasspath(AjcConfigParser parser) { | ||||
List ret = new ArrayList(); | |||||
List<String> ret = new ArrayList<>(); | |||||
// if (parser.bootclasspath == null) { | // if (parser.bootclasspath == null) { | ||||
// addClasspath(System.getProperty("sun.boot.class.path", ""), ret); | // addClasspath(System.getProperty("sun.boot.class.path", ""), ret); | ||||
if (parser.classpath == null) { | if (parser.classpath == null) { | ||||
addClasspath(System.getProperty("java.class.path", ""), ret); | addClasspath(System.getProperty("java.class.path", ""), ret); | ||||
List fixedList = new ArrayList(); | |||||
List<String> fixedList = new ArrayList<>(); | |||||
for (Object o : ret) { | for (Object o : ret) { | ||||
String entry = (String) o; | String entry = (String) o; | ||||
if (!entry.endsWith("aspectjtools.jar")) { | if (!entry.endsWith("aspectjtools.jar")) { | ||||
return checkedClasspaths; | return checkedClasspaths; | ||||
} | } | ||||
private void addExtDirs(String extdirs, List classpathCollector) { | |||||
private void addExtDirs(String extdirs, List<String> classpathCollector) { | |||||
StringTokenizer tokenizer = new StringTokenizer(extdirs, File.pathSeparator); | StringTokenizer tokenizer = new StringTokenizer(extdirs, File.pathSeparator); | ||||
while (tokenizer.hasMoreTokens()) { | while (tokenizer.hasMoreTokens()) { | ||||
// classpathCollector.add(tokenizer.nextToken()); | // classpathCollector.add(tokenizer.nextToken()); | ||||
private String modulepath = null; | private String modulepath = null; | ||||
private String modulesourcepath = null; | private String modulesourcepath = null; | ||||
private String extdirs = null; | private String extdirs = null; | ||||
private List unparsedArgs = new ArrayList(); | |||||
private List<String> unparsedArgs = new ArrayList<>(); | |||||
private AjBuildConfig buildConfig; | private AjBuildConfig buildConfig; | ||||
private IMessageHandler handler; | private IMessageHandler handler; | ||||
private String moduleInfoArgument; | private String moduleInfoArgument; |
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation; | import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation; | ||||
import org.aspectj.weaver.bcel.BcelWeaver; | import org.aspectj.weaver.bcel.BcelWeaver; | ||||
import org.aspectj.weaver.bcel.BcelWorld; | import org.aspectj.weaver.bcel.BcelWorld; | ||||
import org.aspectj.weaver.bcel.UnwovenClassFile; | |||||
/** | /** | ||||
* @author colyer | * @author colyer | ||||
private AjState incrementalCompilationState; | private AjState incrementalCompilationState; | ||||
List /* InterimResult */resultsPendingWeave = new ArrayList(); | |||||
List<InterimCompilationResult> resultsPendingWeave = new ArrayList<>(); | |||||
/** | /** | ||||
* Create an adapter, and tell it everything it needs to now to drive the AspectJ parts of a compile cycle. | * Create an adapter, and tell it everything it needs to now to drive the AspectJ parts of a compile cycle. | ||||
// the compilation lifecycle methods below are called in order as compilation progresses... | // the compilation lifecycle methods below are called in order as compilation progresses... | ||||
public void beforeCompiling(ICompilationUnit[] sourceUnits) { | public void beforeCompiling(ICompilationUnit[] sourceUnits) { | ||||
resultsPendingWeave = new ArrayList(); | |||||
resultsPendingWeave = new ArrayList<>(); | |||||
reportedErrors = false; | reportedErrors = false; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
private List getBinarySourcesFrom(Map binarySourceEntries) { | |||||
private List<InterimCompilationResult> getBinarySourcesFrom(Map<String, List<UnwovenClassFile>> binarySourceEntries) { | |||||
// Map is fileName |-> List<UnwovenClassFile> | // Map is fileName |-> List<UnwovenClassFile> | ||||
List ret = new ArrayList(); | |||||
List<InterimCompilationResult> ret = new ArrayList<>(); | |||||
for (Object o : binarySourceEntries.keySet()) { | for (Object o : binarySourceEntries.keySet()) { | ||||
String sourceFileName = (String) o; | String sourceFileName = (String) o; | ||||
List unwovenClassFiles = (List) binarySourceEntries.get(sourceFileName); | |||||
List<UnwovenClassFile> unwovenClassFiles = binarySourceEntries.get(sourceFileName); | |||||
// XXX - see bugs 57432,58679 - final parameter on next call should be "compiler.options.maxProblemsPerUnit" | // 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(); | result.noSourceAvailable(); | ||||
} | } | ||||
resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourceSetForFullWeave)); | resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourceSetForFullWeave)); | ||||
} else { | } else { | ||||
Map binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave(); | |||||
Map<String, List<UnwovenClassFile>> binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave(); | |||||
resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourcesToAdd)); | resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourcesToAdd)); | ||||
} | } | ||||
// TESTING | // TESTING | ||||
if (pipelineTesting) { | if (pipelineTesting) { | ||||
if (pipelineOutput == null) { | if (pipelineOutput == null) { | ||||
pipelineOutput = new Hashtable(); | |||||
pipelineOutput = new Hashtable<>(); | |||||
} | } | ||||
pipelineOutput.put("filesContainingAspects", Integer.toString(toWaitFor)); | pipelineOutput.put("filesContainingAspects", Integer.toString(toWaitFor)); | ||||
StringBuilder order = new StringBuilder(); | StringBuilder order = new StringBuilder(); | ||||
} | } | ||||
resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourceSetForFullWeave)); | resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourceSetForFullWeave)); | ||||
} else { | } else { | ||||
Map binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave(); | |||||
Map<String, List<UnwovenClassFile>> binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave(); | |||||
resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourcesToAdd)); | resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourcesToAdd)); | ||||
} | } | ||||
} | } |
import org.aspectj.bridge.IMessage; | import org.aspectj.bridge.IMessage; | ||||
import org.aspectj.bridge.IProgressListener; | import org.aspectj.bridge.IProgressListener; | ||||
import org.aspectj.bridge.MessageUtil; | import org.aspectj.bridge.MessageUtil; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation; | import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation; | ||||
import org.aspectj.weaver.IClassFileProvider; | import org.aspectj.weaver.IClassFileProvider; | ||||
import org.aspectj.weaver.IUnwovenClassFile; | import org.aspectj.weaver.IUnwovenClassFile; | ||||
public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Iterator { | public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Iterator { | ||||
private final AbstractCompilerAdapter compilerAdapter; | private final AbstractCompilerAdapter compilerAdapter; | ||||
private Iterator resultIterator; | |||||
private Iterator<InterimCompilationResult> resultIterator; | |||||
private int classFileIndex = 0; | private int classFileIndex = 0; | ||||
private InterimCompilationResult nowProcessing; | private InterimCompilationResult nowProcessing; | ||||
private InterimCompilationResult lastReturnedResult; | private InterimCompilationResult lastReturnedResult; | ||||
compilerAdapter.acceptResult(result.result()); | compilerAdapter.acceptResult(result.result()); | ||||
} | } | ||||
private boolean removeFromMap(Map aMap, char[] key) { | |||||
private boolean removeFromMap(Map<char[], ClassFile> aMap, char[] key) { | |||||
// jdt uses char[] as a key in the hashtable, which is not very useful as equality is based on being | // jdt uses char[] as a key in the hashtable, which is not very useful as equality is based on being | ||||
// the same array, not having the same content. | // the same array, not having the same content. | ||||
// String skey = new String(key); | // String skey = new String(key); |
return context; | return context; | ||||
} | } | ||||
private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List sourceLocations, CompilationResult problemSource, | |||||
private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List<ISourceLocation> sourceLocations, CompilationResult problemSource, | |||||
boolean usedBinarySourceFileName) { | boolean usedBinarySourceFileName) { | ||||
List<IProblem> ret = new ArrayList<>(); | List<IProblem> ret = new ArrayList<>(); | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute; | |||||
import org.aspectj.weaver.AjAttribute; | import org.aspectj.weaver.AjAttribute; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; | import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; | import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; | ||||
*/ | */ | ||||
protected int generateInfoAttributes(ClassFile classFile) { | protected int generateInfoAttributes(ClassFile classFile) { | ||||
// add extra attributes into list then call 2-arg version of generateInfoAttributes... | // add extra attributes into list then call 2-arg version of generateInfoAttributes... | ||||
List extras = new ArrayList(); | |||||
List<IAttribute> extras = new ArrayList<>(); | |||||
addDeclarationStartLineAttribute(extras,classFile); | addDeclarationStartLineAttribute(extras,classFile); | ||||
return classFile.generateMethodInfoAttributes(binding,extras); | return classFile.generateMethodInfoAttributes(binding,extras); | ||||
} | } |
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; | import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; | import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; | import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; | ||||
import org.aspectj.weaver.AjAttribute; | import org.aspectj.weaver.AjAttribute; | ||||
*/ | */ | ||||
public class AjMethodDeclaration extends MethodDeclaration { | public class AjMethodDeclaration extends MethodDeclaration { | ||||
private List attributes = null; | |||||
private List<IAttribute> attributes = null; | |||||
/** | /** | ||||
* @param compilationResult | * @param compilationResult | ||||
// general purpose hook to add an AjAttribute to this method | // general purpose hook to add an AjAttribute to this method | ||||
// used by @AspectJ visitor to add pointcut attribute to @Advice | // used by @AspectJ visitor to add pointcut attribute to @Advice | ||||
protected void addAttribute(EclipseAttributeAdapter eaa) { | protected void addAttribute(EclipseAttributeAdapter eaa) { | ||||
if (attributes==null) attributes = new ArrayList(); | |||||
if (attributes==null) attributes = new ArrayList<>(); | |||||
attributes.add(eaa); | attributes.add(eaa); | ||||
} | } | ||||
*/ | */ | ||||
protected int generateInfoAttributes(ClassFile classFile,boolean addAjSynthetic) { | protected int generateInfoAttributes(ClassFile classFile,boolean addAjSynthetic) { | ||||
// add extra attributes into list then call 2-arg version of generateInfoAttributes... | // add extra attributes into list then call 2-arg version of generateInfoAttributes... | ||||
List extras = (attributes==null?new ArrayList():attributes); | |||||
List<IAttribute> extras = (attributes==null?new ArrayList<>():attributes); | |||||
addDeclarationStartLineAttribute(extras,classFile); | addDeclarationStartLineAttribute(extras,classFile); | ||||
if (addAjSynthetic) { | if (addAjSynthetic) { | ||||
extras.add(new EclipseAttributeAdapter(new AjAttribute.AjSynthetic())); | extras.add(new EclipseAttributeAdapter(new AjAttribute.AjSynthetic())); |
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; | import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; | import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; | import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Clinit; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Clinit; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; | ||||
* methods are able to masquerade as any join point (a field set, field get or method call). The effective signature attribute | * methods are able to masquerade as any join point (a field set, field get or method call). The effective signature attribute | ||||
* is 'unwrapped' in BcelClassWeaver.matchInvokeInstruction() | * is 'unwrapped' in BcelClassWeaver.matchInvokeInstruction() | ||||
*/ | */ | ||||
private void generateMethod(ClassFile classFile, MethodBinding methodBinding, List additionalAttributes, BodyGenerator gen) { | |||||
private void generateMethod(ClassFile classFile, MethodBinding methodBinding, List<EclipseAttributeAdapter> additionalAttributes, BodyGenerator gen) { | |||||
// EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope); | // EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope); | ||||
classFile.generateMethodInfoHeader(methodBinding); | classFile.generateMethodInfoHeader(methodBinding); | ||||
int methodAttributeOffset = classFile.contentsOffset; | int methodAttributeOffset = classFile.contentsOffset; | ||||
int attributeNumber; | int attributeNumber; | ||||
if (additionalAttributes != null) { // mini optimization | if (additionalAttributes != null) { // mini optimization | ||||
List attrs = new ArrayList(); | |||||
List<IAttribute> attrs = new ArrayList<>(); | |||||
attrs.addAll(AstUtil.getAjSyntheticAttribute()); | attrs.addAll(AstUtil.getAjSyntheticAttribute()); | ||||
attrs.addAll(additionalAttributes); | attrs.addAll(additionalAttributes); | ||||
attributeNumber = classFile.generateMethodInfoAttributes(methodBinding, attrs); | attributeNumber = classFile.generateMethodInfoAttributes(methodBinding, attrs); |
import java.util.List; | import java.util.List; | ||||
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; | import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument; | ||||
} | } | ||||
public static List getAjSyntheticAttribute() { | public static List getAjSyntheticAttribute() { | ||||
List ret = new ArrayList(1); | |||||
List<IAttribute> ret = new ArrayList<>(1); | |||||
ret.add(new EclipseAttributeAdapter(new AjAttribute.AjSynthetic())); | ret.add(new EclipseAttributeAdapter(new AjAttribute.AjSynthetic())); | ||||
return ret; | return ret; | ||||
} | } |
} else if (declareDecl instanceof DeclareParents) { | } else if (declareDecl instanceof DeclareParents) { | ||||
DeclareParents dp = (DeclareParents) declareDecl; | DeclareParents dp = (DeclareParents) declareDecl; | ||||
String childPattern = dp.getChild().toString(); | String childPattern = dp.getChild().toString(); | ||||
Collection parentPatterns = dp.getParents().getExactTypes(); | |||||
Collection<UnresolvedType> parentPatterns = dp.getParents().getExactTypes(); | |||||
StringBuilder parents = new StringBuilder(); | StringBuilder parents = new StringBuilder(); | ||||
for (Iterator iter = parentPatterns.iterator(); iter.hasNext();) { | |||||
for (Iterator<UnresolvedType> iter = parentPatterns.iterator(); iter.hasNext();) { | |||||
UnresolvedType urt = ((UnresolvedType) iter.next()); | UnresolvedType urt = ((UnresolvedType) iter.next()); | ||||
parents.append(urt.getName()); | parents.append(urt.getName()); | ||||
if (iter.hasNext()) { | if (iter.hasNext()) { |
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; | import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; | import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; | import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; | ||||
Shadow.Kind kind, | Shadow.Kind kind, | ||||
boolean weaveBody) | boolean weaveBody) | ||||
{ | { | ||||
List l = new ArrayList(1); | |||||
List<IAttribute> l = new ArrayList<>(1); | |||||
l.add(new EclipseAttributeAdapter( | l.add(new EclipseAttributeAdapter( | ||||
new AjAttribute.EffectiveSignatureAttribute(sig, kind, weaveBody))); | new AjAttribute.EffectiveSignatureAttribute(sig, kind, weaveBody))); | ||||
return l; | return l; | ||||
@Override | @Override | ||||
protected int generateInfoAttributes(ClassFile classFile) { | protected int generateInfoAttributes(ClassFile classFile) { | ||||
List l; | |||||
List<IAttribute> l; | |||||
Shadow.Kind kind = getShadowKindForBody(); | Shadow.Kind kind = getShadowKindForBody(); | ||||
if (kind != null) { | if (kind != null) { | ||||
l = makeEffectiveSignatureAttribute(munger.getSignature(), kind, true); | l = makeEffectiveSignatureAttribute(munger.getSignature(), kind, true); | ||||
} else { | } else { | ||||
l = new ArrayList(0); | |||||
l = new ArrayList<>(0); | |||||
} | } | ||||
addDeclarationStartLineAttribute(l,classFile); | addDeclarationStartLineAttribute(l,classFile); | ||||
if (onType instanceof ParameterizedSingleTypeReference) { | if (onType instanceof ParameterizedSingleTypeReference) { | ||||
ParameterizedSingleTypeReference paramRef = (ParameterizedSingleTypeReference) onType; | ParameterizedSingleTypeReference paramRef = (ParameterizedSingleTypeReference) onType; | ||||
TypeReference[] rb = paramRef.typeArguments; | TypeReference[] rb = paramRef.typeArguments; | ||||
typeVariableAliases = new ArrayList(); | |||||
typeVariableAliases = new ArrayList<>(); | |||||
for (TypeReference typeReference : rb) { | for (TypeReference typeReference : rb) { | ||||
typeVariableAliases.add(CharOperation.toString(typeReference.getTypeName())); | typeVariableAliases.add(CharOperation.toString(typeReference.getTypeName())); | ||||
} | } | ||||
} else if (onType instanceof ParameterizedQualifiedTypeReference) { | } else if (onType instanceof ParameterizedQualifiedTypeReference) { | ||||
ParameterizedQualifiedTypeReference paramRef = (ParameterizedQualifiedTypeReference) onType; | ParameterizedQualifiedTypeReference paramRef = (ParameterizedQualifiedTypeReference) onType; | ||||
typeVariableAliases = new ArrayList(); | |||||
typeVariableAliases = new ArrayList<>(); | |||||
for (int j = 0; j < paramRef.typeArguments.length; j++) { | for (int j = 0; j < paramRef.typeArguments.length; j++) { | ||||
TypeReference[] rb = paramRef.typeArguments[j]; | TypeReference[] rb = paramRef.typeArguments[j]; | ||||
for (int i = 0; rb!=null && i < rb.length; i++) { | for (int i = 0; rb!=null && i < rb.length; i++) { |
// afterThrowingAdviceSig, aroundAdviceSig }; | // afterThrowingAdviceSig, aroundAdviceSig }; | ||||
private final CompilationUnitDeclaration unit; | private final CompilationUnitDeclaration unit; | ||||
private final Stack typeStack = new Stack(); | |||||
private final Stack<TypeDeclaration> typeStack = new Stack<>(); | |||||
private AspectJAnnotations ajAnnotations; | private AspectJAnnotations ajAnnotations; | ||||
public ValidateAtAspectJAnnotationsVisitor(CompilationUnitDeclaration unit) { | public ValidateAtAspectJAnnotationsVisitor(CompilationUnitDeclaration unit) { | ||||
* @param arguments | * @param arguments | ||||
* @return argument names (possibly empty) | * @return argument names (possibly empty) | ||||
*/ | */ | ||||
private List toArgumentNames(Argument[] arguments) { | |||||
List names = new ArrayList(); | |||||
private List<String> toArgumentNames(Argument[] arguments) { | |||||
List<String> names = new ArrayList<>(); | |||||
if (arguments == null) { | if (arguments == null) { | ||||
return names; | return names; | ||||
} else { | } else { |
* interfaces targetted by ITDs that have to be implemented by accessing the topMostImplementor of the interface, yet the aspect | * interfaces targetted by ITDs that have to be implemented by accessing the topMostImplementor of the interface, yet the aspect | ||||
* where the ITD originated is not in the world | * where the ITD originated is not in the world | ||||
*/ | */ | ||||
private final Map dangerousInterfaces = new HashMap(); | |||||
private final Map<ResolvedType, String> dangerousInterfaces = new HashMap<>(); | |||||
public AjLookupEnvironment(ITypeRequestor typeRequestor, CompilerOptions options, ProblemReporter problemReporter, | public AjLookupEnvironment(ITypeRequestor typeRequestor, CompilerOptions options, ProblemReporter problemReporter, | ||||
INameEnvironment nameEnvironment) { | INameEnvironment nameEnvironment) { | ||||
// dangerous interface - | // dangerous interface - | ||||
// report a problem if it is. | // report a problem if it is. | ||||
for (Object o : dangerousInterfaces.entrySet()) { | for (Object o : dangerousInterfaces.entrySet()) { | ||||
Map.Entry entry = (Map.Entry) o; | |||||
Map.Entry<ResolvedType, String> entry = (Map.Entry) o; | |||||
ResolvedType interfaceType = (ResolvedType) entry.getKey(); | ResolvedType interfaceType = (ResolvedType) entry.getKey(); | ||||
if (onType.isTopmostImplementor(interfaceType)) { | if (onType.isTopmostImplementor(interfaceType)) { | ||||
factory.showMessage(IMessage.ERROR, onType + ": " + entry.getValue(), onType.getSourceLocation(), null); | factory.showMessage(IMessage.ERROR, onType + ": " + entry.getValue(), onType.getSourceLocation(), null); | ||||
} | } | ||||
} | } | ||||
private final List pendingTypesToFinish = new ArrayList(); | |||||
private final List<BinaryTypeBinding> pendingTypesToFinish = new ArrayList<>(); | |||||
boolean inBinaryTypeCreationAndWeaving = false; | boolean inBinaryTypeCreationAndWeaving = false; | ||||
boolean processingTheQueue = false; | boolean processingTheQueue = false; | ||||
public class PrivilegedHandler implements IPrivilegedHandler { | public class PrivilegedHandler implements IPrivilegedHandler { | ||||
private AspectDeclaration inAspect; | private AspectDeclaration inAspect; | ||||
private Map accessors = new HashMap(); | |||||
private Map<ResolvedMember, Object> accessors = new HashMap<>(); | |||||
public PrivilegedHandler(AspectDeclaration inAspect) { | public PrivilegedHandler(AspectDeclaration inAspect) { | ||||
this.inAspect = inAspect; | this.inAspect = inAspect; | ||||
} | } | ||||
public ResolvedMember[] getMembers() { | public ResolvedMember[] getMembers() { | ||||
Collection m = accessors.keySet(); | |||||
Collection<ResolvedMember> m = accessors.keySet(); | |||||
int len = m.size(); | int len = m.size(); | ||||
ResolvedMember[] ret = new ResolvedMember[len]; | ResolvedMember[] ret = new ResolvedMember[len]; | ||||
int index = 0; | int index = 0; |
} else { | } else { | ||||
weaverType = factory.fromEclipse(type.superclass()); | weaverType = factory.fromEclipse(type.superclass()); | ||||
} | } | ||||
Set checked = new HashSet(); | |||||
Set<ResolvedType> checked = new HashSet<>(); | |||||
for (ConcreteTypeMunger m : weaverType.getInterTypeMungersIncludingSupers()) { | for (ConcreteTypeMunger m : weaverType.getInterTypeMungersIncludingSupers()) { | ||||
ResolvedType theAspect = m.getAspectType(); | ResolvedType theAspect = m.getAspectType(); | ||||
if (!checked.contains(theAspect)) { | if (!checked.contains(theAspect)) { | ||||
} else if (theAspect instanceof ReferenceType) { | } else if (theAspect instanceof ReferenceType) { | ||||
// ResolvedMember rm = factory.makeResolvedMember(fieldDecl.binding); | // ResolvedMember rm = factory.makeResolvedMember(fieldDecl.binding); | ||||
String fname = new String(fieldDecl.name); | String fname = new String(fieldDecl.name); | ||||
Collection/* ResolvedMember */privvies = ((ReferenceType) theAspect).getPrivilegedAccesses(); | |||||
Collection<ResolvedMember> privvies = ((ReferenceType) theAspect).getPrivilegedAccesses(); | |||||
// On an incremental compile the information is in the bcel delegate | // On an incremental compile the information is in the bcel delegate | ||||
if (privvies != null) { | if (privvies != null) { | ||||
for (Object privvy : privvies) { | for (Object privvy : privvies) { |
model.setConfigFile(buildConfig.getConfigFile().getAbsolutePath()); | model.setConfigFile(buildConfig.getConfigFile().getAbsolutePath()); | ||||
kind = IProgramElement.Kind.FILE_LST; | kind = IProgramElement.Kind.FILE_LST; | ||||
} | } | ||||
model.setRoot(new ProgramElement(structureModel, rootLabel, kind, new ArrayList())); | |||||
model.setRoot(new ProgramElement(structureModel, rootLabel, kind, new ArrayList<>())); | |||||
model.setFileMap(new HashMap<>()); | model.setFileMap(new HashMap<>()); | ||||
// setStructureModel(model); | // setStructureModel(model); | ||||
/** init only on initial batch compile? no file-specific options */ | /** init only on initial batch compile? no file-specific options */ | ||||
private void initBcelWorld(IMessageHandler handler) throws IOException { | private void initBcelWorld(IMessageHandler handler) throws IOException { | ||||
List cp = buildConfig.getFullClasspath(); // pr145693 | |||||
List<String> cp = buildConfig.getFullClasspath(); // pr145693 | |||||
// buildConfig.getBootclasspath(); | // buildConfig.getBootclasspath(); | ||||
// cp.addAll(buildConfig.getClasspath()); | // cp.addAll(buildConfig.getClasspath()); | ||||
BcelWorld bcelWorld = new BcelWorld(cp, handler, null); | BcelWorld bcelWorld = new BcelWorld(cp, handler, null); | ||||
private void populateCompilerOptionsFromLintSettings(org.aspectj.org.eclipse.jdt.internal.compiler.Compiler forCompiler) { | private void populateCompilerOptionsFromLintSettings(org.aspectj.org.eclipse.jdt.internal.compiler.Compiler forCompiler) { | ||||
BcelWorld world = this.state.getBcelWorld(); | BcelWorld world = this.state.getBcelWorld(); | ||||
IMessage.Kind swallowedExceptionKind = world.getLint().swallowedExceptionInCatchBlock.getKind(); | IMessage.Kind swallowedExceptionKind = world.getLint().swallowedExceptionInCatchBlock.getKind(); | ||||
Map optionsMap = new HashMap(); | |||||
Map<String, String> optionsMap = new HashMap<>(); | |||||
optionsMap.put(CompilerOptions.OPTION_ReportSwallowedExceptionInCatchBlock, swallowedExceptionKind == null ? "ignore" | optionsMap.put(CompilerOptions.OPTION_ReportSwallowedExceptionInCatchBlock, swallowedExceptionKind == null ? "ignore" | ||||
: swallowedExceptionKind.toString()); | : swallowedExceptionKind.toString()); | ||||
forCompiler.options.set(optionsMap); | forCompiler.options.set(optionsMap); | ||||
sb.append("incrementally building "); | sb.append("incrementally building "); | ||||
} | } | ||||
AjBuildConfig config = (AjBuildConfig) data; | AjBuildConfig config = (AjBuildConfig) data; | ||||
List classpath = config.getClasspath(); | |||||
List<String> classpath = config.getClasspath(); | |||||
sb.append("with classpath: "); | sb.append("with classpath: "); | ||||
for (Object o : classpath) { | for (Object o : classpath) { | ||||
sb.append(o.toString()); | sb.append(o.toString()); |
filename = new String(currCompilationResult.fileName); | filename = new String(currCompilationResult.fileName); | ||||
lineseps = currCompilationResult.lineSeparatorPositions; | lineseps = currCompilationResult.lineSeparatorPositions; | ||||
LangUtil.throwIaxIfNull(currCompilationResult, "result"); | LangUtil.throwIaxIfNull(currCompilationResult, "result"); | ||||
stack = new Stack(); | |||||
stack = new Stack<>(); | |||||
packageDecl = null; | packageDecl = null; | ||||
this.buildConfig = buildConfig; | this.buildConfig = buildConfig; | ||||
internalBuild(cuDeclaration, structureModel); | internalBuild(cuDeclaration, structureModel); | ||||
// -- remove duplicates before adding (XXX use them instead?) | // -- remove duplicates before adding (XXX use them instead?) | ||||
if (addToNode != null && addToNode.getChildren() != null) { | if (addToNode != null && addToNode.getChildren() != null) { | ||||
for (ListIterator itt = addToNode.getChildren().listIterator(); itt.hasNext();) { | |||||
for (ListIterator<IProgramElement> itt = addToNode.getChildren().listIterator(); itt.hasNext();) { | |||||
IProgramElement child = (IProgramElement) itt.next(); | IProgramElement child = (IProgramElement) itt.next(); | ||||
ISourceLocation childLoc = child.getSourceLocation(); | ISourceLocation childLoc = child.getSourceLocation(); | ||||
if (null == childLoc) { | if (null == childLoc) { | ||||
} | } | ||||
} | } | ||||
if (sourceFolderNode == null) { | if (sourceFolderNode == null) { | ||||
sourceFolderNode = new ProgramElement(structureModel, sourceFolder, IProgramElement.Kind.SOURCE_FOLDER, new ArrayList()); | |||||
sourceFolderNode = new ProgramElement(structureModel, sourceFolder, IProgramElement.Kind.SOURCE_FOLDER, new ArrayList<>()); | |||||
root.addChild(sourceFolderNode); | root.addChild(sourceFolderNode); | ||||
} | } | ||||
return sourceFolderNode; | return sourceFolderNode; | ||||
} | } | ||||
if (pkgNode == null) { | if (pkgNode == null) { | ||||
// note packages themselves have no source location | // note packages themselves have no source location | ||||
pkgNode = new ProgramElement(activeStructureModel, pkgName, IProgramElement.Kind.PACKAGE, new ArrayList()); | |||||
pkgNode = new ProgramElement(activeStructureModel, pkgName, IProgramElement.Kind.PACKAGE, new ArrayList<>()); | |||||
rootForSource.addChild(pkgNode); | rootForSource.addChild(pkgNode); | ||||
} | } | ||||
addToNode = pkgNode; | addToNode = pkgNode; | ||||
formatter.genLabelAndKind(methodDeclaration, peNode); // will set the | formatter.genLabelAndKind(methodDeclaration, peNode); // will set the | ||||
// name | // name | ||||
genBytecodeInfo(methodDeclaration, peNode); | genBytecodeInfo(methodDeclaration, peNode); | ||||
List namedPointcuts = genNamedPointcuts(methodDeclaration); | |||||
List<ReferencePointcut> namedPointcuts = genNamedPointcuts(methodDeclaration); | |||||
// if (shouldAddUsesPointcut) | // if (shouldAddUsesPointcut) | ||||
// addUsesPointcutRelationsForNode(peNode, namedPointcuts, methodDeclaration); | // addUsesPointcutRelationsForNode(peNode, namedPointcuts, methodDeclaration); | ||||
* @param methodDeclaration | * @param methodDeclaration | ||||
* @return all of the named pointcuts referenced by the PCD of this declaration | * @return all of the named pointcuts referenced by the PCD of this declaration | ||||
*/ | */ | ||||
private List genNamedPointcuts(MethodDeclaration methodDeclaration) { | |||||
List pointcuts = new ArrayList(); | |||||
private List<ReferencePointcut> genNamedPointcuts(MethodDeclaration methodDeclaration) { | |||||
List<ReferencePointcut> pointcuts = new ArrayList<>(); | |||||
if (methodDeclaration instanceof AdviceDeclaration) { | if (methodDeclaration instanceof AdviceDeclaration) { | ||||
if (((AdviceDeclaration) methodDeclaration).pointcutDesignator != null) { | if (((AdviceDeclaration) methodDeclaration).pointcutDesignator != null) { | ||||
addAllNamed(((AdviceDeclaration) methodDeclaration).pointcutDesignator.getPointcut(), pointcuts); | addAllNamed(((AdviceDeclaration) methodDeclaration).pointcutDesignator.getPointcut(), pointcuts); | ||||
* @param pointcuts | * @param pointcuts | ||||
* accumulator for named pointcuts | * accumulator for named pointcuts | ||||
*/ | */ | ||||
private void addAllNamed(Pointcut pointcut, List pointcuts) { | |||||
private void addAllNamed(Pointcut pointcut, List<ReferencePointcut> pointcuts) { | |||||
if (pointcut == null) { | if (pointcut == null) { | ||||
return; | return; | ||||
} | } |
* @see org.eclipse.jdt.internal.compiler.ICompilerAdapterFactory#getAdapter(org.eclipse.jdt.internal.compiler.Compiler) | * @see org.eclipse.jdt.internal.compiler.ICompilerAdapterFactory#getAdapter(org.eclipse.jdt.internal.compiler.Compiler) | ||||
*/ | */ | ||||
public ICompilerAdapter getAdapter(Compiler forCompiler) { | public ICompilerAdapter getAdapter(Compiler forCompiler) { | ||||
Map javaOptions = forCompiler.options.getMap(); | |||||
Map<String, String> javaOptions = forCompiler.options.getMap(); | |||||
// TODO get aspectj options from project and add into map before... | // TODO get aspectj options from project and add into map before... | ||||
AjCompilerOptions ajOptions = new AjCompilerOptions(javaOptions); | AjCompilerOptions ajOptions = new AjCompilerOptions(javaOptions); | ||||
forCompiler.options = ajOptions; | forCompiler.options = ajOptions; | ||||
private void setLintProperties(BcelWorld world, AjCompilerOptions options) { | private void setLintProperties(BcelWorld world, AjCompilerOptions options) { | ||||
Properties p = new Properties(); | Properties p = new Properties(); | ||||
Lint lintSettings = world.getLint(); | Lint lintSettings = world.getLint(); | ||||
Map map = options.getMap(); | |||||
Map<String, String> map = options.getMap(); | |||||
p.put(lintSettings.invalidAbsoluteTypeName.getName(), map.get(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName)); | p.put(lintSettings.invalidAbsoluteTypeName.getName(), map.get(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName)); | ||||
p.put(lintSettings.invalidWildcardTypeName.getName(), map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName)); | p.put(lintSettings.invalidWildcardTypeName.getName(), map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName)); | ||||
p.put(lintSettings.unresolvableMember.getName(), map.get(AjCompilerOptions.OPTION_ReportUnresolvableMember)); | p.put(lintSettings.unresolvableMember.getName(), map.get(AjCompilerOptions.OPTION_ReportUnresolvableMember)); | ||||
private static class UnwovenResultCollector implements IIntermediateResultsRequestor { | private static class UnwovenResultCollector implements IIntermediateResultsRequestor { | ||||
private Collection results = new ArrayList(); | |||||
private Collection<InterimCompilationResult> results = new ArrayList<>(); | |||||
/* | /* | ||||
* (non-Javadoc) | * (non-Javadoc) |
try { | try { | ||||
// Set fileSet = StructureModelManager.INSTANCE.getStructureModel().getFileMap().entrySet(); | // Set fileSet = StructureModelManager.INSTANCE.getStructureModel().getFileMap().entrySet(); | ||||
Set fileSet = model.getHierarchy().getFileMapEntrySet(); | |||||
Set<Map.Entry<String, IProgramElement>> fileSet = model.getHierarchy().getFileMapEntrySet(); | |||||
for (Object o : fileSet) { | for (Object o : fileSet) { | ||||
IProgramElement peNode = (IProgramElement) ((Map.Entry) o).getValue(); | IProgramElement peNode = (IProgramElement) ((Map.Entry) o).getValue(); | ||||
dumpStructureToFile(peNode); | dumpStructureToFile(peNode); |
} | } | ||||
CompilationResultDestinationManager outputManager = ajbc.getCompilationResultDestinationManager(); | CompilationResultDestinationManager outputManager = ajbc.getCompilationResultDestinationManager(); | ||||
if (outputManager != null) { | if (outputManager != null) { | ||||
List outputDirs = outputManager.getAllOutputLocations(); | |||||
List<File> outputDirs = outputManager.getAllOutputLocations(); | |||||
for (Object o : outputDirs) { | for (Object o : outputDirs) { | ||||
File dir = (File) o; | File dir = (File) o; | ||||
if (dir.equals(location)) { | if (dir.equals(location)) { |
public List getAdvice() { | public List getAdvice() { | ||||
// ajh02: method added | // ajh02: method added | ||||
List bd = bodyDeclarations(); | List bd = bodyDeclarations(); | ||||
List advice = new ArrayList(); | |||||
List<AdviceDeclaration> advice = new ArrayList<>(); | |||||
for (Object decl : bd) { | for (Object decl : bd) { | ||||
if (decl instanceof AdviceDeclaration) { | if (decl instanceof AdviceDeclaration) { | ||||
advice.add(decl); | |||||
advice.add((AdviceDeclaration)decl); | |||||
} | } | ||||
} | } | ||||
return advice; | return advice; |