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


Java TypeDeclaration.CLASS_DECL属性代码示例

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


在下文中一共展示了TypeDeclaration.CLASS_DECL属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: acceptType

/**
 * 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,代码行数:33,代码来源:NameLookup.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: toString

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,代码行数:35,代码来源:HierarchyBinaryType.java

示例5: lookupBinaryHandle

/**
 * Looks up and returns a handle for the given binary info.
 */
protected IType lookupBinaryHandle(IBinaryType typeInfo) {
	int flag;
	String qualifiedName;
	switch (TypeDeclaration.kind(typeInfo.getModifiers())) {
		case TypeDeclaration.CLASS_DECL :
			flag = NameLookup.ACCEPT_CLASSES;
			break;
		case TypeDeclaration.INTERFACE_DECL :
			flag = NameLookup.ACCEPT_INTERFACES;
			break;
		case TypeDeclaration.ENUM_DECL :
			flag = NameLookup.ACCEPT_ENUMS;
			break;
		default:
			//case IGenericType.ANNOTATION :
			flag = NameLookup.ACCEPT_ANNOTATIONS;
			break;
	}
	char[] bName = typeInfo.getName();
	qualifiedName = new String(ClassFile.translatedName(bName));
	if (qualifiedName.equals(this.focusQualifiedName)) return getType();
	NameLookup.Answer answer = this.nameLookup.findType(qualifiedName,
		false,
		flag,
		true/* consider secondary types */,
		false/* do NOT wait for indexes */,
		false/*don't check restrictions*/,
		null);
	return answer == null || answer.type == null || !answer.type.isBinary() ? null : answer.type;

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

示例6: enterType

/**
 */
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,代码行数:14,代码来源:SimpleDOMBuilder.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: isClass

/**
 * @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,代码行数:7,代码来源:SourceType.java

示例10: isClass

public boolean isClass() throws JavaModelException {
	IBinaryType info = (IBinaryType) getElementInfo();
	return TypeDeclaration.kind(info.getModifiers()) == TypeDeclaration.CLASS_DECL;

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

示例11: consumeClassDeclaration

protected void consumeClassDeclaration() {
	// ClassDeclaration ::= ClassHeader ClassBody

	int length;
	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
		//there are length declarations
		//dispatch according to the type of the declarations
		dispatchDeclarationInto(length);
	}

	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];

	//convert constructor that do not have the type's name into methods
	boolean hasConstructor = typeDecl.checkConstructors(this);

	//add the default constructor when needed (interface don't have it)
	if (!hasConstructor) {
		switch(TypeDeclaration.kind(typeDecl.modifiers)) {
			case TypeDeclaration.CLASS_DECL :
			case TypeDeclaration.ENUM_DECL :
				boolean insideFieldInitializer = false;
				if (this.diet) {
					for (int i = this.nestedType; i > 0; i--){
						if (this.variablesCounter[i] > 0) {
							insideFieldInitializer = true;
							break;
						}
					}
				}
				typeDecl.createDefaultConstructor(!this.diet || insideFieldInitializer, true);
		}
	}
	//always add <clinit> (will be remove at code gen time if empty)
	if (this.scanner.containsAssertKeyword) {
		typeDecl.bits |= ASTNode.ContainsAssertion;
	}
	typeDecl.addClinit();
	typeDecl.bodyEnd = this.endStatementPosition;
	if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
		typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
	}

	typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:44,代码来源:Parser.java


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