public void ignoreChildrenOf(CtElement element) { if (ignoredParent != null) { throw new SpoonException("Unexpected state. The ignoredParent is already set"); } ignoredParent = element; }
/** * calls outputConsumer for each reference of the field */ @Override public <T> void visitCtField(CtField<T> field) { throw new SpoonException("Field scope function is not supported"); }
@Override public void addResult(T value) { if (this.result != null) { throw new SpoonException("Cannot add second value into single value ConversionContext"); } this.result = value; }
public FileSystemFile(File file) { try { this.file = file.getCanonicalFile(); } catch (IOException e) { throw new SpoonException(e); } }
private Level toLevel(String level) { if (level == null || level.isEmpty()) { throw new SpoonException("Wrong level given at Spoon."); } return Level.toLevel(level, Level.ALL); }
@Override protected void enter(CtElement e) { throw new SpoonException("Unsupported variable of type " + e.getClass().getName()); } /**
private static CacheInfo loadCacheInfo(File file) throws InvalidClassException { try (FileInputStream fileStream = new FileInputStream(file); ObjectInputStream objectStream = new ObjectInputStream(new BufferedInputStream(fileStream))) { return (CacheInfo) objectStream.readObject(); } catch (InvalidClassException e) { throw e; } catch (ClassNotFoundException | IOException e) { throw new SpoonException("unable to load cache info"); } }
@Override public boolean add(X value) { if (hasValue) { //single value cannot have more then one value throw new SpoonException("Single value attribute cannot have more then one value"); } SingleHandler.this.setValue(element, value); hasValue = true; return true; }
public void setArgs(String[] args2) { this.commandLineArgs = args2; if (processed) { throw new SpoonException("You cannot process twice the same launcher instance."); } processed = true; processArguments(); }
/** * @return {@link ChangeCollector} registered in spoon environment */ private ChangeCollector getChangeCollector() { ChangeCollector changeCollector = ChangeCollector.getChangeCollector(env); if (changeCollector == null) { throw new SpoonException(ChangeCollector.class.getSimpleName() + " was not attached to the Environment"); } return changeCollector; }
@Override public void addProcessor(Class<? extends Processor<?>> type) { try { Processor<?> p = type.newInstance(); addProcessor(p); } catch (Exception e) { throw new SpoonException("Unable to instantiate processor \"" + type.getName() + "\" - Your processor should have a constructor with no arguments", e); } }
protected <T> T castTo(Object o, Class<T> type) { if (o == null) { return getEmptyContainer(); } if (type.isInstance(o)) { return (T) o; } throw new SpoonException("Cannot access parameter container of type " + o.getClass() + ". It expects " + type); }
/** * @return the {@link ValueConvertor} used by reading and writing into parameter values defined by this {@link ParameterInfo} */ public ValueConvertor getValueConvertor() { if (valueConvertor != null) { return valueConvertor; } if (containerItemAccessor != null) { return containerItemAccessor.getValueConvertor(); } throw new SpoonException("ValueConvertor is not defined."); }
private CtQuery createScopeQuery(CtVariable<?> variable, CtElement scope, Context context) { QueryCreator qc = new QueryCreator(scope, context); variable.accept(qc); if (qc.query == null) { throw new SpoonException("Unexpected type of variable: " + variable.getClass().getName()); } return qc.query; } }
@Override public boolean visit(UnionTypeReference unionTypeReference, BlockScope scope) { if (!(context.stack.peekFirst().node instanceof Argument)) { throw new SpoonException("UnionType is only supported for CtCatch."); } context.enter(helper.createCatchVariable(unionTypeReference), unionTypeReference); return true; }
private void checkMethodParameterTypeRef(CtTypeReference<?> parameterType) { if (parameterType instanceof CtTypeParameterReference && !(parameterType instanceof CtWildcardReference)) { throw new SpoonException("CtExecutableReference cannot use CtTypeParameterReference. Use boundingType of CtTypeParameterReference instead."); } if (parameterType instanceof CtArrayTypeReference) { checkMethodParameterTypeRef(((CtArrayTypeReference<?>) parameterType).getComponentType()); } }
@Override public void refactor() { if (getTarget() == null) { throw new SpoonException("The target of refactoring is not defined"); } if (getNewName() == null) { throw new SpoonException("The new name of refactoring is not defined"); } detectIssues(); refactorNoCheck(); }
@Override public void refactor() { if (getTarget() == null) { throw new SpoonException("The target of refactoring is not defined"); } detectIssues(); refactorNoCheck(); }
@Override public <T> void visitCtTypeReference(CtTypeReference<T> reference) { if (reference.getDeclaration() == null) { return; } if (reference.getDeclaration().getTopLevelType() != clone) { throw new SpoonException("post condition broken " + reference); } super.visitCtTypeReference(reference); }
public Pattern build() { if (built) { throw new SpoonException("The Pattern may be built only once"); } built = true; //clean the mapping so it is not possible to further modify built pattern using this builder patternElementToSubstRequests.clear(); return new Pattern(getFactory(), new ListOfNodes(patternNodes.getNodes())).setAddGeneratedBy(isAddGeneratedBy()); }