private JavaClass getJavaClass() throws FileNotFoundException { Resource<?> resource = shell.getCurrentResource(); if (resource instanceof JavaResource) { return getJavaClassFrom(resource); } else { throw new RuntimeException("Current resource is not a JavaResource!"); } }
@Override public List<String> getCompletionTokens() { final List<String> tokens = new ArrayList<String>(); final Resource<?> currentResource = shell.getCurrentResource(); try { final JavaClass javaClass = ResourceUtil.getJavaClassFromResource(currentResource); for (Field<JavaClass> oneField : javaClass.getFields()) { tokens.add(oneField.getName()); } } catch (FileNotFoundException e) { throw new RuntimeException(e); } return tokens; } }
@DefaultCommand public void run() { shell.println(shell.getCurrentResource().getFullyQualifiedName()); } }
for (Resource<?> r : new PathspecParser(resourceFactory, shell.getCurrentResource(), val + "*") .resolve())
PathspecParser pathspecParser = new PathspecParser(resourceFactory, shell.getCurrentResource(), path); List<Resource<?>> targets = pathspecParser.search(); shell.println("----------------"); int offset = shell.getCurrentResource().getFullyQualifiedName().length(); if (shell.getCurrentResource() == null) shell.println("Picked up type <" + shell.getCurrentResource().getClass().getSimpleName() + ">: " + resource);
public Resource getCurrentResource(final InjectionPoint ip, final Shell shell) Resource<?> currentResource = shell.getCurrentResource(); Type type = null;
private Annotation<JavaClass> addConstraintOnProperty(String property, boolean onAccessor, Class<? extends java.lang.annotation.Annotation> annotationClass) throws FileNotFoundException { final Resource<?> currentResource = shell.getCurrentResource(); final JavaClass clazz = getJavaClassFromResource(currentResource); final Field<JavaClass> field = clazz.getField(property); if (field == null) { throw new IllegalStateException("The current class has no property named '" + property + "'"); } Member<JavaClass, ?> member = field; if (onAccessor) { final Method<JavaClass> accessor = JavaHelper.getFieldAccessor(field); if (accessor == null) { throw new IllegalStateException("The property named '" + property + "' has no accessor"); } member = accessor; } if (member.hasAnnotation(annotationClass)) { throw new IllegalStateException("The element '" + member.getName() + "' is already annotated with @" + annotationClass.getSimpleName()); } return member.addAnnotation(annotationClass); }
Map<String, List<String>> listGroups = new TreeMap<String, List<String>>(); Class<? extends Resource> currResource = shell.getCurrentResource().getClass();
if (!command.usableWithResource(shell.getCurrentResource().getClass())) + command.getName() + "' is not usable in current scope [" + shell.getCurrentResource().getClass().getSimpleName() + "]" + " -- usable scopes: "
@DefaultCommand(help = "Removes the given constraint on the given property/property accessor") public void removePropertyConstraint( @Option(name = "property", completer = PropertyCompleter.class, required = true) String property, @Option(name = "named", required = true) String constraint, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor) throws FileNotFoundException { final JavaClass clazz = getJavaClassFromResource(shell.getCurrentResource()); final Member<JavaClass, ?> member = getMember(clazz, property, onAccessor); if (member == null) { throw new IllegalStateException("There is no property named '" + property + "' or accessor for this property"); } if (!removeConstraint(member, constraint)) { throw new IllegalStateException("There is no constraint named '" + constraint + "' on " + member.getName()); } // save java source project.getFacet(JavaSourceFacet.class).saveJavaSource(clazz); shell.println("Constraint named '" + constraint + "' has been successfully removed.\n"); }
if (shell.getCurrentResource() == null)