@Override protected void enter(CtElement e) { if (e instanceof CtCompilationUnit) { return; } ElementSourceFragment newFragment = addChild(parents.peek(), scannedRole, e); if (newFragment != null) { parents.push(newFragment); if (e instanceof CtModifiable) { CtModifiable modifiable = (CtModifiable) e; Set<CtExtendedModifier> modifiers = modifiable.getExtendedModifiers(); for (CtExtendedModifier ctExtendedModifier : modifiers) { addChild(newFragment, CtRole.MODIFIER, ctExtendedModifier); } } } } @Override
List<String> thirdPosition = new ArrayList<>(); // all other things for (CtExtendedModifier extendedModifier : modifiable.getExtendedModifiers()) { if (!extendedModifier.isImplicit()) { ModifierKind modifierKind = extendedModifier.getKind();
/** verifies that the explicit modifier should be present in the original source code */ public void checkModifiers() { for (CtModifiable modifiable : _rootPackage.getElements(new TypeFilter<>(CtModifiable.class))) { for (CtExtendedModifier modifier : modifiable.getExtendedModifiers()) { if (modifier.isImplicit()) { continue; } SourcePosition position = modifier.getPosition(); CompilationUnit compilationUnit = position.getCompilationUnit(); String originalSourceCode = compilationUnit.getOriginalSourceCode(); assertEquals(modifier.getKind().toString(), originalSourceCode.substring(position.getSourceStart(), position.getSourceEnd() + 1)); } } }
char[] contents = jdtTreeBuilder.getContextBuilder().getCompilationUnitContents(); Set<CtExtendedModifier> modifiers = e.getExtendedModifiers(); Map<String, CtExtendedModifier> explicitModifiersByName = new HashMap<>(); for (CtExtendedModifier modifier: modifiers) {