本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.isEnum方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.isEnum方法的具體用法?Java ITypeBinding.isEnum怎麽用?Java ITypeBinding.isEnum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.isEnum方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addNewFieldForType
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void addNewFieldForType(ICompilationUnit targetCU, ITypeBinding binding,
ITypeBinding senderDeclBinding, SimpleName simpleName, boolean isWriteAccess, boolean mustBeConst,
Collection<CUCorrectionProposal> proposals) {
String name= simpleName.getIdentifier();
String nameLabel= BasicElementLabels.getJavaElementName(name);
String label;
if (senderDeclBinding.isEnum() && !isWriteAccess) {
label = Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createenum_description,
new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) });
proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.ENUM_CONST,
simpleName, senderDeclBinding, 10));
} else {
if (!mustBeConst) {
if (binding == null) {
label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createfield_description, nameLabel);
} else {
label = Messages.format(
CorrectionMessages.UnresolvedElementsSubProcessor_createfield_other_description,
new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) });
}
int fieldRelevance= StubUtility.hasFieldName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_FIELD_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_FIELD;
proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.FIELD,
simpleName, senderDeclBinding, fieldRelevance));
}
if (!isWriteAccess && !senderDeclBinding.isAnonymous()) {
if (binding == null) {
label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createconst_description, nameLabel);
} else {
label = Messages.format(
CorrectionMessages.UnresolvedElementsSubProcessor_createconst_other_description,
new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) });
}
int constRelevance= StubUtility.hasConstantName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_CONSTANT_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_CONSTANT;
proposals.add(new NewVariableCorrectionProposal(label, targetCU,
NewVariableCorrectionProposal.CONST_FIELD, simpleName, senderDeclBinding, constRelevance));
}
}
}
示例2: visit
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
@Override
public boolean visit(VariableDeclarationStatement param) {
ITypeBinding type = param.getType().resolveBinding();
if (hasAnnotation(param.modifiers()) && !type.isPrimitive()) {
List<VariableDeclarationFragment> L = param.fragments();
for (VariableDeclarationFragment oo : L) {
SingleMemberAnnotation annotation = getAnnotation(param.modifiers());
Expression value = annotation.getValue();
if (value instanceof StringLiteral) { //@Domain("D")
StringLiteral annotValue = (StringLiteral)value;
String parserInput = annotValue.getLiteralValue();
AnnotationInfo annotInfo = AnnotationInfo.parseAnnotation(parserInput);
DomainParams annot = annotInfo.getAnnotation();
boolean b = annot.isObjectPublicDomain();
if (b)
{
b = true;
}
boolean isDom = false;
boolean isDomPars = false;
String qualifiedName = "";
// if (oo.resolveBinding().getDeclaringMethod() != null) {
// qualifiedName = oo.resolveBinding().getDeclaringMethod().getDeclaringClass().getQualifiedName();
//
// isDom = isDomain(oo.resolveBinding().getDeclaringMethod().getDeclaringClass(), annot);
// isDomPars = isDomainParams(oo.resolveBinding().getDeclaringMethod().getDeclaringClass(),annot);
//
//
// }
// else
{
qualifiedName = currentType.resolveBinding().getQualifiedName();
isDom = isDomain(currentType.resolveBinding(), annot);
isDomPars = isDomainParams(currentType.resolveBinding() , annot);
}
ObjectMetricItem archMetricItem = new ObjectMetricItem(oo.resolveBinding().getKey(),oo.resolveBinding().getName().toString(),
param.getType().resolveBinding().getQualifiedName().toString(),
parserInput,
qualifiedName,
oo.toString(),
Modifier.isStatic(param.getModifiers()),
"LocalVariable",
type.isArray(),
type.isEnum(),
type.isParameterizedType(),
isDom,
isDomPars,
annot.isObjectPublicDomain()
);
if (!objectsHashtable.containsKey(archMetricItem.toString())) {
objectsHashtable.put(archMetricItem.toString(), archMetricItem);
}
// TODO: src.triplets for Local variables
}
}
}
return super.visit(param);
}
示例3: traverseFields
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private void traverseFields(TypeDeclaration declaration) {
FieldDeclaration[] fieldDeclarations = declaration.getFields();
for (int i = 0; i < fieldDeclarations.length; i++) {
FieldDeclaration fieldDeclaration = fieldDeclarations[i];
ITypeBinding type = fieldDeclaration.getType().resolveBinding();
if (hasAnnotation(fieldDeclaration.modifiers()) && !type.isPrimitive()) {
List ff = fieldDeclaration.fragments();
for (Object ff1 : ff) {
VariableDeclaration V = (VariableDeclaration) ff1;
String key = V.resolveBinding().getKey();
String name = V.getName().getIdentifier();
String objectType = fieldDeclaration.getType().resolveBinding().getQualifiedName();
String enclosingType = declaration.resolveBinding().getQualifiedName();
String ast = fieldDeclaration.getAST().toString();
boolean isStatic = Modifier.isStatic(fieldDeclaration.getModifiers());
//
SingleMemberAnnotation annotation = getAnnotation(fieldDeclaration.modifiers());
Expression value = annotation.getValue();
if (value instanceof StringLiteral) { //@Domain("D")
StringLiteral annotValue = (StringLiteral)value;
String parserInput = annotValue.getLiteralValue();
AnnotationInfo annotInfo = AnnotationInfo.parseAnnotation(parserInput);
DomainParams annot = annotInfo.getAnnotation();
boolean isDomainParam = isDomainParams(declaration.resolveBinding(), annot);
boolean isDomain = isDomain(declaration.resolveBinding(), annot);
ObjectMetricItem archMetricItem = new ObjectMetricItem(key,name,
objectType,
parserInput,
enclosingType,
ast,
isStatic,
"Field",
type.isArray(),
type.isEnum(),
type.isParameterizedType(),
isDomain,
isDomainParam,
annot.isObjectPublicDomain()
);
// TODO: Do we need the following two lines?
archMetricItem.setDomainParams(isDomainParam);
archMetricItem.setDomain(isDomain);
if (!objectsHashtable.containsKey(archMetricItem.toString())) {
objectsHashtable.put(archMetricItem.toString(), archMetricItem);
}
// TODO: src.triplets for Field
}
else
{
//this should not happen
System.out.println("Error in field declaration: "+ value);
}
}
}
}
}