List of usage examples for org.eclipse.jdt.core.dom IExtendedModifier isModifier
public boolean isModifier();
From source file:ch.acanda.eclipse.pmd.java.resolution.design.UseUtilityClassQuickFix.java
License:Open Source License
private Predicate<? super IExtendedModifier> isFinal() { return new Predicate<IExtendedModifier>() { @Override// w ww . j a v a 2 s .co m public boolean apply(final IExtendedModifier modifier) { return modifier.isModifier() && ((Modifier) modifier).isFinal(); } }; }
From source file:changenodes.matching.BestLeafTreeMatcher.java
License:Apache License
private void markBodyDeclaration(ASTNode x, ASTNode y) { BodyDeclaration leftMethod = (BodyDeclaration) x; BodyDeclaration rightMethod = (BodyDeclaration) y; List<IExtendedModifier> leftModifiers = (List<IExtendedModifier>) leftMethod.modifiers(); List<IExtendedModifier> rightModifiers = (List<IExtendedModifier>) rightMethod.modifiers(); for (IExtendedModifier lm : leftModifiers) { if (lm.isModifier()) { for (IExtendedModifier rm : rightModifiers) { if (rm.isModifier()) { Modifier clm = (Modifier) lm; Modifier crm = (Modifier) rm; if (crm.getKeyword().equals(clm.getKeyword())) { leftMatching.put(clm, crm); rightMatching.put(crm, clm); }//from w w w . ja va 2s. c o m } } } } }
From source file:com.google.gdt.eclipse.core.JavaASTUtils.java
License:Open Source License
@SuppressWarnings("unchecked") public static Modifier findPrivateModifier(BodyDeclaration decl) { List<IExtendedModifier> modifiers = decl.modifiers(); for (IExtendedModifier m : modifiers) { if (m.isModifier()) { Modifier modifier = (Modifier) m; if (modifier.isPrivate()) { return modifier; }/* w ww .j a v a 2 s .co m*/ } } return null; }
From source file:com.google.googlejavaformat.java.JavaInputAstVisitor.java
License:Apache License
/** * Helper method for {@link EnumConstantDeclaration}s, {@link TypeDeclaration}s, and * {@code visitAndBreakModifiers}. Output combined modifiers and annotations and returns the * trailing break./*from w w w .j a v a 2 s.c o m*/ * @param modifiers a list of {@link IExtendedModifier}s, which can include annotations * @param annotationsDirection {@link Direction#VERTICAL} or {@link Direction#HORIZONTAL} * @param declarationAnnotationBreak a tag for the {code Break} after any declaration annotations. * @return the list of {@link Doc.Break}s following the modifiers and annotations */ private List<Op> visitModifiers(List<IExtendedModifier> modifiers, Direction annotationsDirection, Optional<BreakTag> declarationAnnotationBreak) { if (modifiers.isEmpty()) { return EMPTY_LIST; } builder.open(ZERO); boolean first = true; boolean lastWasAnnotation = false; int idx = 0; for (; idx < modifiers.size(); idx++) { IExtendedModifier modifier = modifiers.get(idx); if (modifier.isModifier()) { break; } if (!first) { builder.addAll(annotationsDirection.isVertical() ? forceBreakList(declarationAnnotationBreak) : breakList(declarationAnnotationBreak)); } ((ASTNode) modifier).accept(this); first = false; lastWasAnnotation = true; } builder.close(); ImmutableList<Op> trailingBreak = annotationsDirection.isVertical() ? forceBreakList(declarationAnnotationBreak) : breakList(declarationAnnotationBreak); if (idx >= modifiers.size()) { return trailingBreak; } if (lastWasAnnotation) { builder.addAll(trailingBreak); } builder.open(ZERO); first = true; for (; idx < modifiers.size(); idx++) { IExtendedModifier modifier = modifiers.get(idx); if (!first) { builder.addAll(breakFillList(Optional.<BreakTag>absent())); } ((ASTNode) modifier).accept(this); first = false; lastWasAnnotation = modifier.isAnnotation(); } builder.close(); return breakFillList(Optional.<BreakTag>absent()); }
From source file:com.halware.nakedide.eclipse.ext.annot.utils.AstUtils.java
License:Open Source License
/** * Returns the index of the first modifier that is not an annotation * This assumes that annotations belong before modifiers, though * technically they can be interspersed with modifiers. *//*from w ww . ja va 2s. c o m*/ public static int annotationLocation(BodyDeclaration declaration) { int count = 0; for (Iterator i = declaration.modifiers().listIterator(); i.hasNext();) { IExtendedModifier modifier = (IExtendedModifier) i.next(); if (modifier.isModifier()) { break; } count++; } return count; }
From source file:com.halware.nakedide.eclipse.ext.annot.utils.AstUtils.java
License:Open Source License
/** * Returns the index of the first modifier that is not an annotation * This assumes that annotations belong before modifiers, though * technically they can be interspersed with modifiers. *///from ww w . j av a2 s. co m public static int annotationLocation(SingleVariableDeclaration declaration) { int count = 0; for (Iterator i = declaration.modifiers().listIterator(); i.hasNext();) { IExtendedModifier modifier = (IExtendedModifier) i.next(); if (modifier.isModifier()) { break; } count++; } return count; }
From source file:com.halware.nakedide.eclipse.ext.annot.utils.dali.ASTTools.java
License:Open Source License
/** * Returns the index of the first modifier that is not an annotation * This assumes that annotations belong before modifiers, though * technically they can be interspersed with modifiers. *///from w ww . j a v a2 s . co m public static int annotationLocation(BodyDeclaration bodyDeclaration) { int count = 0; for (Iterator i = bodyDeclaration.modifiers().listIterator(); i.hasNext();) { IExtendedModifier modifier = (IExtendedModifier) i.next(); if (modifier.isModifier()) { break; } count++; } return count; }
From source file:de.ovgu.cide.export.physical.ahead.JakFeatureRefactorer.java
License:Open Source License
/** * helper function, filters all modifiers and returns only private public * and protected/* w w w . ja v a 2 s . co m*/ * * @param modifiers * @return */ private Collection<Modifier> getScopeModifiers(List<IExtendedModifier> modifiers) { Set<Modifier> result = new HashSet<Modifier>(); for (IExtendedModifier modifier : modifiers) if (modifier.isModifier()) { Modifier m = (Modifier) modifier; if (m.isPrivate() || m.isProtected() || m.isPublic()) result.add(m); } return result; }
From source file:de.ovgu.cide.export.physical.ahead.JakHookMethodHelper.java
License:Open Source License
private boolean isStatic(MethodDeclaration method) { for (IExtendedModifier modifier : (List<IExtendedModifier>) method.modifiers()) { if (modifier.isModifier()) { if (((Modifier) modifier).isStatic()) return true; }/*from w w w. j a va 2 s.co m*/ } return false; }
From source file:de.ovgu.cide.export.physical.ahead.JakPrettyPrinter.java
License:Open Source License
private void printOnlyModifiers(List<IExtendedModifier> ext) { for (Iterator<IExtendedModifier> it = ext.iterator(); it.hasNext();) { IExtendedModifier p = it.next(); if (p.isModifier()) { ((Modifier) p).accept(this); this.buffer.append(" ");//$NON-NLS-1$ }// w w w . jav a2 s .co m } }