import org.aspectj.weaver.EnumAnnotationValue;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
-import org.aspectj.weaver.ResolvedMemberImpl;
import org.aspectj.weaver.ResolvedPointcutDefinition;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.StandardAnnotation;
resolvedTypeX.setEndPos(declaration.sourceEnd);
}
+ @Override
public boolean isAspect() {
final boolean isCodeStyle = declaration instanceof AspectDeclaration;
return isCodeStyle ? isCodeStyle : isAnnotationStyleAspect();
}
+ @Override
public boolean isAnonymous() {
if (declaration.binding != null) {
return declaration.binding.isAnonymousType();
return ((declaration.modifiers & (ASTNode.IsAnonymousType | ASTNode.IsLocalType)) != 0);
}
+ @Override
public boolean isNested() {
if (declaration.binding != null) {
return (declaration.binding.isMemberType());
return ((declaration.modifiers & ASTNode.IsMemberType) != 0);
}
+ @Override
public ResolvedType getOuterClass() {
if (declaration.binding != null) {
ReferenceBinding enclosingType = declaration.binding.enclosingType();
return eclipseWorld().fromEclipse(declaration.enclosingType.binding);
}
+ @Override
public boolean isAnnotationStyleAspect() {
if (declaration.annotations == null) {
return false;
return false;
}
+ @Override
public WeaverStateInfo getWeaverState() {
return null;
}
+ @Override
public ResolvedType getSuperclass() {
if (binding.isInterface()) {
return getResolvedTypeX().getWorld().getCoreType(UnresolvedType.OBJECT);
return eclipseWorld().fromEclipse(binding.superclass());
}
+ @Override
public ResolvedType[] getDeclaredInterfaces() {
return eclipseWorld().fromEclipse(binding.superInterfaces());
}
* This method may not return all fields, for example it may not include the ajc$initFailureCause or ajc$perSingletonInstance
* fields - see bug 129613
*/
+ @Override
public ResolvedMember[] getDeclaredFields() {
if (declaredFields == null) {
fillDeclaredMembers();
* This method may not return all methods, for example it may not include clinit, aspectOf, hasAspect or ajc$postClinit methods
* - see bug 129613
*/
+ @Override
public ResolvedMember[] getDeclaredMethods() {
if (declaredMethods == null) {
fillDeclaredMembers();
return declaredMethods;
}
+ @Override
public ResolvedMember[] getDeclaredPointcuts() {
if (declaredPointcuts == null) {
fillDeclaredMembers();
return declaredPointcuts;
}
+ @Override
public int getModifiers() {
// only return the real Java modifiers, not the extra eclipse ones
return binding.modifiers & ExtraCompilerModifiers.AccJustFlag;
}
+ @Override
public String toString() {
return "EclipseSourceType(" + new String(binding.sourceName()) + ")";
}
// dec.sourceEnd);
// }
+ @Override
public boolean isInterface() {
return binding.isInterface();
}
public final static short ACC_ANNOTATION = 0x2000;
public final static short ACC_ENUM = 0x4000;
+ @Override
public boolean isEnum() {
return (binding.getAccessFlags() & ACC_ENUM) != 0;
}
+ @Override
public boolean isAnnotation() {
return (binding.getAccessFlags() & ACC_ANNOTATION) != 0;
}
+ @Override
public boolean isAnnotationWithRuntimeRetention() {
if (!isAnnotation()) {
return false;
}
}
+ @Override
public String getRetentionPolicy() {
if (isAnnotation()) {
if ((binding.getAnnotationTagBits() & TagBits.AnnotationRetentionMASK) == TagBits.AnnotationRuntimeRetention) {
return null;
}
+ @Override
public boolean canAnnotationTargetType() {
if (isAnnotation()) {
return ((binding.getAnnotationTagBits() & TagBits.AnnotationForType) != 0);
return false;
}
+ @Override
public AnnotationTargetKind[] getAnnotationTargetKinds() {
if (discoveredAnnotationTargetKinds) {
return annotationTargetKinds;
}
}
+ @Override
public boolean hasAnnotation(UnresolvedType ofType) {
ensureAnnotationTypesResolved();
for (int a = 0, max = annotationTypes.length; a < max; a++) {
* annotations, this code only needs to deal with converting system annotations that the weaver needs to process
* (RetentionPolicy, Target).
*/
+ @Override
public AnnotationAJ[] getAnnotations() {
int declarationAnnoCount = (declaration.annotations == null ? 0 : declaration.annotations.length);
if (annotations != null && annotations.length == declarationAnnoCount) {
return annotations;
}
+ @Override
public boolean hasAnnotations() {
return (declaration.annotations != null && declaration.annotations.length != 0);
}
}
}
+ @Override
public ResolvedType[] getAnnotationTypes() {
ensureAnnotationTypesResolved();
return annotationTypes;
}
+ @Override
public PerClause getPerClause() {
// should probably be: ((AspectDeclaration)declaration).perClause;
// but we don't need this level of detail, and working with real per
return kind;
}
- public Collection getDeclares() {
+ @Override
+ public Collection<Declare> getDeclares() {
return declares;
}
- public Collection getPrivilegedAccesses() {
- return Collections.EMPTY_LIST;
+ @Override
+ public Collection<ResolvedMember> getPrivilegedAccesses() {
+ return Collections.emptyList();
}
+ @Override
public Collection getTypeMungers() {
return typeMungers;
}
+ @Override
public boolean doesNotExposeShadowMungers() {
return true;
}
+ @Override
public String getDeclaredGenericSignature() {
return CharOperation.charToString(binding.genericSignature());
}
+ @Override
public boolean isGeneric() {
return binding.isGenericType();
}
+ @Override
public TypeVariable[] getTypeVariables() {
if (declaration.typeParameters == null) {
return new TypeVariable[0];
package org.aspectj.ajdt.internal.compiler.batch;
-import org.aspectj.bridge.ICommand;
-import org.aspectj.bridge.IMessage;
-import org.aspectj.bridge.IMessageHandler;
-import org.aspectj.bridge.IMessageHolder;
-import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.bridge.Message;
-import org.aspectj.bridge.MessageHandler;
-import org.aspectj.bridge.ReflectionFactory;
-import org.aspectj.util.FileUtil;
-import org.aspectj.util.LangUtil;
-
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
-//import java.util.Enumeration;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
+import org.aspectj.bridge.ICommand;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessageHandler;
+import org.aspectj.bridge.IMessageHolder;
+import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.Message;
+import org.aspectj.bridge.MessageHandler;
+import org.aspectj.bridge.ReflectionFactory;
+import org.aspectj.util.FileUtil;
+import org.aspectj.util.LangUtil;
+
/**
* Mostly stateless incremental test case.
* Subclass to use from junit.
if (null == targetClasses) {
return false;
}
- final ArrayList files = new ArrayList();
+ final ArrayList<File> files = new ArrayList<>();
final FileFilter collector = new FileFilter() {
+ @Override
public boolean accept(File file) {
return files.add(file);
}
List safeFiles = Collections.unmodifiableList(files);
log("Compiling ", safeFiles, handler);
if (1 == i) {
- ArrayList argList = new ArrayList();
+ ArrayList<String> argList = new ArrayList<>();
argList.addAll(getBaseArgs(targetSrc, targetClasses));
File[] fra = (File[]) safeFiles.toArray(new File[0]);
// sigh
argList.addAll(
Arrays.asList(FileUtil.getAbsolutePaths(fra)));
- String[] args = (String[]) argList.toArray(new String[0]);
+ String[] args = argList.toArray(new String[0]);
commandLine.append(""+argList);
result = compiler.runCommand(args, compilerMessages);
} else {
public File outputDir;
/** @param srcDir ignored for now */
- protected List getBaseArgs(File srcDir, File classesDir) {
+ protected List<String> getBaseArgs(File srcDir, File classesDir) {
outputDir = classesDir;
String[] input =
new String[] {
"-d",
classesDir.getAbsolutePath()};
return Collections.unmodifiableList(
- new ArrayList(Arrays.asList(input)));
+ new ArrayList<String>(Arrays.asList(input)));
}
protected File makeDir(
// -------------------------------------- test case verification
- List normalizeFilenames(String[] ra) { // XXX util
- ArrayList result = new ArrayList();
+ List<String> normalizeFilenames(String[] ra) { // XXX util
+ ArrayList<String> result = new ArrayList<>();
if (null != ra) {
for (int i = 0; i < ra.length; i++) {
result.add(normalizeFilename(ra[i]));
}
/** @param list the List of File */
- List normalizeFilenames(List list) { // XXX util
- ArrayList result = new ArrayList();
- for (Iterator iter = list.iterator(); iter.hasNext();) {
- result.add(normalizeFilename(((File) iter.next()).getPath()));
+ List<String> normalizeFilenames(List<File> list) { // XXX util
+ ArrayList<String> result = new ArrayList<>();
+ for (File file: list) {
+// for (Iterator<?> iter = list.iterator(); iter.hasNext();) {
+ result.add(normalizeFilename(file.getPath()));
}
Collections.sort(result);
return result;
}
return null;
}
+ @Override
public String toString() {
return "Definition "
+ " expectFail="
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.aspectj.org.eclipse.jdt.core.JavaCore;
import org.aspectj.org.eclipse.jdt.core.dom.AST;
import org.aspectj.org.eclipse.jdt.core.dom.ASTParser;
import org.aspectj.org.eclipse.jdt.core.dom.WildTypePattern;
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import junit.framework.TestCase;
+
public class ASTVisitorTest extends TestCase {
public void testEnum_pr211201() {
private void check(String source, String expectedOutput){
ASTParser parser = ASTParser.newParser(AST.JLS3);//JLS2); // ajh02: need to use 2 for returnType - in 3 it has "returnType2"
- Map options = new HashMap();
+ Map<String, String> options = new HashMap<>();
options.put(CompilerOptions.OPTION_Source, "1.5");
parser.setCompilerOptions(options);//JavaCore.getOptions());
parser.setSource(source.toCharArray());
}
/** @deprecated using deprecated code */
+ @Deprecated
private static final int AST_INTERNAL_JLS2 = AST.JLS2;
* that come from testing Javadoc.getComment())
*
*/
+ @Deprecated
+ @Override
protected void setUp() throws Exception {
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
this(false);
}
+ @Override
public String toString(){
return b.toString();
}
visitTheKids = visitChildren;
}
+ @Override
public boolean visit(TypeDeclaration node) {
if (((AjTypeDeclaration)node).isAspect()) {
if (((AspectDeclaration) node).isPrivileged()){
return isVisitingChildren();
}
+ @Override
public void endVisit(TypeDeclaration node) {
if (((AjTypeDeclaration)node).isAspect())
if (((AspectDeclaration) node).isPrivileged()
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(EnumDeclaration node) {
b.append("(enum");
return isVisitingChildren();
}
+ @Override
public void endVisit(EnumDeclaration node) {
b.append(")");
}
+ @Override
public boolean visit(PointcutDeclaration node) {
b.append("(pointcut"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(PointcutDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(ReferencePointcut node) {
b.append("(referencePointcut"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(ReferencePointcut node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(BeforeAdviceDeclaration node) {
b.append("(beforeAdvice"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public boolean visit(AroundAdviceDeclaration node) {
b.append("(aroundAdvice"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public boolean visit(AfterAdviceDeclaration node) {
b.append("(afterAdvice"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public boolean visit(AfterThrowingAdviceDeclaration node) {
b.append("(afterThrowingAdvice"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public boolean visit(AfterReturningAdviceDeclaration node) {
b.append("(afterReturningAdvice"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(BeforeAdviceDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(AroundAdviceDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(AfterAdviceDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(AfterThrowingAdviceDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(AfterReturningAdviceDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(MethodDeclaration node) {
if (node instanceof InterTypeMethodDeclaration) return visit((InterTypeMethodDeclaration)node);
if (node.isConstructor()){
}
return isVisitingChildren();
}
+ @Override
public void endVisit(MethodDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(InterTypeFieldDeclaration node) {
b.append("(fieldITD"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(InterTypeFieldDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(InterTypeMethodDeclaration node) {
if (node.isConstructor()){
b.append("(constructorITD");
}
return isVisitingChildren();
}
+ @Override
public void endVisit(InterTypeMethodDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(MethodInvocation node) {
b.append("(methodInvocation"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(MethodInvocation node) {
b.append(")"); //$NON-NLS-1$
}
public void endVisit(BodyDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(FieldDeclaration node) {
b.append("(field"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(FieldDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(FieldAccess node) {
b.append("(fieldAccess"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(FieldAccess node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(Assignment node) {
b.append("(assignment"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(Assignment node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(Block node) {
b.append("(block"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(Block node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(CompilationUnit node) {
b.append("(compilationUnit"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(CompilationUnit node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(ExpressionStatement node) {
b.append("(expressionStatement"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(ExpressionStatement node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(InfixExpression node) {
b.append("(infixExpression"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(InfixExpression node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(Initializer node) {
b.append("(initializer"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(Initializer node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(NumberLiteral node) {
b.append("(numberLiteral"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(NumberLiteral node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(PrimitiveType node) {
b.append("(primitiveType"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(PrimitiveType node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(QualifiedName node) {
b.append("(qualifiedName"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(QualifiedName node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(SimpleName node) {
b.append("(simpleName"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(SimpleName node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(StringLiteral node) {
b.append("(stringLiteral"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(StringLiteral node) {
b.append(")"); //$NON-NLS-1$
}
b.append("(variableDeclaration"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public boolean visit(BlockComment bc) {
b.append("(blockcomment");
return isVisitingChildren();
}
+ @Override
public void endVisit(BlockComment bc) {
b.append(")");
}
public void endVisit(VariableDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(VariableDeclarationStatement node) {
b.append("(variableDeclarationStatement"); //$NON-NLS-1$
return isVisitingChildren();
}
+ @Override
public void endVisit(VariableDeclarationStatement node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(DeclareAtTypeDeclaration node) {
b.append("(declareAtType");
return isVisitingChildren();
}
+ @Override
public boolean visit(DeclareAtMethodDeclaration node) {
b.append("(declareAtMethod");
return isVisitingChildren();
}
+ @Override
public boolean visit(DeclareAtConstructorDeclaration node) {
b.append("(declareAtConstructor");
return isVisitingChildren();
}
+ @Override
public boolean visit(DeclareAtFieldDeclaration node) {
b.append("(declareAtField");
return isVisitingChildren();
}
+ @Override
public boolean visit(DeclareErrorDeclaration node) {
b.append("(declareError");
return isVisitingChildren();
}
+ @Override
public boolean visit(DeclareParentsDeclaration node) {
b.append("(declareParents");
return isVisitingChildren();
}
+ @Override
public boolean visit(DeclarePrecedenceDeclaration node) {
b.append("(declarePrecedence");
return isVisitingChildren();
}
+ @Override
public boolean visit(DeclareSoftDeclaration node) {
b.append("(declareSoft");
return isVisitingChildren();
}
+ @Override
public boolean visit(DeclareWarningDeclaration node) {
b.append("(declareWarning");
return isVisitingChildren();
}
+ @Override
public void endVisit(DeclareErrorDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(DeclareParentsDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(DeclarePrecedenceDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(DeclareAtFieldDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(DeclareAtMethodDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(DeclareAtTypeDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(DeclareAtConstructorDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(DeclareSoftDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(DeclareWarningDeclaration node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(AbstractBooleanTypePattern node) {
b.append("(");
node.getLeft().accept(this);
}
+ @Override
public boolean visit(AnyTypePattern node) {
b.append("(anyTypePattern");
return isVisitingChildren();
}
+ @Override
public void endVisit(AnyTypePattern node) {
b.append(")");
}
+ @Override
public boolean visit(AnyWithAnnotationTypePattern node) {
b.append("(anyWithAnnotationTypePattern");
return isVisitingChildren();
}
+ @Override
public void endVisit(AnyWithAnnotationTypePattern node) {
b.append(")");
}
+ @Override
public boolean visit(IdentifierTypePattern node) {
if (node instanceof WildTypePattern) {
b.append("(wildTypePattern");
}
+ @Override
public void endVisit(IdentifierTypePattern node) {
b.append(")");
}
+ @Override
public boolean visit(NotTypePattern node) {
b.append("(notTypePattern");
return isVisitingChildren();
}
+ @Override
public void endVisit(NotTypePattern node) {
b.append(")");
}
+ @Override
public boolean visit(TypeCategoryTypePattern node) {
b.append("(typeCategoryTypePattern");
return isVisitingChildren();
}
+ @Override
public void endVisit(TypeCategoryTypePattern node) {
b.append(")");
}
// End of TypePattern additions for Bugzilla 329268
+ @Override
public boolean visit(SignaturePattern node) {
b.append("(signaturePattern");
return isVisitingChildren();
}
+ @Override
public void endVisit(SignaturePattern node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public boolean visit(PerObject node) {
b.append("(perObject");
return isVisitingChildren();
}
+ @Override
public boolean visit(PerCflow node) {
b.append("(perCflow");
return isVisitingChildren();
}
+ @Override
public boolean visit(PerTypeWithin node) {
b.append("(perTypeWithin");
return isVisitingChildren();
}
+ @Override
public void endVisit(PerObject node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(PerCflow node) {
b.append(")"); //$NON-NLS-1$
}
+ @Override
public void endVisit(PerTypeWithin node) {
b.append(")"); //$NON-NLS-1$
}