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; }
/** * Return the type of the field * for List<String> field the ValueType is List * for String field the ValueType is String * */ public CtTypeReference<?> getTypeOfField() { if (valueType == null) { throw new SpoonException("Model is not initialized yet"); } return valueType; }
public ParameterInfo getCurrentParameter() { if (currentParameter == null) { throw new SpoonException("Parameter name must be defined first by call of #parameter(String) method."); } return currentParameter; }
/** * @param valueConvertor the {@link ValueConvertor} used by reading and writing into parameter values defined by this {@link ParameterInfo} */ public AbstractParameterInfo setValueConvertor(ValueConvertor valueConvertor) { if (valueConvertor == null) { throw new SpoonException("valueConvertor must not be null"); } this.valueConvertor = valueConvertor; return this; }
@Override protected List<Object> getEmptyContainer() { throw new SpoonException("ComputedParameterInfo#getEmptyContainer should not be used"); } @Override
private ChainOfMatchersImpl(RootNode firstMatcher, Matchers next) { if (firstMatcher == null) { throw new SpoonException("The firstMatcher Node MUST NOT be null"); } this.firstMatcher = firstMatcher; if (next == null) { throw new SpoonException("The next Node MUST NOT be null"); } this.next = next; }
private <T> T checkNotNull(T o) { if (o == null) { throw new SpoonException("Unexpected null value"); } return o; }
/** * fails when `values` are not sorted ascending * It is used to check whether start/end values of SourcePosition are consistent */ protected static void checkArgsAreAscending(int...values) { int last = -1; for (int value : values) { if (value < 0) { throw new SpoonException("SourcePosition value must not be negative"); } if (last > value) { throw new SpoonException("SourcePosition values must be ascending or equal"); } last = value; } }
public FileSystemFile(File file) { try { this.file = file.getCanonicalFile(); } catch (IOException e) { throw new SpoonException(e); } }
public FileSystemFolder(File file) { if (!file.isDirectory()) { throw new SpoonException("Not a directory " + file); } try { this.file = file.getCanonicalFile(); } catch (Exception e) { throw new SpoonException(e); } }
/** * @param ctRole to be checked {@link CtRole} * @return true if `ctRole` of scope `element` is modified */ public boolean isRoleModified(CtRole ctRole) { if (changedRoles == null) { throw new SpoonException("changedRoles are not initialized for this ChangeResolver. Use getChanges(...) instead"); } return changedRoles.contains(ctRole); }
private static boolean _java8_isDefault(Method method) { if (_method_isDefault == null) { //spoon is running with java 7 JDK, all methods are not default, because java 7 does not have default methods return false; } try { return (Boolean) _method_isDefault.invoke(method); } catch (IllegalAccessException | IllegalArgumentException e) { throw new SpoonException("Calling of Java8 Method#isDefault() failed", e); } catch (InvocationTargetException e) { throw new SpoonException("Calling of Java8 Method#isDefault() failed", e.getTargetException()); } }
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()); } /**
@Override public AbstractRenameRefactoring<T> setNewName(String newName) { if (newNameValidationRE != null && newNameValidationRE.matcher(newName).matches() == false) { throw new SpoonException("New name \"" + newName + "\" is not valid name"); } this.newName = newName; return this; } }
@Override protected void enter(CtElement e) { throw new SpoonException("Unsupported variable of type " + e.getClass().getName()); } /**
String getNextToken(String delimiters) { try { if (off >= length) { return null; } String token = tokenizer.nextToken(delimiters); off += token.length(); return token; } catch (NoSuchElementException e) { throw new SpoonException("Unexpected error", e); } } }
private static String replaceApiToImplPackage(String modelInterfaceQName) { if (modelInterfaceQName.startsWith(modelApiPackage) == false) { throw new SpoonException("The qualified name " + modelInterfaceQName + " doesn't belong to Spoon model API package: " + modelApiPackage); } return modelApiImplPackage + modelInterfaceQName.substring(modelApiPackage.length()); }