本文整理汇总了Java中org.eclipse.jdt.core.dom.EnumDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java EnumDeclaration类的具体用法?Java EnumDeclaration怎么用?Java EnumDeclaration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EnumDeclaration类属于org.eclipse.jdt.core.dom包,在下文中一共展示了EnumDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBindingOfParentTypeContext
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
/**
* Returns the type binding of the node's type context or null if the node is inside
* an annotation, type parameter, super type declaration, or Javadoc of a top level type.
* The result of this method is equal to the result of {@link #getBindingOfParentType(ASTNode)} for nodes in the type's body.
*
* @param node an AST node
* @return the type binding of the node's parent type context, or <code>null</code>
*/
public static ITypeBinding getBindingOfParentTypeContext(ASTNode node) {
StructuralPropertyDescriptor lastLocation= null;
while (node != null) {
if (node instanceof AbstractTypeDeclaration) {
AbstractTypeDeclaration decl= (AbstractTypeDeclaration) node;
if (lastLocation == decl.getBodyDeclarationsProperty()
|| lastLocation == decl.getJavadocProperty()) {
return decl.resolveBinding();
} else if (decl instanceof EnumDeclaration && lastLocation == EnumDeclaration.ENUM_CONSTANTS_PROPERTY) {
return decl.resolveBinding();
}
} else if (node instanceof AnonymousClassDeclaration) {
return ((AnonymousClassDeclaration) node).resolveBinding();
}
lastLocation= node.getLocationInParent();
node= node.getParent();
}
return null;
}
示例2: getAdditionalInfo
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
@Override
public String getAdditionalInfo() {
if (fTypeNode instanceof EnumDeclaration) {
return CorrectionMessages.UnimplementedMethodsCorrectionProposal_enum_info;
}
IMethodBinding[] methodsToOverride = getMethodsToImplement();
StringBuffer buf = new StringBuffer();
buf.append("<b>"); //$NON-NLS-1$
if (methodsToOverride.length == 1) {
buf.append(CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_singular);
} else {
buf.append(Messages.format(CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_plural, String.valueOf(methodsToOverride.length)));
}
buf.append("</b><ul>"); //$NON-NLS-1$
for (int i = 0; i < methodsToOverride.length; i++) {
buf.append("<li>"); //$NON-NLS-1$
buf.append(BindingLabelProvider.getBindingLabel(methodsToOverride[i], JavaElementLabels.ALL_FULLY_QUALIFIED));
buf.append("</li>"); //$NON-NLS-1$s
}
buf.append("</ul>"); //$NON-NLS-1$
return buf.toString();
}
示例3: doAddEnumConst
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) {
SimpleName node= fOriginalNode;
ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding);
if (newTypeDecl == null) {
astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null);
newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey());
}
if (newTypeDecl != null) {
AST ast= newTypeDecl.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration();
constDecl.setName(ast.newSimpleName(node.getIdentifier()));
ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
listRewriter.insertLast(constDecl, null);
return rewrite;
}
return null;
}
示例4: getBindingOfParentTypeContext
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
/**
* Returns the type binding of the node's type context or null if the node is inside an
* annotation, type parameter, super type declaration, or Javadoc of a top level type. The result
* of this method is equal to the result of {@link #getBindingOfParentType(ASTNode)} for nodes in
* the type's body.
*
* @param node an AST node
* @return the type binding of the node's parent type context, or <code>null</code>
*/
public static ITypeBinding getBindingOfParentTypeContext(ASTNode node) {
StructuralPropertyDescriptor lastLocation = null;
while (node != null) {
if (node instanceof AbstractTypeDeclaration) {
AbstractTypeDeclaration decl = (AbstractTypeDeclaration) node;
if (lastLocation == decl.getBodyDeclarationsProperty()
|| lastLocation == decl.getJavadocProperty()) {
return decl.resolveBinding();
} else if (decl instanceof EnumDeclaration
&& lastLocation == EnumDeclaration.ENUM_CONSTANTS_PROPERTY) {
return decl.resolveBinding();
}
} else if (node instanceof AnonymousClassDeclaration) {
return ((AnonymousClassDeclaration) node).resolveBinding();
}
lastLocation = node.getLocationInParent();
node = node.getParent();
}
return null;
}
示例5: getFullTypeName
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
protected String getFullTypeName() {
ASTNode node = getNode();
while (true) {
node = node.getParent();
if (node instanceof AbstractTypeDeclaration) {
String typeName = ((AbstractTypeDeclaration) node).getName().getIdentifier();
if (getNode() instanceof LambdaExpression) {
return Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_lambda_expression, typeName);
}
return typeName;
} else if (node instanceof ClassInstanceCreation) {
ClassInstanceCreation cic = (ClassInstanceCreation) node;
return Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass,
BasicElementLabels.getJavaElementName(ASTNodes.asString(cic.getType())));
} else if (node instanceof EnumConstantDeclaration) {
EnumDeclaration ed = (EnumDeclaration) node.getParent();
return Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass,
BasicElementLabels.getJavaElementName(ASTNodes.asString(ed.getName())));
}
}
}
示例6: addInheritedTypeQualifications
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
private void addInheritedTypeQualifications(final AbstractTypeDeclaration declaration, final CompilationUnitRewrite targetRewrite, final TextEditGroup group) {
Assert.isNotNull(declaration);
Assert.isNotNull(targetRewrite);
final CompilationUnit unit= (CompilationUnit) declaration.getRoot();
final ITypeBinding binding= declaration.resolveBinding();
if (binding != null) {
Type type= null;
if (declaration instanceof TypeDeclaration) {
type= ((TypeDeclaration) declaration).getSuperclassType();
if (type != null && unit.findDeclaringNode(binding) != null)
addTypeQualification(type, targetRewrite, group);
}
List<Type> types= null;
if (declaration instanceof TypeDeclaration)
types= ((TypeDeclaration) declaration).superInterfaceTypes();
else if (declaration instanceof EnumDeclaration)
types= ((EnumDeclaration) declaration).superInterfaceTypes();
if (types != null) {
for (final Iterator<Type> iterator= types.iterator(); iterator.hasNext();) {
type= iterator.next();
if (unit.findDeclaringNode(type.resolveBinding()) != null)
addTypeQualification(type, targetRewrite, group);
}
}
}
}
示例7: getFullTypeName
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
protected String getFullTypeName() {
ASTNode node= getNode();
while (true) {
node= node.getParent();
if (node instanceof AbstractTypeDeclaration) {
String typeName= ((AbstractTypeDeclaration) node).getName().getIdentifier();
if (getNode() instanceof LambdaExpression) {
return Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_lambda_expression, typeName);
}
return typeName;
} else if (node instanceof ClassInstanceCreation) {
ClassInstanceCreation cic= (ClassInstanceCreation) node;
return Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass, BasicElementLabels.getJavaElementName(ASTNodes.asString(cic.getType())));
} else if (node instanceof EnumConstantDeclaration) {
EnumDeclaration ed= (EnumDeclaration) node.getParent();
return Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass, BasicElementLabels.getJavaElementName(ASTNodes.asString(ed.getName())));
}
}
}
示例8: getBindingOfParentTypeContext
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
/**
* Returns the type binding of the node's type context or null if the node is inside
* an annotation, type parameter, super type declaration, or Javadoc of a top level type.
* The result of this method is equal to the result of {@link #getBindingOfParentType(ASTNode)} for nodes in the type's body.
*
* @param node an AST node
* @return the type binding of the node's parent type context, or <code>null</code>
*/
public static ITypeBinding getBindingOfParentTypeContext(ASTNode node) {
StructuralPropertyDescriptor lastLocation= null;
while (node != null) {
if (node instanceof AbstractTypeDeclaration) {
AbstractTypeDeclaration decl= (AbstractTypeDeclaration) node;
if (lastLocation == decl.getBodyDeclarationsProperty()
|| lastLocation == decl.getJavadocProperty()) {
return decl.resolveBinding();
} else if (decl instanceof EnumDeclaration && lastLocation == EnumDeclaration.ENUM_CONSTANTS_PROPERTY) {
return decl.resolveBinding();
}
} else if (node instanceof AnonymousClassDeclaration) {
return ((AnonymousClassDeclaration) node).resolveBinding();
}
lastLocation= node.getLocationInParent();
node= node.getParent();
}
return null;
}
示例9: evaluateListRewrite
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
private ListRewrite evaluateListRewrite(ASTRewrite rewrite, ASTNode declNode) {
switch (declNode.getNodeType()) {
case ASTNode.METHOD_DECLARATION:
return rewrite.getListRewrite(declNode, MethodDeclaration.MODIFIERS2_PROPERTY);
case ASTNode.FIELD_DECLARATION:
return rewrite.getListRewrite(declNode, FieldDeclaration.MODIFIERS2_PROPERTY);
case ASTNode.VARIABLE_DECLARATION_EXPRESSION:
return rewrite.getListRewrite(declNode, VariableDeclarationExpression.MODIFIERS2_PROPERTY);
case ASTNode.VARIABLE_DECLARATION_STATEMENT:
return rewrite.getListRewrite(declNode, VariableDeclarationStatement.MODIFIERS2_PROPERTY);
case ASTNode.SINGLE_VARIABLE_DECLARATION:
return rewrite.getListRewrite(declNode, SingleVariableDeclaration.MODIFIERS2_PROPERTY);
case ASTNode.TYPE_DECLARATION:
return rewrite.getListRewrite(declNode, TypeDeclaration.MODIFIERS2_PROPERTY);
case ASTNode.ENUM_DECLARATION:
return rewrite.getListRewrite(declNode, EnumDeclaration.MODIFIERS2_PROPERTY);
case ASTNode.ANNOTATION_TYPE_DECLARATION:
return rewrite.getListRewrite(declNode, AnnotationTypeDeclaration.MODIFIERS2_PROPERTY);
case ASTNode.ENUM_CONSTANT_DECLARATION:
return rewrite.getListRewrite(declNode, EnumConstantDeclaration.MODIFIERS2_PROPERTY);
case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
return rewrite.getListRewrite(declNode, AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY);
default:
throw new IllegalArgumentException("node has no modifiers: " + declNode.getClass().getName()); //$NON-NLS-1$
}
}
示例10: getAdditionalInfo
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String getAdditionalInfo() {
if (fTypeNode instanceof EnumDeclaration)
return CorrectionMessages.UnimplementedMethodsCorrectionProposal_enum_info;
IMethodBinding[] methodsToOverride= getMethodsToImplement();
StringBuffer buf= new StringBuffer();
buf.append("<b>"); //$NON-NLS-1$
if (methodsToOverride.length == 1) {
buf.append(CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_singular);
} else {
buf.append(Messages.format(CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_plural, String.valueOf(methodsToOverride.length)));
}
buf.append("</b><ul>"); //$NON-NLS-1$
for (int i= 0; i < methodsToOverride.length; i++) {
buf.append("<li>"); //$NON-NLS-1$
buf.append(BindingLabelProvider.getBindingLabel(methodsToOverride[i], JavaElementLabels.ALL_FULLY_QUALIFIED));
buf.append("</li>"); //$NON-NLS-1$
}
buf.append("</ul>"); //$NON-NLS-1$
return buf.toString();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:AddUnimplementedMethodsOperation.java
示例11: initialize
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
public String initialize(CompilationUnit root, ASTNode node) {
if (!(node instanceof Name))
return SearchMessages.ImplementOccurrencesFinder_invalidTarget;
fSelectedNode= ASTNodes.getNormalizedNode(node);
if (!(fSelectedNode instanceof Type))
return SearchMessages.ImplementOccurrencesFinder_invalidTarget;
StructuralPropertyDescriptor location= fSelectedNode.getLocationInParent();
if (location != TypeDeclaration.SUPERCLASS_TYPE_PROPERTY && location != TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY && location != EnumDeclaration.SUPER_INTERFACE_TYPES_PROPERTY)
return SearchMessages.ImplementOccurrencesFinder_invalidTarget;
fSelectedType= ((Type)fSelectedNode).resolveBinding();
if (fSelectedType == null)
return SearchMessages.ImplementOccurrencesFinder_invalidTarget;
fStart= fSelectedNode.getParent(); // type declaration
fASTRoot= root;
fDescription= Messages.format(SearchMessages.ImplementOccurrencesFinder_occurrence_description, BasicElementLabels.getJavaElementName(fSelectedType.getName()));
return null;
}
示例12: doAddEnumConst
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) {
SimpleName node= fOriginalNode;
ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding);
if (newTypeDecl == null) {
astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null);
newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey());
}
if (newTypeDecl != null) {
AST ast= newTypeDecl.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration();
constDecl.setName(ast.newSimpleName(node.getIdentifier()));
ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
listRewriter.insertLast(constDecl, null);
addLinkedPosition(rewrite.track(constDecl.getName()), false, KEY_NAME);
return rewrite;
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:NewVariableCorrectionProposal.java
示例13: visit
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
@Override
public boolean visit(EnumDeclaration node) {
AbstractEnum absEnum = new AbstractEnum();
if (packageName != null) {
absEnum.setName(packageName+'.'+node.getName().getFullyQualifiedName());
} else {
absEnum.setName(node.getName().getFullyQualifiedName());
}
TypeVisitor visitor = new TypeVisitor();
node.accept(visitor);
absEnum.setMethods(visitor.getMethods());
absEnum.setFields(visitor.getFields());
absEnum.setStartPosition(node.getStartPosition());
absEnum.setEndPosition(node.getStartPosition() + node.getLength() - 1);
absEnum.setConstants(visitor.getEnumConstants());
types.add(absEnum);
return true;
}
示例14: writeLabels
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void writeLabels(Collection<String> labels) {
if (labels.isEmpty())
return;
EnumDeclaration enumType = getAST().newEnumDeclaration();
enumType.setName(getAST().newSimpleName("TAG"));
enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD));
// elements
int num = 0;
for (String label : labels) {
EnumConstantDeclaration constantDeclaration = getAST().newEnumConstantDeclaration();
constantDeclaration.setName(getAST().newSimpleName(normalizeEnumName(label)));
enumType.enumConstants().add(num, constantDeclaration);
num++;
}
getTarget().bodyDeclarations().add(enumType);
}
示例15: writeMessages
import org.eclipse.jdt.core.dom.EnumDeclaration; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void writeMessages(Collection<String> messages) {
EnumDeclaration enumType = getAST().newEnumDeclaration();
enumType.setName(getAST().newSimpleName("QCPFMSG"));
enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD));
// elements
int num = 0;
for (String message : messages) {
if (message.equalsIgnoreCase("CPF0000"))
continue;
EnumConstantDeclaration constantDeclaration = getAST().newEnumConstantDeclaration();
constantDeclaration.setName(getAST().newSimpleName(normalizeEnumName(message)));
enumType.enumConstants().add(num, constantDeclaration);
num++;
}
getTarget().bodyDeclarations().add(enumType);
}