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


Java TypeDeclaration.kind方法代码示例

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


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

示例1: enterType

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
/**
 * @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,代码行数:21,代码来源:SourceIndexerRequestor.java

示例2: updateOnClosingBrace

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){
	if(this.methodDeclaration.isAnnotationMethod()) {
		this.updateSourceEndIfNecessary(braceStart, braceEnd);
		if(!this.foundOpeningBrace && this.parent != null) {
			return this.parent.updateOnClosingBrace(braceStart, braceEnd);
		}
		return this;
	}
	if(this.parent != null && this.parent instanceof RecoveredType) {
		int mods = ((RecoveredType)this.parent).typeDeclaration.modifiers;
		if (TypeDeclaration.kind(mods) == TypeDeclaration.INTERFACE_DECL) {
			if (!this.foundOpeningBrace) {
				this.updateSourceEndIfNecessary(braceStart - 1, braceStart - 1);
				return this.parent.updateOnClosingBrace(braceStart, braceEnd);
			}
		}
	}
	return super.updateOnClosingBrace(braceStart, braceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:RecoveredMethod.java

示例3: acceptType

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
/**
 * Returns true if:<ul>
 *  <li>the given type is an existing class and the flag's <code>ACCEPT_CLASSES</code>
 *      bit is on
 *  <li>the given type is an existing interface and the <code>ACCEPT_INTERFACES</code>
 *      bit is on
 *  <li>neither the <code>ACCEPT_CLASSES</code> or <code>ACCEPT_INTERFACES</code>
 *      bit is on
 *  </ul>
 * Otherwise, false is returned.
 */
protected boolean acceptType(IType type, int acceptFlags, boolean isSourceType) {
	if (acceptFlags == 0 || acceptFlags == ACCEPT_ALL)
		return true; // no flags or all flags, always accepted
	try {
		int kind = isSourceType
				? TypeDeclaration.kind(((SourceTypeElementInfo) ((SourceType) type).getElementInfo()).getModifiers())
				: TypeDeclaration.kind(((IBinaryType) ((BinaryType) type).getElementInfo()).getModifiers());
		switch (kind) {
			case TypeDeclaration.CLASS_DECL :
				return (acceptFlags & ACCEPT_CLASSES) != 0;
			case TypeDeclaration.INTERFACE_DECL :
				return (acceptFlags & ACCEPT_INTERFACES) != 0;
			case TypeDeclaration.ENUM_DECL :
				return (acceptFlags & ACCEPT_ENUMS) != 0;
			default:
				//case IGenericType.ANNOTATION_TYPE :
				return (acceptFlags & ACCEPT_ANNOTATIONS) != 0;
		}
	} catch (JavaModelException npe) {
		return false; // the class is not present, do not accept.
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:NameLookup.java

示例4: formatTypeOpeningBrace

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
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,代码行数:38,代码来源:CodeFormatterVisitor.java

示例5: toString

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
public String toString() {
	StringBuffer buffer = new StringBuffer();
	if (this.modifiers == ClassFileConstants.AccPublic) {
		buffer.append("public "); //$NON-NLS-1$
	}
	switch (TypeDeclaration.kind(this.modifiers)) {
		case TypeDeclaration.CLASS_DECL :
			buffer.append("class "); //$NON-NLS-1$
			break;
		case TypeDeclaration.INTERFACE_DECL :
			buffer.append("interface "); //$NON-NLS-1$
			break;
		case TypeDeclaration.ENUM_DECL :
			buffer.append("enum "); //$NON-NLS-1$
			break;
	}
	if (this.name != null) {
		buffer.append(this.name);
	}
	if (this.superclass != null) {
		buffer.append("\n  extends "); //$NON-NLS-1$
		buffer.append(this.superclass);
	}
	int length;
	if (this.superInterfaces != null && (length = this.superInterfaces.length) != 0) {
		buffer.append("\n implements "); //$NON-NLS-1$
		for (int i = 0; i < length; i++) {
			buffer.append(this.superInterfaces[i]);
			if (i != length - 1) {
				buffer.append(", "); //$NON-NLS-1$
			}
		}
	}
	return buffer.toString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:36,代码来源:HierarchyBinaryType.java

示例6: isInterface

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
/**
 * @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,代码行数:13,代码来源:SourceType.java

示例7: enterType

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
/**
 */
public void enterType(TypeInfo typeInfo) {
	if (this.fBuildingType) {
		int[] sourceRange = {typeInfo.declarationStart, -1}; // will be fixed in the exit
		int[] nameRange = new int[] {typeInfo.nameSourceStart, typeInfo.nameSourceEnd};
		this.fNode = new DOMType(this.fDocument, sourceRange, new String(typeInfo.name), nameRange,
			typeInfo.modifiers, CharOperation.charArrayToStringArray(typeInfo.superinterfaces), TypeDeclaration.kind(typeInfo.modifiers) == TypeDeclaration.CLASS_DECL); // TODO (jerome) should pass in kind
		addChild(this.fNode);
		this.fStack.push(this.fNode);

		// type parameters not supported by JDOM
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:15,代码来源:SimpleDOMBuilder.java

示例8: createType

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
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,代码行数:52,代码来源:JavaDerivedStateComputer.java

示例9: add

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
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,代码行数:70,代码来源:RecoveredMethod.java

示例10: isEnum

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
/**
 * @see IType#isEnum()
 * @since 3.0
 */
public boolean isEnum() throws JavaModelException {
	SourceTypeElementInfo info = (SourceTypeElementInfo) getElementInfo();
	return TypeDeclaration.kind(info.getModifiers()) == TypeDeclaration.ENUM_DECL;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:9,代码来源:SourceType.java

示例11: isClass

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
/**
 * @see IType
 */
public boolean isClass() throws JavaModelException {
	SourceTypeElementInfo info = (SourceTypeElementInfo) getElementInfo();
	return TypeDeclaration.kind(info.getModifiers()) == TypeDeclaration.CLASS_DECL;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:SourceType.java

示例12: buildLocalType

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
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,代码行数:54,代码来源:ClassScope.java

示例13: isClass

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
public boolean isClass() throws JavaModelException {
	IBinaryType info = (IBinaryType) getElementInfo();
	return TypeDeclaration.kind(info.getModifiers()) == TypeDeclaration.CLASS_DECL;

}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:BinaryType.java

示例14: buildLocalType

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
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.memberTypes = memberTypeBindings;
		return localType;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:54,代码来源:ClassScope.java

示例15: isAnnotation

import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; //导入方法依赖的package包/类
/**
 * @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-Juno38,代码行数:9,代码来源:BinaryType.java


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