本文整理汇总了Java中org.eclipse.jdt.core.dom.IExtendedModifier类的典型用法代码示例。如果您正苦于以下问题:Java IExtendedModifier类的具体用法?Java IExtendedModifier怎么用?Java IExtendedModifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IExtendedModifier类属于org.eclipse.jdt.core.dom包,在下文中一共展示了IExtendedModifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installLinkedVisibilityProposals
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
public static void installLinkedVisibilityProposals(LinkedProposalModel linkedProposalModel, ASTRewrite rewrite, List<IExtendedModifier> modifiers, boolean inInterface, String groupId) {
ASTNode modifier = findVisibilityModifier(modifiers);
if (modifier != null) {
int selected = ((Modifier) modifier).getKeyword().toFlagValue();
LinkedProposalPositionGroup positionGroup = linkedProposalModel.getPositionGroup(groupId, true);
positionGroup.addPosition(rewrite.track(modifier), false);
positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));
// add all others
int[] flagValues = inInterface ? new int[] { Modifier.PUBLIC, 0 } : new int[] { Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE };
for (int i = 0; i < flagValues.length; i++) {
if (flagValues[i] != selected) {
positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
}
}
}
}
示例2: getAnnotation
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
private ASTNode getAnnotation(List paramModifiers, String annotation) {
ASTNode found = null;
for (Iterator itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
IExtendedModifier o = (IExtendedModifier) itParamModifiers.next();
if (o instanceof SingleMemberAnnotation) {
SingleMemberAnnotation annot = (SingleMemberAnnotation) o;
String name = annot.getTypeName().toString();
if (name.compareTo(annotation) == 0) {
found = annot;
break;
}
}
}
return found;
}
示例3: checkExisting
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
boolean checkExisting(
List<IExtendedModifier> existingModifiers,
ListRewrite listRewrite,
TextEditGroup editGroup) {
for (Object mod : existingModifiers) {
if (mod instanceof MarkerAnnotation) {
MarkerAnnotation annotation = (MarkerAnnotation) mod;
String existingName = annotation.getTypeName().getFullyQualifiedName();
int lastDot = fAnnotationToRemove.lastIndexOf('.');
if (existingName.equals(fAnnotationToRemove)
|| (lastDot != -1
&& fAnnotationToRemove.substring(lastDot + 1).equals(existingName))) {
if (!fAllowRemove) return false; // veto this change
listRewrite.remove(annotation, editGroup);
return true;
}
// paranoia: check if by accident the annotation is already present (shouldn't happen):
lastDot = fAnnotationToAdd.lastIndexOf('.');
if (existingName.equals(fAnnotationToAdd)
|| (lastDot != -1 && fAnnotationToAdd.substring(lastDot + 1).equals(existingName))) {
return false; // already present
}
}
}
return true;
}
示例4: hasNullAnnotation
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
private static boolean hasNullAnnotation(MethodDeclaration decl) {
List<IExtendedModifier> modifiers = decl.modifiers();
String nonnull =
NullAnnotationsFix.getNonNullAnnotationName(decl.resolveBinding().getJavaElement(), false);
String nullable =
NullAnnotationsFix.getNullableAnnotationName(decl.resolveBinding().getJavaElement(), false);
for (Object mod : modifiers) {
if (mod instanceof Annotation) {
Name annotationName = ((Annotation) mod).getTypeName();
String fullyQualifiedName = annotationName.getFullyQualifiedName();
if (annotationName.isSimpleName()
? nonnull.endsWith(fullyQualifiedName)
: fullyQualifiedName.equals(nonnull)) return true;
if (annotationName.isSimpleName()
? nullable.endsWith(fullyQualifiedName)
: fullyQualifiedName.equals(nullable)) return true;
}
}
return false;
}
示例5: installLinkedVisibilityProposals
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
public static void installLinkedVisibilityProposals(
LinkedProposalModel linkedProposalModel,
ASTRewrite rewrite,
List<IExtendedModifier> modifiers,
boolean inInterface) {
ASTNode modifier = findVisibilityModifier(modifiers);
if (modifier != null) {
int selected = ((Modifier) modifier).getKeyword().toFlagValue();
LinkedProposalPositionGroup positionGroup =
linkedProposalModel.getPositionGroup(KEY_MODIFIER, true);
positionGroup.addPosition(rewrite.track(modifier), false);
positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));
// add all others
int[] flagValues =
inInterface
? new int[] {Modifier.PUBLIC, 0}
: new int[] {Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE};
for (int i = 0; i < flagValues.length; i++) {
if (flagValues[i] != selected) {
positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
}
}
}
}
示例6: checkExisting
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
boolean checkExisting(List<IExtendedModifier> existingModifiers, ListRewrite listRewrite, TextEditGroup editGroup) {
for (Object mod : existingModifiers) {
if (mod instanceof MarkerAnnotation) {
MarkerAnnotation annotation= (MarkerAnnotation) mod;
String existingName= annotation.getTypeName().getFullyQualifiedName();
int lastDot= fAnnotationToRemove.lastIndexOf('.');
if (existingName.equals(fAnnotationToRemove) || (lastDot != -1 && fAnnotationToRemove.substring(lastDot + 1).equals(existingName))) {
if (!fAllowRemove)
return false; // veto this change
listRewrite.remove(annotation, editGroup);
return true;
}
// paranoia: check if by accident the annotation is already present (shouldn't happen):
lastDot= fAnnotationToAdd.lastIndexOf('.');
if (existingName.equals(fAnnotationToAdd) || (lastDot != -1 && fAnnotationToAdd.substring(lastDot + 1).equals(existingName))) {
return false; // already present
}
}
}
return true;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:NullAnnotationsRewriteOperations.java
示例7: hasNullAnnotation
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
private static boolean hasNullAnnotation(MethodDeclaration decl) {
List<IExtendedModifier> modifiers= decl.modifiers();
String nonnull= NullAnnotationsFix.getNonNullAnnotationName(decl.resolveBinding().getJavaElement(), false);
String nullable= NullAnnotationsFix.getNullableAnnotationName(decl.resolveBinding().getJavaElement(), false);
for (Object mod : modifiers) {
if (mod instanceof Annotation) {
Name annotationName= ((Annotation) mod).getTypeName();
String fullyQualifiedName= annotationName.getFullyQualifiedName();
if (annotationName.isSimpleName() ? nonnull.endsWith(fullyQualifiedName) : fullyQualifiedName.equals(nonnull))
return true;
if (annotationName.isSimpleName() ? nullable.endsWith(fullyQualifiedName) : fullyQualifiedName.equals(nullable))
return true;
}
}
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:NullAnnotationsRewriteOperations.java
示例8: splitVariableDeclarationStatement
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
/**
* Split the fragments in <code>statement</code> to multiple VariableDeclarationStatements whenever
* <code>splitOperator.needsSplit</code> returns <code>true</code>.
* i.e.:
* int i, j; ---> int i; int j; (if splitOperator.needsSplit(i, j) == true)
*
* @param statement The VariableDeclarationStatement to split
* @param splitOperator The operator to use to split
* @param rewrite The rewriter to use to generate new VariableDeclarationStatements.
*/
private void splitVariableDeclarationStatement(VariableDeclarationStatement statement, ISplitOperation splitOperator, ASTRewrite rewrite) {
List<VariableDeclarationFragment> fragments= statement.fragments();
Iterator<VariableDeclarationFragment> iter= fragments.iterator();
VariableDeclarationFragment lastFragment= iter.next();
VariableDeclarationStatement lastStatement= statement;
splitOperator.initializeStatement(lastStatement, lastFragment);
ListRewrite fragmentsRewrite= null;
while (iter.hasNext()) {
VariableDeclarationFragment currentFragment= iter.next();
if (splitOperator.needsSplit(lastFragment, currentFragment)) {
VariableDeclarationStatement newStatement= getAst().newVariableDeclarationStatement((VariableDeclarationFragment)rewrite.createMoveTarget(currentFragment));
ListRewrite modifierRewrite= rewrite.getListRewrite(newStatement, VariableDeclarationStatement.MODIFIERS2_PROPERTY);
for (Iterator<IExtendedModifier> iterator= statement.modifiers().iterator(); iterator.hasNext();) {
modifierRewrite.insertLast(rewrite.createCopyTarget((ASTNode)iterator.next()), null);
}
newStatement.setType((Type)rewrite.createCopyTarget(statement.getType()));
splitOperator.initializeStatement(newStatement, currentFragment);
fragmentsRewrite= rewrite.getListRewrite(newStatement, VariableDeclarationStatement.FRAGMENTS_PROPERTY);
lastStatement= newStatement;
} else if (fragmentsRewrite != null) {
ASTNode fragment0= rewrite.createMoveTarget(currentFragment);
fragmentsRewrite.insertLast(fragment0, null);
}
lastFragment= currentFragment;
}
}
示例9: installLinkedVisibilityProposals
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
public static void installLinkedVisibilityProposals(LinkedProposalModel linkedProposalModel, ASTRewrite rewrite, List<IExtendedModifier> modifiers, boolean inInterface) {
ASTNode modifier= findVisibilityModifier(modifiers);
if (modifier != null) {
int selected= ((Modifier) modifier).getKeyword().toFlagValue();
LinkedProposalPositionGroup positionGroup= linkedProposalModel.getPositionGroup(KEY_MODIFIER, true);
positionGroup.addPosition(rewrite.track(modifier), false);
positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));
// add all others
int[] flagValues= inInterface ? new int[] { Modifier.PUBLIC, 0 } : new int[] { Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE };
for (int i= 0; i < flagValues.length; i++) {
if (flagValues[i] != selected) {
positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:ModifierCorrectionSubProcessor.java
示例10: makeConstant
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
/**
* Makes an attribute constant.
*/
@SuppressWarnings("unchecked")
public void makeConstant() {
List<IExtendedModifier> modifierList = fieldDeclaration.modifiers();
logger.debug("Trying to make attribute '" + attributeName + "' constant...");
/*
* Test if modifier already exists. If they don't exist than add them to the modifier list.
*/
if (testIfModifierExists(ModifierKeyword.STATIC_KEYWORD, modifierList)) {
logger.debug("modifier 'static' already exists");
} else {
modifierList.add(fieldDeclaration.getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD));
logger.debug("Added 'static' modifier to '" + attributeName + "'");
}
if (testIfModifierExists(ModifierKeyword.FINAL_KEYWORD, modifierList)) {
logger.debug("modifier 'final' already exists...");
} else {
modifierList.add(fieldDeclaration.getAST().newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD));
logger.debug("Added 'final' modifier to '" + attributeName + "'");
}
notifyChanged();
}
示例11: makeVariable
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
/**
* Makes a constant attribute variable.
*/
@SuppressWarnings("unchecked")
public void makeVariable() {
List<IExtendedModifier> modifierList = fieldDeclaration.modifiers();
List<IExtendedModifier> removeList = new ArrayList<IExtendedModifier>();
logger.debug("Trying to make attribute '" + attributeName + "' variable...");
for (Object modifier : modifierList) {
/*
* Mark modifier for deletion if it exists. To avoid NoSuchElementException this modifier will be put in a
* separate list and will be removed later.
*/
if (modifier.toString().equals(Modifier.ModifierKeyword.FINAL_KEYWORD.toString())
|| modifier.toString().equals(Modifier.ModifierKeyword.STATIC_KEYWORD.toString())) {
logger.debug("'" + modifier + "' flagged for deletion...");
removeList.add((IExtendedModifier) modifier);
}
}
logger.debug("Remove modifiers...");
modifierList.removeAll(removeList);
notifyChanged();
}
示例12: annotations
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
/**
* Returns the annotations for a given <code>modifierList</code>.
*
* @param modifierList the modifier list to be processed
* @return An ArraySet with all annotations
*/
@OperationMeta(returnGenerics = JavaAnnotation.class)
public Set<JavaAnnotation> annotations(List<IExtendedModifier> modifierList) {
List<JavaAnnotation> list = new ArrayList<JavaAnnotation>();
for (Object modifier : modifierList) {
if (modifier instanceof org.eclipse.jdt.core.dom.Annotation) {
org.eclipse.jdt.core.dom.Annotation annot = (org.eclipse.jdt.core.dom.Annotation) modifier;
// Get annotation name and value
Map<String, String> fields = new HashMap<String, String>();
// possibly the unqualified name as not resolved unless not given as qualified name!
String name = annot.getTypeName().getFullyQualifiedName();
if (annot instanceof SingleMemberAnnotation) {
fields.put(JavaAnnotation.DEFAULT_FIELD,
toString(((SingleMemberAnnotation) modifier).getValue()));
} else if (annot instanceof NormalAnnotation) {
@SuppressWarnings("unchecked")
List<MemberValuePair> values = ((NormalAnnotation) annot).values();
for (MemberValuePair pair : values) {
fields.put(pair.getName().getIdentifier(), toString(pair.getValue()));
}
}
list.add(new JavaAnnotation(name, fields, this));
}
}
return new ArraySet<JavaAnnotation>(list.toArray(new JavaAnnotation[list.size()]), JavaAnnotation.class);
}
示例13: hasNullAnnotation
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
private static boolean hasNullAnnotation(MethodDeclaration decl) {
List<IExtendedModifier> modifiers= decl.modifiers();
String nonnull= NullQuickFixes.getNonNullAnnotationName(decl.resolveBinding().getJavaElement(), false);
String nullable= NullQuickFixes.getNullableAnnotationName(decl.resolveBinding().getJavaElement(), false);
for (Object mod : modifiers) {
if (mod instanceof Annotation) {
Name annotationName= ((Annotation) mod).getTypeName();
String fullyQualifiedName= annotationName.getFullyQualifiedName();
if (annotationName.isSimpleName() ? nonnull.endsWith(fullyQualifiedName) : fullyQualifiedName.equals(nonnull))
return true;
if (annotationName.isSimpleName() ? nullable.endsWith(fullyQualifiedName) : fullyQualifiedName.equals(nullable))
return true;
}
}
return false;
}
示例14: setPublic
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
/**
* Sets the public modifier and deletes the protected one.
*/
private void setPublic(MethodDeclaration md) {
// if already public, do nothing
if (isPublic(md)) {
return;
}
// set public
Modifier modifier = ast.newModifier(ModifierKeyword.fromFlagValue(Modifier.PUBLIC));
md.modifiers().add(0, modifier);
// delete protected
for (int i = 0; i < md.modifiers().size(); i++) {
if (((IExtendedModifier)md.modifiers().get(i)).isModifier()) {
Modifier m = (Modifier)md.modifiers().get(i);
if (m.isProtected()) {
m.delete();
break;
}
}
}
}
示例15: getAnnotation
import org.eclipse.jdt.core.dom.IExtendedModifier; //导入依赖的package包/类
/**
* Return an Annotation instance used on this body declaration
*/
public static Annotation getAnnotation(String annotationName,
BodyDeclaration bodyDeclaration) {
List<?> modifiers = bodyDeclaration.modifiers();
// Test if this MethodDeclaration contains modifiers
if (modifiers != null) {
Iterator<?> modifiersIterator = modifiers.iterator();
while (modifiersIterator.hasNext()) {
IExtendedModifier modifier = (IExtendedModifier) modifiersIterator
.next();
if (modifier.isAnnotation()) {
Annotation a = (Annotation) modifier;
String annotationType = a.getTypeName().toString();
if (annotationType.endsWith(annotationName)) {
return a;
}
}
}
}
return null;
}