List of usage examples for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccDeprecated
int AccDeprecated
To view the source code for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccDeprecated.
Click Source Link
From source file:ch.uzh.ifi.seal.changedistiller.ast.java.CommentRecorderParser.java
License:Open Source License
@Override public void checkComment() { // discard obsolete comments while inside methods or fields initializer (see bug 74369) if (!(diet && (dietInt == 0)) && (scanner.commentPtr >= 0)) { flushCommentsDefinedPriorTo(endStatementPosition); }//from w w w .j av a 2s . c o m boolean deprecated = false; boolean checkDeprecated = false; int lastCommentIndex = -1; // since jdk1.2 look only in the last java doc comment... nextComment: for (lastCommentIndex = scanner.commentPtr; lastCommentIndex >= 0; lastCommentIndex--) { // look for @deprecated into the first javadoc comment preceeding the declaration int commentSourceStart = scanner.commentStarts[lastCommentIndex]; // javadoc only (non javadoc comment have negative start and/or end positions.) if ((commentSourceStart < 0) || ((modifiersSourceStart != -1) && (modifiersSourceStart < commentSourceStart)) || (scanner.commentStops[lastCommentIndex] < 0)) { continue nextComment; } checkDeprecated = true; int commentSourceEnd = scanner.commentStops[lastCommentIndex] - 1; // stop is one over // do not report problem before last parsed comment while recovering code... if (javadocParser.shouldReportProblems) { javadocParser.reportProblems = (currentElement == null) || (commentSourceEnd > lastJavadocEnd); } else { javadocParser.reportProblems = false; } deprecated = javadocParser.checkDeprecation(lastCommentIndex); javadoc = javadocParser.docComment; if (currentElement == null) { lastJavadocEnd = commentSourceEnd; } break nextComment; } if (deprecated) { checkAndSetModifiers(ClassFileConstants.AccDeprecated); } // modify the modifier source start to point at the first comment if ((lastCommentIndex >= 0) && checkDeprecated) { modifiersSourceStart = scanner.commentStarts[lastCommentIndex]; if (modifiersSourceStart < 0) { modifiersSourceStart = -modifiersSourceStart; } } }
From source file:com.android.tools.lint.psi.EcjPsiBinaryClass.java
License:Apache License
@Override public boolean isDeprecated() { return (mTypeBinding.modifiers & ClassFileConstants.AccDeprecated) != 0; }
From source file:com.android.tools.lint.psi.EcjPsiBinaryField.java
License:Apache License
@Override public boolean isDeprecated() { return (mBinding.modifiers & ClassFileConstants.AccDeprecated) != 0; }
From source file:com.android.tools.lint.psi.EcjPsiBinaryMethod.java
License:Apache License
@Override public boolean isDeprecated() { return (mMethodBinding.modifiers & ClassFileConstants.AccDeprecated) != 0; }
From source file:com.android.tools.lint.psi.EcjPsiClass.java
License:Apache License
@Override public boolean isDeprecated() { SourceTypeBinding binding = ((TypeDeclaration) mNativeNode).binding; return binding != null && (binding.modifiers & ClassFileConstants.AccDeprecated) != 0; }
From source file:com.android.tools.lint.psi.EcjPsiField.java
License:Apache License
@Override public boolean isDeprecated() { return mDeclaration.binding != null && (mDeclaration.binding.modifiers & ClassFileConstants.AccDeprecated) != 0; }
From source file:lombok.eclipse.handlers.EclipseHandlerUtil.java
License:Open Source License
public static boolean isFieldDeprecated(EclipseNode fieldNode) { FieldDeclaration field = (FieldDeclaration) fieldNode.get(); if ((field.modifiers & ClassFileConstants.AccDeprecated) != 0) { return true; }/*from www. jav a 2 s .c o m*/ if (field.annotations == null) return false; for (Annotation annotation : field.annotations) { if (typeMatches(Deprecated.class, fieldNode, annotation.type)) { return true; } } return false; }
From source file:org.eclipse.ajdt.core.parserbridge.AJSourceElementNotifier.java
License:Open Source License
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration) { // range check boolean isInRange = initialPosition <= methodDeclaration.declarationSourceStart && eofPosition >= methodDeclaration.declarationSourceEnd; if (methodDeclaration.isClinit()) { this.visitIfNeeded(methodDeclaration); return;/* w w w. j a va2s .co m*/ } if (methodDeclaration.isDefaultConstructor()) { if (reportReferenceInfo) { ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration; ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall; if (constructorCall != null) { switch (constructorCall.accessMode) { case ExplicitConstructorCall.This: requestor.acceptConstructorReference(typeNames[nestedTypeIndex - 1], constructorCall.arguments == null ? 0 : constructorCall.arguments.length, constructorCall.sourceStart); break; case ExplicitConstructorCall.Super: case ExplicitConstructorCall.ImplicitSuper: requestor.acceptConstructorReference(superTypeNames[nestedTypeIndex - 1], constructorCall.arguments == null ? 0 : constructorCall.arguments.length, constructorCall.sourceStart); break; } } } return; } char[][] argumentTypes = null; char[][] argumentNames = null; boolean isVarArgs = false; Argument[] arguments = methodDeclaration.arguments; if (arguments != null) { char[][][] argumentTypesAndNames = this.getArguments(arguments); argumentTypes = argumentTypesAndNames[0]; argumentNames = argumentTypesAndNames[1]; isVarArgs = arguments[arguments.length - 1].isVarArgs(); } char[][] thrownExceptionTypes = getThrownExceptions(methodDeclaration); // by default no selector end position int selectorSourceEnd = -1; if (methodDeclaration.isConstructor()) { selectorSourceEnd = this.sourceEnds.get(methodDeclaration); if (isInRange) { int currentModifiers = methodDeclaration.modifiers; if (isVarArgs) currentModifiers |= ClassFileConstants.AccVarargs; // remember deprecation so as to not lose it below boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(methodDeclaration.annotations); ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo(); methodInfo.isConstructor = true; methodInfo.declarationStart = methodDeclaration.declarationSourceStart; methodInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag; methodInfo.name = methodDeclaration.selector; methodInfo.nameSourceStart = methodDeclaration.sourceStart; methodInfo.nameSourceEnd = selectorSourceEnd; methodInfo.parameterTypes = argumentTypes; methodInfo.parameterNames = argumentNames; methodInfo.exceptionTypes = thrownExceptionTypes; methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters()); methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration); methodInfo.annotations = methodDeclaration.annotations; methodInfo.node = methodDeclaration; requestor.enterConstructor(methodInfo); } if (reportReferenceInfo) { ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration; ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall; if (constructorCall != null) { switch (constructorCall.accessMode) { case ExplicitConstructorCall.This: requestor.acceptConstructorReference(typeNames[nestedTypeIndex - 1], constructorCall.arguments == null ? 0 : constructorCall.arguments.length, constructorCall.sourceStart); break; case ExplicitConstructorCall.Super: case ExplicitConstructorCall.ImplicitSuper: requestor.acceptConstructorReference(superTypeNames[nestedTypeIndex - 1], constructorCall.arguments == null ? 0 : constructorCall.arguments.length, constructorCall.sourceStart); break; } } } this.visitIfNeeded(methodDeclaration); if (isInRange) { requestor.exitConstructor(methodDeclaration.declarationSourceEnd); } return; } selectorSourceEnd = this.sourceEnds.get(methodDeclaration); // AspectJ Change Begin // recreate source locations for Pointcuts and Advice org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration ajmDec = new org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration( new org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult( methodDeclaration.compilationResult.fileName, methodDeclaration.compilationResult.unitIndex, methodDeclaration.compilationResult.totalUnitsKnown, 500)); if (ajmDec instanceof PointcutDeclaration) { selectorSourceEnd = methodDeclaration.sourceStart + methodDeclaration.selector.length - 1; } if (ajmDec instanceof AdviceDeclaration) { selectorSourceEnd = methodDeclaration.sourceStart + ((AdviceDeclaration) ajmDec).kind.getName().length() - 1; } // AspectJ Change End if (isInRange) { int currentModifiers = methodDeclaration.modifiers; if (isVarArgs) currentModifiers |= ClassFileConstants.AccVarargs; // remember deprecation so as to not lose it below boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(methodDeclaration.annotations); TypeReference returnType = methodDeclaration instanceof MethodDeclaration ? ((MethodDeclaration) methodDeclaration).returnType : null; ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo(); methodInfo.isAnnotation = methodDeclaration instanceof AnnotationMethodDeclaration; methodInfo.declarationStart = methodDeclaration.declarationSourceStart; methodInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag; methodInfo.returnType = returnType == null ? null : CharOperation.concatWith(returnType.getParameterizedTypeName(), '.'); methodInfo.name = methodDeclaration.selector; methodInfo.nameSourceStart = methodDeclaration.sourceStart; methodInfo.nameSourceEnd = selectorSourceEnd; methodInfo.parameterTypes = argumentTypes; methodInfo.parameterNames = argumentNames; methodInfo.exceptionTypes = thrownExceptionTypes; methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters()); methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration); methodInfo.annotations = methodDeclaration.annotations; methodInfo.node = methodDeclaration; requestor.enterMethod(methodInfo); } this.visitIfNeeded(methodDeclaration); if (isInRange) { if (methodDeclaration instanceof AnnotationMethodDeclaration) { AnnotationMethodDeclaration annotationMethodDeclaration = (AnnotationMethodDeclaration) methodDeclaration; Expression expression = annotationMethodDeclaration.defaultValue; if (expression != null) { requestor.exitMethod(methodDeclaration.declarationSourceEnd, expression); return; } } requestor.exitMethod(methodDeclaration.declarationSourceEnd, (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) null); } }
From source file:org.eclipse.ajdt.core.parserbridge.AJSourceElementNotifier.java
License:Open Source License
protected void notifySourceElementRequestor(FieldDeclaration fieldDeclaration, TypeDeclaration declaringType) { // range check boolean isInRange = initialPosition <= fieldDeclaration.declarationSourceStart && eofPosition >= fieldDeclaration.declarationSourceEnd; switch (fieldDeclaration.getKind()) { case AbstractVariableDeclaration.ENUM_CONSTANT: if (this.reportReferenceInfo) { // accept constructor reference for enum constant if (fieldDeclaration.initialization instanceof AllocationExpression) { AllocationExpression alloc = (AllocationExpression) fieldDeclaration.initialization; requestor.acceptConstructorReference(declaringType.name, alloc.arguments == null ? 0 : alloc.arguments.length, alloc.sourceStart); }//from ww w .ja v a 2 s . co m } // fall through next case case AbstractVariableDeclaration.FIELD: int fieldEndPosition = this.sourceEnds.get(fieldDeclaration); if (fieldEndPosition == -1) { // use the declaration source end by default fieldEndPosition = fieldDeclaration.declarationSourceEnd; } if (isInRange) { int currentModifiers = fieldDeclaration.modifiers; // remember deprecation so as to not lose it below boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(fieldDeclaration.annotations); char[] typeName = null; if (fieldDeclaration.type == null) { // enum constant typeName = declaringType.name; currentModifiers |= ClassFileConstants.AccEnum; } else { // regular field typeName = CharOperation.concatWith(fieldDeclaration.type.getParameterizedTypeName(), '.'); } ISourceElementRequestor.FieldInfo fieldInfo = new ISourceElementRequestor.FieldInfo(); fieldInfo.declarationStart = fieldDeclaration.declarationSourceStart; fieldInfo.name = fieldDeclaration.name; fieldInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag; fieldInfo.type = typeName; fieldInfo.nameSourceStart = fieldDeclaration.sourceStart; fieldInfo.nameSourceEnd = fieldDeclaration.sourceEnd; fieldInfo.categories = (char[][]) this.nodesToCategories.get(fieldDeclaration); fieldInfo.annotations = fieldDeclaration.annotations; fieldInfo.node = fieldDeclaration; requestor.enterField(fieldInfo); } this.visitIfNeeded(fieldDeclaration, declaringType); if (isInRange) { requestor.exitField( // filter out initializations that are not a constant (simple check) (fieldDeclaration.initialization == null || fieldDeclaration.initialization instanceof ArrayInitializer || fieldDeclaration.initialization instanceof AllocationExpression || fieldDeclaration.initialization instanceof ArrayAllocationExpression || fieldDeclaration.initialization instanceof Assignment || fieldDeclaration.initialization instanceof ClassLiteralAccess || fieldDeclaration.initialization instanceof MessageSend || fieldDeclaration.initialization instanceof ArrayReference || fieldDeclaration.initialization instanceof ThisReference) ? -1 : fieldDeclaration.initialization.sourceStart, fieldEndPosition, fieldDeclaration.declarationSourceEnd); } break; case AbstractVariableDeclaration.INITIALIZER: if (isInRange) { requestor.enterInitializer(fieldDeclaration.declarationSourceStart, fieldDeclaration.modifiers); } this.visitIfNeeded((Initializer) fieldDeclaration); if (isInRange) { requestor.exitInitializer(fieldDeclaration.declarationSourceEnd); } break; } }
From source file:org.eclipse.ajdt.core.parserbridge.AJSourceElementNotifier.java
License:Open Source License
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType) { if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;// ww w . j a v a 2 s . co m // AspectJ change begin boolean isAspect = false; org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration ajtypeDeclaration = new org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration( new org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult( typeDeclaration.compilationResult.fileName, typeDeclaration.compilationResult.unitIndex, typeDeclaration.compilationResult.totalUnitsKnown, 500)); if (ajtypeDeclaration instanceof AspectDeclaration) { isAspect = true; } // AspectJ change end // range check boolean isInRange = initialPosition <= typeDeclaration.declarationSourceStart && eofPosition >= typeDeclaration.declarationSourceEnd; FieldDeclaration[] fields = typeDeclaration.fields; AbstractMethodDeclaration[] methods = typeDeclaration.methods; TypeDeclaration[] memberTypes = typeDeclaration.memberTypes; int fieldCounter = fields == null ? 0 : fields.length; int methodCounter = methods == null ? 0 : methods.length; int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length; int fieldIndex = 0; int methodIndex = 0; int memberTypeIndex = 0; if (notifyTypePresence) { char[][] interfaceNames = getInterfaceNames(typeDeclaration); int kind = TypeDeclaration.kind(typeDeclaration.modifiers); char[] implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_OBJECT; if (isInRange) { int currentModifiers = typeDeclaration.modifiers; // remember deprecation so as to not lose it below boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(typeDeclaration.annotations); boolean isEnumInit = typeDeclaration.allocation != null && typeDeclaration.allocation.enumConstant != null; char[] superclassName; if (isEnumInit) { currentModifiers |= ClassFileConstants.AccEnum; superclassName = declaringType.name; } else { superclassName = getSuperclassName(typeDeclaration); } ISourceElementRequestor.TypeInfo typeInfo = new ISourceElementRequestor.TypeInfo(); if (typeDeclaration.allocation == null) { typeInfo.declarationStart = typeDeclaration.declarationSourceStart; } else if (isEnumInit) { typeInfo.declarationStart = typeDeclaration.allocation.enumConstant.sourceStart; } else { typeInfo.declarationStart = typeDeclaration.allocation.sourceStart; } typeInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag; typeInfo.name = typeDeclaration.name; typeInfo.nameSourceStart = isEnumInit ? typeDeclaration.allocation.enumConstant.sourceStart : typeDeclaration.sourceStart; typeInfo.nameSourceEnd = sourceEnd(typeDeclaration); typeInfo.superclass = superclassName; typeInfo.superinterfaces = interfaceNames; typeInfo.typeParameters = getTypeParameterInfos(typeDeclaration.typeParameters); typeInfo.categories = (char[][]) this.nodesToCategories.get(typeDeclaration); typeInfo.secondary = typeDeclaration.isSecondary(); typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null; typeInfo.annotations = typeDeclaration.annotations; typeInfo.node = typeDeclaration; requestor.enterType(typeInfo, isAspect, (isAspect ? ((AspectDeclaration) ajtypeDeclaration).isPrivileged : false)); // AspectJ change switch (kind) { case TypeDeclaration.CLASS_DECL: if (superclassName != null) implicitSuperclassName = superclassName; break; case TypeDeclaration.INTERFACE_DECL: implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_OBJECT; break; case TypeDeclaration.ENUM_DECL: implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_ENUM; break; case TypeDeclaration.ANNOTATION_TYPE_DECL: implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_ANNOTATION_ANNOTATION; break; } } if (this.nestedTypeIndex == this.typeNames.length) { // need a resize System.arraycopy(this.typeNames, 0, (this.typeNames = new char[this.nestedTypeIndex * 2][]), 0, this.nestedTypeIndex); System.arraycopy(this.superTypeNames, 0, (this.superTypeNames = new char[this.nestedTypeIndex * 2][]), 0, this.nestedTypeIndex); } this.typeNames[this.nestedTypeIndex] = typeDeclaration.name; this.superTypeNames[this.nestedTypeIndex++] = implicitSuperclassName; } while ((fieldIndex < fieldCounter) || (memberTypeIndex < memberTypeCounter) || (methodIndex < methodCounter)) { FieldDeclaration nextFieldDeclaration = null; AbstractMethodDeclaration nextMethodDeclaration = null; TypeDeclaration nextMemberDeclaration = null; int position = Integer.MAX_VALUE; int nextDeclarationType = -1; if (fieldIndex < fieldCounter) { nextFieldDeclaration = fields[fieldIndex]; if (nextFieldDeclaration.declarationSourceStart < position) { position = nextFieldDeclaration.declarationSourceStart; nextDeclarationType = 0; // FIELD } } if (methodIndex < methodCounter) { nextMethodDeclaration = methods[methodIndex]; if (nextMethodDeclaration.declarationSourceStart < position) { position = nextMethodDeclaration.declarationSourceStart; nextDeclarationType = 1; // METHOD } } if (memberTypeIndex < memberTypeCounter) { nextMemberDeclaration = memberTypes[memberTypeIndex]; if (nextMemberDeclaration.declarationSourceStart < position) { position = nextMemberDeclaration.declarationSourceStart; nextDeclarationType = 2; // MEMBER } } switch (nextDeclarationType) { case 0: fieldIndex++; notifySourceElementRequestor(nextFieldDeclaration, typeDeclaration); break; case 1: methodIndex++; notifySourceElementRequestor(nextMethodDeclaration); break; case 2: memberTypeIndex++; notifySourceElementRequestor(nextMemberDeclaration, true, null); } } if (notifyTypePresence) { if (isInRange) { requestor.exitType(typeDeclaration.declarationSourceEnd); } nestedTypeIndex--; } }