use of org.eclipse.jdt.core.dom.IExtendedModifier in project che by eclipse.
the class ModifierRewrite method copyAllModifiers.
public void copyAllModifiers(ASTNode otherDecl, TextEditGroup editGroup, boolean copyIndividually) {
ListRewrite modifierList = evaluateListRewrite(fModifierRewrite.getASTRewrite(), otherDecl);
List<IExtendedModifier> originalList = modifierList.getOriginalList();
if (originalList.isEmpty()) {
return;
}
if (copyIndividually) {
for (Iterator<IExtendedModifier> iterator = originalList.iterator(); iterator.hasNext(); ) {
ASTNode modifier = (ASTNode) iterator.next();
ASTNode copy = fModifierRewrite.getASTRewrite().createCopyTarget(modifier);
if (copy != null) {
//paranoia check (only left here because we're in RC1)
fModifierRewrite.insertLast(copy, editGroup);
}
}
} else {
ASTNode copy = modifierList.createCopyTarget((ASTNode) originalList.get(0), (ASTNode) originalList.get(originalList.size() - 1));
if (copy != null) {
//paranoia check (only left here because we're in RC1)
fModifierRewrite.insertLast(copy, editGroup);
}
}
}
use of org.eclipse.jdt.core.dom.IExtendedModifier in project che by eclipse.
the class ModifierRewrite method copyAllAnnotations.
public void copyAllAnnotations(ASTNode otherDecl, TextEditGroup editGroup) {
ListRewrite modifierList = evaluateListRewrite(fModifierRewrite.getASTRewrite(), otherDecl);
List<IExtendedModifier> originalList = modifierList.getOriginalList();
for (Iterator<IExtendedModifier> iterator = originalList.iterator(); iterator.hasNext(); ) {
IExtendedModifier modifier = iterator.next();
if (modifier.isAnnotation()) {
fModifierRewrite.insertLast(fModifierRewrite.getASTRewrite().createCopyTarget((Annotation) modifier), editGroup);
}
}
}
use of org.eclipse.jdt.core.dom.IExtendedModifier in project che by eclipse.
the class ModifierCorrectionSubProcessor method findAnnotation.
private static Annotation findAnnotation(String qualifiedTypeName, List<IExtendedModifier> modifiers) {
for (int i = 0; i < modifiers.size(); i++) {
IExtendedModifier curr = modifiers.get(i);
if (curr instanceof Annotation) {
Annotation annot = (Annotation) curr;
ITypeBinding binding = annot.getTypeName().resolveTypeBinding();
if (binding != null && qualifiedTypeName.equals(binding.getQualifiedName())) {
return annot;
}
}
}
return null;
}
use of org.eclipse.jdt.core.dom.IExtendedModifier in project che by eclipse.
the class ModifierCorrectionSubProcessor method findVisibilityModifier.
private static Modifier findVisibilityModifier(List<IExtendedModifier> modifiers) {
for (int i = 0; i < modifiers.size(); i++) {
IExtendedModifier curr = modifiers.get(i);
if (curr instanceof Modifier) {
Modifier modifier = (Modifier) curr;
ModifierKeyword keyword = modifier.getKeyword();
if (keyword == ModifierKeyword.PUBLIC_KEYWORD || keyword == ModifierKeyword.PROTECTED_KEYWORD || keyword == ModifierKeyword.PRIVATE_KEYWORD) {
return modifier;
}
}
}
return null;
}
use of org.eclipse.jdt.core.dom.IExtendedModifier in project che by eclipse.
the class NullAnnotationsRewriteOperations method hasNullAnnotation.
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;
}
Aggregations