spoon.reflect.code.CtCatch Java Examples
The following examples show how to use
spoon.reflect.code.CtCatch.
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: SpoonModelLibrary.java From nopol with GNU General Public License v2.0 | 5 votes |
public static CtTry newTryCatch(Factory factory, CtStatement tryBlock, List<CtCatch> catchers, CtElement parent) { CtTry tryCatch = factory.Core().createTry(); tryCatch.setBody(asBlock(tryBlock, tryCatch)); tryCatch.setCatchers(catchers); setParent(tryCatch, catchers); setParent(parent, tryCatch); return tryCatch; }
Example #2
Source File: SingleTryOperator.java From astor with GNU General Public License v2.0 | 5 votes |
@Override public boolean applyModification() { CtElement el = MetaGenerator.geOriginalElement(statementToWrap); if (!(el instanceof CtStatement)) { return false; } CtStatement original = (CtStatement) el; this.setParentBlock(original.getParent(CtBlock.class)); CtTry tryNew = MutationSupporter.getFactory().createTry(); List<CtCatch> catchers = new ArrayList<>(); CtCatch catchEx1 = MutationSupporter.getFactory().createCtCatch("e", Exception.class, new CtBlockImpl()); catchers.add(catchEx1); tryNew.setCatchers(catchers); CtBlock tryBoddy = new CtBlockImpl(); tryNew.setBody(tryBoddy); CtStatement stmtC = statementToWrap.clone(); MutationSupporter.clearPosition(stmtC); tryBoddy.addStatement(stmtC); // super.setOriginal(original); super.setModified(tryNew); // return super.applyModification(); }
Example #3
Source File: SingleStatementFixSpaceProcessor.java From astor with GNU General Public License v2.0 | 5 votes |
@Override public void process(CtStatement element) { if (!(element instanceof CtBlock || element instanceof CtClass || element instanceof CtMethod || element instanceof CtTry || element instanceof CtCatch) && (element.getParent() instanceof CtBlock) && (!(element.toString().startsWith("super")) || ConfigurationProperties.getPropertyBool("manipulatesuper"))) { add(element); } }
Example #4
Source File: SpoonModelLibrary.java From nopol with GNU General Public License v2.0 | 4 votes |
public static <E extends Throwable> CtTry newTryCatch(Factory factory, CtStatement tryBlock, Class<E> exception, String catchName, CtStatement catchBlock, CtElement parent) { CtCatch newCatch = newCatch(factory, exception, catchName, catchBlock); return newTryCatch(factory, tryBlock, asList(newCatch), parent); }
Example #5
Source File: SpoonModelLibrary.java From nopol with GNU General Public License v2.0 | 4 votes |
public static <E extends Throwable> CtCatch newCatch(Factory factory, Class<E> throwableClass, String catchName, CtStatement catchBlock) { CtCatch aCatch = factory.Core().createCatch(); aCatch.setParameter(factory.Code().createCatchVariable(newTypeReference(factory, throwableClass), catchName)); aCatch.setBody(asBlock(catchBlock, aCatch)); return aCatch; }
Example #6
Source File: CatchProcessor.java From spoon-examples with GNU General Public License v2.0 | 4 votes |
@Override public boolean isToBeProcessed(CtCatch candidate) { return candidate.getBody().getStatements().isEmpty(); }
Example #7
Source File: CatchProcessor.java From spoon-examples with GNU General Public License v2.0 | 4 votes |
@Override public void process(CtCatch element) { getEnvironment().report(this, Level.WARN, element, "empty catch clause " + element.getPosition().toString()); emptyCatchs.add(element); }