List of usage examples for org.eclipse.jdt.internal.compiler.lookup ExtraCompilerModifiers AccJustFlag
int AccJustFlag
To view the source code for org.eclipse.jdt.internal.compiler.lookup ExtraCompilerModifiers AccJustFlag.
Click Source Link
From source file:com.codenvy.ide.ext.java.server.internal.core.LocalVariable.java
License:Open Source License
/** * {@inheritDoc}/*from ww w . ja va 2 s .com*/ * @since 3.7 */ public int getFlags() { if (this.flags == -1) { SourceMapper mapper = getSourceMapper(); if (mapper != null) { try { // ensure the class file's buffer is open so that source ranges are computed ClassFile classFile = (ClassFile) getClassFile(); if (classFile != null) { classFile.getBuffer(); return mapper.getFlags(this); } } catch (JavaModelException e) { // ignore } } return 0; } return this.flags & ExtraCompilerModifiers.AccJustFlag; }
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;//from w w w. ja v a 2 s . c om } 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); }// ww w . jav a2 s .c om } // 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;/*from w ww. ja v a 2 s. c o 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--; } }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
protected void setModifiers(EnumConstantDeclaration enumConstantDeclaration, org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) { switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: enumConstantDeclaration/*from w w w . jav a2 s . c o m*/ .internalSetModifiers(fieldDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); if (fieldDeclaration.annotations != null) { enumConstantDeclaration.setFlags(enumConstantDeclaration.getFlags() | ASTNode.MALFORMED); } break; default: this.scanner.resetTo(fieldDeclaration.declarationSourceStart, fieldDeclaration.sourceStart); this.setModifiers(enumConstantDeclaration, fieldDeclaration.annotations, fieldDeclaration.sourceStart); } }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
/** * @param fieldDeclaration//ww w . j ava 2s.com * @param fieldDecl */ protected void setModifiers(FieldDeclaration fieldDeclaration, 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; default: this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart); this.setModifiers(fieldDeclaration, fieldDecl.annotations, fieldDecl.sourceStart); } }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
/** * @param initializer//from www.j av a 2 s . c o m * @param oldInitializer */ protected void setModifiers(Initializer initializer, 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; default: this.scanner.resetTo(oldInitializer.declarationSourceStart, oldInitializer.bodyStart); this.setModifiers(initializer, oldInitializer.annotations, oldInitializer.bodyStart); } }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
/** * @param methodDecl//from w ww . ja v a 2 s.co m * @param methodDeclaration */ protected void setModifiers(MethodDeclaration methodDecl, AbstractMethodDeclaration methodDeclaration) { switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: methodDecl.internalSetModifiers(methodDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); if (methodDeclaration.annotations != null) { methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); } break; default: this.scanner.resetTo(methodDeclaration.declarationSourceStart, methodDeclaration.sourceStart); this.setModifiers(methodDecl, methodDeclaration.annotations, methodDeclaration.sourceStart); } }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
/** * @param variableDecl/*www . ja v a 2s . co m*/ * @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; default: this.scanner.resetTo(argument.declarationSourceStart, argument.sourceStart); 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.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; modifier = 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 } } }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
protected void setModifiers(SingleVariableDeclaration variableDecl, LocalDeclaration localDeclaration) { switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: variableDecl.internalSetModifiers(localDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag); if (localDeclaration.annotations != null) { variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED); }//w w w . java 2 s . c o m break; default: this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart); 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.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++]; modifier = 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 } } }