当前位置: 首页>>代码示例>>Java>>正文


Java TypeDeclaration.ANNOTATION_TYPE_DECL属性代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ANNOTATION_TYPE_DECL属性的典型用法代码示例。如果您正苦于以下问题:Java TypeDeclaration.ANNOTATION_TYPE_DECL属性的具体用法?Java TypeDeclaration.ANNOTATION_TYPE_DECL怎么用?Java TypeDeclaration.ANNOTATION_TYPE_DECL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.jdt.internal.compiler.ast.TypeDeclaration的用法示例。


在下文中一共展示了TypeDeclaration.ANNOTATION_TYPE_DECL属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enterType

/**
 * @see ISourceElementRequestor#enterType(ISourceElementRequestor.TypeInfo)
 */
public void enterType(TypeInfo typeInfo) {
	// TODO (jerome) might want to merge the 4 methods
	switch (TypeDeclaration.kind(typeInfo.modifiers)) {
		case TypeDeclaration.CLASS_DECL:
			enterClass(typeInfo);
			break;
		case TypeDeclaration.ANNOTATION_TYPE_DECL:
			enterAnnotationType(typeInfo);
			break;
		case TypeDeclaration.INTERFACE_DECL:
			enterInterface(typeInfo);
			break;
		case TypeDeclaration.ENUM_DECL:
			enterEnum(typeInfo);
			break;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:SourceIndexerRequestor.java

示例2: formatTypeOpeningBrace

private void formatTypeOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace, TypeDeclaration typeDeclaration) {
	int fieldCount = (typeDeclaration.fields == null) ? 0 : typeDeclaration.fields.length;
	int methodCount = (typeDeclaration.methods == null) ? 0 : typeDeclaration.methods.length;
	int typeCount = (typeDeclaration.memberTypes == null) ? 0 : typeDeclaration.memberTypes.length;

	if (methodCount <= 2) {
		for (int i = 0, max = methodCount; i < max; i++) {
			final AbstractMethodDeclaration abstractMethodDeclaration = typeDeclaration.methods[i];
			if (abstractMethodDeclaration.isDefaultConstructor()) {
				methodCount--;
			} else if (abstractMethodDeclaration.isClinit()) {
				methodCount--;
			}
		}
	}
	final int memberLength = fieldCount + methodCount + typeCount;

	boolean insertNewLine = memberLength > 0;

	if (!insertNewLine) {
		if (TypeDeclaration.kind(typeDeclaration.modifiers) == TypeDeclaration.ENUM_DECL) {
			insertNewLine = this.preferences.insert_new_line_in_empty_enum_declaration;
		} else if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
			insertNewLine = this.preferences.insert_new_line_in_empty_anonymous_type_declaration;
		} else if (TypeDeclaration.kind(typeDeclaration.modifiers) == TypeDeclaration.ANNOTATION_TYPE_DECL) {
			insertNewLine = this.preferences.insert_new_line_in_empty_annotation_declaration;
		} else {
			insertNewLine = this.preferences.insert_new_line_in_empty_type_declaration;
		}
	}

	formatOpeningBrace(bracePosition, insertSpaceBeforeBrace);

	if (insertNewLine) {
		this.scribe.printNewLine();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:CodeFormatterVisitor.java

示例3: matchTypeDeclaration

boolean matchTypeDeclaration(TypeDeclarationPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {
	if (!(binaryInfo instanceof IBinaryType)) return false;

	IBinaryType type = (IBinaryType) binaryInfo;
	char[] fullyQualifiedTypeName = convertClassFileFormat(type.getName());
	boolean qualifiedPattern = pattern instanceof QualifiedTypeDeclarationPattern;
	if (pattern.enclosingTypeNames == null || qualifiedPattern) {
		char[] simpleName = (pattern.getMatchMode() == SearchPattern.R_PREFIX_MATCH)
			? CharOperation.concat(pattern.simpleName, IIndexConstants.ONE_STAR)
			: pattern.simpleName;
		char[] pkg = qualifiedPattern ? ((QualifiedTypeDeclarationPattern)pattern).qualification : pattern.pkg;
		if (!checkTypeName(simpleName, pkg, fullyQualifiedTypeName, pattern.isCaseSensitive(), pattern.isCamelCase())) return false;
	} else {
		char[] enclosingTypeName = CharOperation.concatWith(pattern.enclosingTypeNames, '.');
		char[] patternString = pattern.pkg == null
			? enclosingTypeName
			: CharOperation.concat(pattern.pkg, enclosingTypeName, '.');
		if (!checkTypeName(pattern.simpleName, patternString, fullyQualifiedTypeName, pattern.isCaseSensitive(), pattern.isCamelCase())) return false;
	}

	int kind  = TypeDeclaration.kind(type.getModifiers());
	switch (pattern.typeSuffix) {
		case CLASS_SUFFIX:
			return kind == TypeDeclaration.CLASS_DECL;
		case INTERFACE_SUFFIX:
			return kind == TypeDeclaration.INTERFACE_DECL;
		case ENUM_SUFFIX:
			return kind == TypeDeclaration.ENUM_DECL;
		case ANNOTATION_TYPE_SUFFIX:
			return kind == TypeDeclaration.ANNOTATION_TYPE_DECL;
		case CLASS_AND_INTERFACE_SUFFIX:
			return kind == TypeDeclaration.CLASS_DECL || kind == TypeDeclaration.INTERFACE_DECL;
		case CLASS_AND_ENUM_SUFFIX:
			return kind == TypeDeclaration.CLASS_DECL || kind == TypeDeclaration.ENUM_DECL;
		case INTERFACE_AND_ANNOTATION_SUFFIX:
			return kind == TypeDeclaration.INTERFACE_DECL || kind == TypeDeclaration.ANNOTATION_TYPE_DECL;
		case TYPE_SUFFIX: // nothing
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:40,代码来源:ClassFileMatchLocator.java

示例4: isInterface

/**
 * @see IType
 */
public boolean isInterface() throws JavaModelException {
	SourceTypeElementInfo info = (SourceTypeElementInfo) getElementInfo();
	switch (TypeDeclaration.kind(info.getModifiers())) {
		case TypeDeclaration.INTERFACE_DECL:
		case TypeDeclaration.ANNOTATION_TYPE_DECL: // annotation is interface too
			return true;
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:SourceType.java

示例5: isInterface

public boolean isInterface() throws JavaModelException {
	IBinaryType info = (IBinaryType) getElementInfo();
	switch (TypeDeclaration.kind(info.getModifiers())) {
		case TypeDeclaration.INTERFACE_DECL:
		case TypeDeclaration.ANNOTATION_TYPE_DECL: // annotation is interface too
			return true;
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:BinaryType.java

示例6: add

public RecoveredElement add(AbstractMethodDeclaration methodDeclaration, int bracketBalanceValue) {

	/* attach it to last type - if any */
	if (this.typeCount > 0){
		RecoveredType type = this.types[this.typeCount -1];
		int start = type.bodyEnd;
		int end = type.typeDeclaration.bodyEnd;
		type.bodyEnd = 0; // reset position
		type.typeDeclaration.declarationSourceEnd = 0; // reset position
		type.typeDeclaration.bodyEnd = 0;

		int kind = TypeDeclaration.kind(type.typeDeclaration.modifiers);
		if(start > 0 &&
				start < end &&
				kind != TypeDeclaration.INTERFACE_DECL &&
				kind != TypeDeclaration.ANNOTATION_TYPE_DECL) {
			// the } of the last type can be considered as the end of an initializer
			Initializer initializer = new Initializer(new Block(0), 0);
			initializer.bodyStart = end;
			initializer.bodyEnd = end;
			initializer.declarationSourceStart = end;
			initializer.declarationSourceEnd = end;
			initializer.sourceStart = end;
			initializer.sourceEnd = end;
			type.add(initializer, bracketBalanceValue);
		}

		resetPendingModifiers();

		return type.add(methodDeclaration, bracketBalanceValue);
	}
	return this; // ignore
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:33,代码来源:RecoveredUnit.java

示例7: createType

public JvmDeclaredType createType(final TypeDeclaration type, final String packageName) {
  JvmDeclaredType _switchResult = null;
  int _kind = TypeDeclaration.kind(type.modifiers);
  switch (_kind) {
    case TypeDeclaration.CLASS_DECL:
      _switchResult = TypesFactory.eINSTANCE.createJvmGenericType();
      break;
    case TypeDeclaration.INTERFACE_DECL:
      JvmGenericType _createJvmGenericType = TypesFactory.eINSTANCE.createJvmGenericType();
      final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
        it.setInterface(true);
      };
      _switchResult = ObjectExtensions.<JvmGenericType>operator_doubleArrow(_createJvmGenericType, _function);
      break;
    case TypeDeclaration.ENUM_DECL:
      _switchResult = TypesFactory.eINSTANCE.createJvmEnumerationType();
      break;
    case TypeDeclaration.ANNOTATION_TYPE_DECL:
      _switchResult = TypesFactory.eINSTANCE.createJvmAnnotationType();
      break;
    default:
      String _string = type.toString();
      String _plus = ("Cannot handle type " + _string);
      throw new IllegalArgumentException(_plus);
  }
  final JvmDeclaredType jvmType = _switchResult;
  jvmType.setPackageName(packageName);
  jvmType.setSimpleName(String.valueOf(type.name));
  if ((jvmType instanceof JvmGenericType)) {
    if ((type.typeParameters != null)) {
      for (final TypeParameter typeParam : type.typeParameters) {
        {
          final JvmTypeParameter jvmTypeParam = TypesFactory.eINSTANCE.createJvmTypeParameter();
          jvmTypeParam.setName(String.valueOf(typeParam.name));
          EList<JvmTypeParameter> _typeParameters = ((JvmGenericType)jvmType).getTypeParameters();
          _typeParameters.add(jvmTypeParam);
        }
      }
    }
  }
  if ((type.memberTypes != null)) {
    for (final TypeDeclaration nestedType : type.memberTypes) {
      {
        final JvmDeclaredType nested = this.createType(nestedType, null);
        EList<JvmMember> _members = jvmType.getMembers();
        _members.add(nested);
      }
    }
  }
  return jvmType;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:51,代码来源:JavaDerivedStateComputer.java

示例8: connect

/**
 * Connect the supplied type to its superclass & superinterfaces.
 * The superclass & superinterfaces are the identical binary or source types as
 * supplied by the name environment.
 */
public void connect(
	IGenericType type,
	IType typeHandle,
	IType superclassHandle,
	IType[] superinterfaceHandles) {

	/*
	 * Temporary workaround for 1G2O5WK: ITPJCORE:WINNT - NullPointerException when selecting "Show in Type Hierarchy" for a inner class
	 */
	if (typeHandle == null)
		return;
	if (TypeHierarchy.DEBUG) {
		System.out.println(
			"Connecting: " + ((JavaElement) typeHandle).toStringWithAncestors()); //$NON-NLS-1$
		System.out.println(
			"  to superclass: " //$NON-NLS-1$
				+ (superclassHandle == null
					? "<None>" //$NON-NLS-1$
					: ((JavaElement) superclassHandle).toStringWithAncestors()));
		System.out.print("  and superinterfaces:"); //$NON-NLS-1$
		if (superinterfaceHandles == null || superinterfaceHandles.length == 0) {
			System.out.println(" <None>"); //$NON-NLS-1$
		} else {
			System.out.println();
			for (int i = 0, length = superinterfaceHandles.length; i < length; i++) {
				if (superinterfaceHandles[i] == null) continue;
				System.out.println(
					"    " + ((JavaElement) superinterfaceHandles[i]).toStringWithAncestors()); //$NON-NLS-1$
			}
		}
	}
	// now do the caching
	switch (TypeDeclaration.kind(type.getModifiers())) {
		case TypeDeclaration.CLASS_DECL :
		case TypeDeclaration.ENUM_DECL :
			if (superclassHandle == null) {
				this.hierarchy.addRootClass(typeHandle);
			} else {
				this.hierarchy.cacheSuperclass(typeHandle, superclassHandle);
			}
			break;
		case TypeDeclaration.INTERFACE_DECL :
		case TypeDeclaration.ANNOTATION_TYPE_DECL :
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=329663
			if (this.hierarchy.typeToSuperInterfaces.get(typeHandle) == null)
				this.hierarchy.addInterface(typeHandle);
			break;
	}
	if (superinterfaceHandles == null) {
		superinterfaceHandles = TypeHierarchy.NO_TYPE;
	}
	this.hierarchy.cacheSuperInterfaces(typeHandle, superinterfaceHandles);

	// record flags
	this.hierarchy.cacheFlags(typeHandle, type.getModifiers());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:61,代码来源:HierarchyBuilder.java

示例9: add

public RecoveredElement add(TypeDeclaration typeDeclaration, int bracketBalanceValue) {

	/* do not consider a type starting passed the type end (if set)
		it must be belonging to an enclosing type */
	if (this.methodDeclaration.declarationSourceEnd != 0
		&& typeDeclaration.declarationSourceStart > this.methodDeclaration.declarationSourceEnd){

		if (this.parent == null) {
			return this; // ignore
		}
		return this.parent.add(typeDeclaration, bracketBalanceValue);
	}
	if ((typeDeclaration.bits & ASTNode.IsLocalType) != 0 || parser().methodRecoveryActivated || parser().statementRecoveryActivated){
		if (this.methodBody == null){
			Block block = new Block(0);
			block.sourceStart = this.methodDeclaration.bodyStart;
			this.add(block, 1);
		}
		this.methodBody.attachPendingModifiers(
				this.pendingAnnotations,
				this.pendingAnnotationCount,
				this.pendingModifiers,
				this.pendingModifersSourceStart);
		resetPendingModifiers();
		return this.methodBody.add(typeDeclaration, bracketBalanceValue, true);
	}
	switch (TypeDeclaration.kind(typeDeclaration.modifiers)) {
		case TypeDeclaration.INTERFACE_DECL :
		case TypeDeclaration.ANNOTATION_TYPE_DECL :
			resetPendingModifiers();
			this.updateSourceEndIfNecessary(previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1));
			if (this.parent == null) {
				return this; // ignore
			}
			// close the constructor
			return this.parent.add(typeDeclaration, bracketBalanceValue);
	}
	if (this.localTypes == null) {
		this.localTypes = new RecoveredType[5];
		this.localTypeCount = 0;
	} else {
		if (this.localTypeCount == this.localTypes.length) {
			System.arraycopy(
				this.localTypes,
				0,
				(this.localTypes = new RecoveredType[2 * this.localTypeCount]),
				0,
				this.localTypeCount);
		}
	}
	RecoveredType element = new RecoveredType(typeDeclaration, this, bracketBalanceValue);
	this.localTypes[this.localTypeCount++] = element;

	if(this.pendingAnnotationCount > 0) {
		element.attach(
				this.pendingAnnotations,
				this.pendingAnnotationCount,
				this.pendingModifiers,
				this.pendingModifersSourceStart);
	}
	resetPendingModifiers();

	/* consider that if the opening brace was not found, it is there */
	if (!this.foundOpeningBrace){
		this.foundOpeningBrace = true;
		this.bracketBalance++;
	}
	return element;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:69,代码来源:RecoveredMethod.java

示例10: isAnnotation

/**
 * @see IType#isAnnotation()
 * @since 3.0
 */
public boolean isAnnotation() throws JavaModelException {
	IBinaryType info = (IBinaryType) getElementInfo();
	return TypeDeclaration.kind(info.getModifiers()) == TypeDeclaration.ANNOTATION_TYPE_DECL;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:BinaryType.java

示例11: buildLocalType

private LocalTypeBinding buildLocalType(SourceTypeBinding enclosingType, PackageBinding packageBinding) {

		this.referenceContext.scope = this;
		this.referenceContext.staticInitializerScope = new MethodScope(this, this.referenceContext, true);
		this.referenceContext.initializerScope = new MethodScope(this, this.referenceContext, false);

		// build the binding or the local type
		LocalTypeBinding localType = new LocalTypeBinding(this, enclosingType, innermostSwitchCase());
		this.referenceContext.binding = localType;
		checkAndSetModifiers();
		buildTypeVariables();

		// Look at member types
		ReferenceBinding[] memberTypeBindings = Binding.NO_MEMBER_TYPES;
		if (this.referenceContext.memberTypes != null) {
			int size = this.referenceContext.memberTypes.length;
			memberTypeBindings = new ReferenceBinding[size];
			int count = 0;
			nextMember : for (int i = 0; i < size; i++) {
				TypeDeclaration memberContext = this.referenceContext.memberTypes[i];
				switch(TypeDeclaration.kind(memberContext.modifiers)) {
					case TypeDeclaration.INTERFACE_DECL :
					case TypeDeclaration.ANNOTATION_TYPE_DECL :
						problemReporter().illegalLocalTypeDeclaration(memberContext);
						continue nextMember;
				}
				ReferenceBinding type = localType;
				// check that the member does not conflict with an enclosing type
				do {
					if (CharOperation.equals(type.sourceName, memberContext.name)) {
						problemReporter().typeCollidesWithEnclosingType(memberContext);
						continue nextMember;
					}
					type = type.enclosingType();
				} while (type != null);
				// check the member type does not conflict with another sibling member type
				for (int j = 0; j < i; j++) {
					if (CharOperation.equals(this.referenceContext.memberTypes[j].name, memberContext.name)) {
						problemReporter().duplicateNestedType(memberContext);
						continue nextMember;
					}
				}
				ClassScope memberScope = new ClassScope(this, this.referenceContext.memberTypes[i]);
				LocalTypeBinding memberBinding = memberScope.buildLocalType(localType, packageBinding);
				memberBinding.setAsMemberType();
				memberTypeBindings[count++] = memberBinding;
			}
			if (count != size)
				System.arraycopy(memberTypeBindings, 0, memberTypeBindings = new ReferenceBinding[count], 0, count);
		}
		localType.setMemberTypes(memberTypeBindings);
		return localType;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:53,代码来源:ClassScope.java

示例12: buildMemberTypes

private void buildMemberTypes(AccessRestriction accessRestriction) {
    SourceTypeBinding sourceType = this.referenceContext.binding;
	ReferenceBinding[] memberTypeBindings = Binding.NO_MEMBER_TYPES;
	if (this.referenceContext.memberTypes != null) {
		int length = this.referenceContext.memberTypes.length;
		memberTypeBindings = new ReferenceBinding[length];
		int count = 0;
		nextMember : for (int i = 0; i < length; i++) {
			TypeDeclaration memberContext = this.referenceContext.memberTypes[i];
			switch(TypeDeclaration.kind(memberContext.modifiers)) {
				case TypeDeclaration.INTERFACE_DECL :
				case TypeDeclaration.ANNOTATION_TYPE_DECL :
					if (sourceType.isNestedType()
							&& sourceType.isClass() // no need to check for enum, since implicitly static
							&& !sourceType.isStatic()) {
						problemReporter().illegalLocalTypeDeclaration(memberContext);
						continue nextMember;
					}
				break;
			}
			ReferenceBinding type = sourceType;
			// check that the member does not conflict with an enclosing type
			do {
				if (CharOperation.equals(type.sourceName, memberContext.name)) {
					problemReporter().typeCollidesWithEnclosingType(memberContext);
					continue nextMember;
				}
				type = type.enclosingType();
			} while (type != null);
			// check that the member type does not conflict with another sibling member type
			for (int j = 0; j < i; j++) {
				if (CharOperation.equals(this.referenceContext.memberTypes[j].name, memberContext.name)) {
					problemReporter().duplicateNestedType(memberContext);
					continue nextMember;
				}
			}

			ClassScope memberScope = new ClassScope(this, memberContext);
			memberTypeBindings[count++] = memberScope.buildType(sourceType, sourceType.fPackage, accessRestriction);
		}
		if (count != length)
			System.arraycopy(memberTypeBindings, 0, memberTypeBindings = new ReferenceBinding[count], 0, count);
	}
	sourceType.memberTypes = memberTypeBindings;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:45,代码来源:ClassScope.java

示例13: isAnnotation

/**
 * @see IType#isAnnotation()
 * @since 3.0
 */
public boolean isAnnotation() throws JavaModelException {
	SourceTypeElementInfo info = (SourceTypeElementInfo) getElementInfo();
	return TypeDeclaration.kind(info.getModifiers()) == TypeDeclaration.ANNOTATION_TYPE_DECL;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:8,代码来源:SourceType.java


注:本文中的org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ANNOTATION_TYPE_DECL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。