spoon.reflect.declaration.CtModifiable Java Examples
The following examples show how to use
spoon.reflect.declaration.CtModifiable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpoonReferenceLibrary.java From nopol with GNU General Public License v2.0 | 6 votes |
private static boolean isVisibleFrom(CtTypeReference<?> accessingClass, CtModifiable modifiable, CtTypeReference<?> declaringClass, CtTypeReference<?> actualClass) { if (hasPublicModifier(modifiable)) { return true; } if ((isNestedIn(accessingClass, actualClass) || isNestedIn(actualClass, accessingClass)) && areSameClass(declaringClass, actualClass)) { return true; } if (hasNoVisibilityModifier(modifiable) && areFromSamePackage(declaringClass, actualClass) && areFromSamePackage(actualClass, accessingClass)) { return true; } if (hasPrivateModifier(modifiable) && areSameClass(declaringClass, accessingClass)) { return true; } if (hasProtectedModifier(modifiable) && areFromSamePackage(declaringClass, accessingClass)) { return true; } if (hasProtectedModifier(modifiable) && isSubclassOf(declaringClass, accessingClass) && areSameClass(actualClass, accessingClass)) { return true; } return false; }
Example #2
Source File: DocProcessor.java From spoon-examples with GNU General Public License v2.0 | 5 votes |
public void process(CtElement element) { if (element instanceof CtType || element instanceof CtField || element instanceof CtExecutable) { Set<ModifierKind> modifiers = ((CtModifiable) element).getModifiers(); if (modifiers.contains(PUBLIC) || modifiers.contains(PROTECTED)) { String docComment = element.getDocComment(); if (docComment == null || docComment.equals("")) { System.out.println("undocumented element at " + element.getPosition()); undocumentedElements.add(element); } } } }
Example #3
Source File: NodeCreator.java From gumtree-spoon-ast-diff with Apache License 2.0 | 5 votes |
@Override public void scanCtModifiable(CtModifiable m) { if (m.getModifiers().isEmpty()) return; // We add the type of modifiable element String type = MODIFIERS + getClassName(m.getClass().getSimpleName()); ITree modifiers = builder.createNode(type, ""); // We create a virtual node modifiers.setMetadata(SpoonGumTreeBuilder.SPOON_OBJECT, new CtVirtualElement(type, m, m.getModifiers())); // ensuring an order (instead of hashset) // otherwise some flaky tests in CI Set<ModifierKind> modifiers1 = new TreeSet<>(new Comparator<ModifierKind>() { @Override public int compare(ModifierKind o1, ModifierKind o2) { return o1.name().compareTo(o2.name()); } }); modifiers1.addAll(m.getModifiers()); for (ModifierKind kind : modifiers1) { ITree modifier = builder.createNode("Modifier", kind.toString()); modifiers.addChild(modifier); // We wrap the modifier (which is not a ctelement) modifier.setMetadata(SpoonGumTreeBuilder.SPOON_OBJECT, new CtWrapper(kind, m)); } builder.addSiblingNode(modifiers); }