public String getPropertyAsString() { if (property==null) return null; if (! (property instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) property; return constant.getText(); }
/** * This method returns the method name as String if it is no dynamic * calculated method name, but a constant. */ public String getMethodAsString() { if (! (method instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) method; return constant.getText(); }
private Pattern determineClassNamePattern(Expression expr) { if (!(expr instanceof ConstantExpression)) { return null; } final ConstantExpression constExpr = (ConstantExpression) expr; final String text = constExpr.getText(); if (constExpr.getValue() == null || text.equals("")) { return null; } try { final Pattern pattern = Pattern.compile(text); return pattern; } catch (PatternSyntaxException e) { addError("Invalid class name pattern: " + e.getMessage(), expr); return null; } }
protected String getMethodName(Expression message) { String methodName = null; if (message instanceof CastExpression) { CastExpression msg = (CastExpression) message; if (msg.getType() == ClassHelper.STRING_TYPE) { final Expression methodExpr = msg.getExpression(); if (methodExpr instanceof ConstantExpression) methodName = methodExpr.getText(); } } if (methodName == null && message instanceof ConstantExpression) { ConstantExpression constantExpression = (ConstantExpression) message; methodName = constantExpression.getText(); } return methodName; }
out.print("(String)null"); } else { out.print(expression.getText());
public void visitMethodCallExpression(MethodCallExpression call) { if (call.isImplicitThis() && call.getMethod() instanceof ConstantExpression) { ConstantExpression methodNameConstant = (ConstantExpression) call.getMethod(); Object value = methodNameConstant.getText(); if (!(value instanceof String)) { throw new GroovyBugError("tried to make a method call with a non-String constant method name."); } String methodName = (String) value; Variable v = checkVariableNameForDeclaration(methodName, call); if (v != null && !(v instanceof DynamicVariable)) { checkVariableContextAccess(v, call); } if (v instanceof VariableExpression || v instanceof Parameter) { VariableExpression object = new VariableExpression(v); object.setSourcePosition(methodNameConstant); call.setObjectExpression(object); ConstantExpression method = new ConstantExpression("call"); method.setSourcePosition(methodNameConstant); // important for GROOVY-4344 call.setImplicitThis(false); call.setMethod(method); } } super.visitMethodCallExpression(call); }
public String getPropertyAsString() { if (property==null) return null; if (! (property instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) property; return constant.getText(); }
public String getPropertyAsString() { if (property==null) return null; if (! (property instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) property; return constant.getText(); }
/** * This method returns the method name as String if it is no dynamic * calculated method name, but a constant. */ public String getMethodAsString() { if (! (method instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) method; return constant.getText(); }
public String getPropertyAsString() { if (property==null) return null; if (! (property instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) property; return constant.getText(); }
/** * This method returns the method name as String if it is no dynamic * calculated method name, but a constant. */ public String getMethodAsString() { if (! (method instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) method; return constant.getText(); }
public String getPropertyAsString() { if (property==null) return null; if (! (property instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) property; return constant.getText(); }
/** * This method returns the method name as String if it is no dynamic * calculated method name, but a constant. */ public String getMethodAsString() { if (! (method instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) method; return constant.getText(); }
/** * This method returns the method name as String if it is no dynamic * calculated method name, but a constant. */ public String getMethodAsString() { if (! (method instanceof ConstantExpression)) return null; ConstantExpression constant = (ConstantExpression) method; return constant.getText(); }
public static boolean isSameMethod(ExecutableElement javaMethod, MethodCallExpression methodCall) { ConstantExpression methodName = (ConstantExpression) methodCall.getMethod(); if (javaMethod.getSimpleName().contentEquals(methodName.getText())) { // not comparing parameter types for now, only their count // is it even possible to make some check for parameter types? if (getParameterCount(methodCall) == javaMethod.getParameters().size()) { return true; } } return false; }
private static void addMapChangeListener(ClassNode classNode, String propertyName, ConstantExpression reference, boolean useWeakListener) { addMapChangeListener(classNode, propertyName, new VariableExpression(reference.getText()), useWeakListener); }
public static void addEventPublisherIfNeeded(SourceUnit source, AnnotationNode annotationNode, ClassNode classNode) { if (needsDelegate(classNode, source, METHODS, "EventPublisher", EVENT_PUBLISHER_TYPE)) { LOG.debug("Injecting {} into {}", EVENT_PUBLISHER_TYPE, classNode.getName()); ConstantExpression value = (ConstantExpression) annotationNode.getMember("value"); String beanName = value != null ? value.getText() : null; beanName = isBlank(beanName) ? null : beanName; apply(classNode, beanName); } }
public static void addResourceResolverIfNeeded(SourceUnit source, AnnotationNode annotationNode, ClassNode classNode) { if (needsDelegate(classNode, source, METHODS, "ResourceResolverAware", RESOURCE_RESOLVER_TYPE)) { LOG.debug("Injecting {} into {}", RESOURCE_RESOLVER_TYPE, classNode.getName()); ConstantExpression value = (ConstantExpression) annotationNode.getMember("value"); String beanName = value != null ? value.getText() : null; beanName = isBlank(beanName) ? "applicationResourceResolver" : beanName; apply(classNode, beanName); } }
public static void addMessageSourceIfNeeded(SourceUnit source, AnnotationNode annotationNode, ClassNode classNode) { if (needsDelegate(classNode, source, METHODS, "MessageSourceAware", MESSAGE_SOURCE_TYPE)) { LOG.debug("Injecting {} into {}", MESSAGE_SOURCE_TYPE, classNode.getName()); ConstantExpression value = (ConstantExpression) annotationNode.getMember("value"); String beanName = value != null ? value.getText() : null; beanName = isBlank(beanName) ? "applicationMessageSource" : beanName; apply(classNode, beanName); } }
private static void addPropertyChangeListener(ClassNode classNode, String propertyName, ConstantExpression reference) { ArgumentListExpression args = new ArgumentListExpression(); if (propertyName != null) args.addExpression(new ConstantExpression(propertyName)); VariableExpression variable = new VariableExpression(reference.getText()); args.addExpression(CastExpression.asExpression(PROPERTY_CHANGE_LISTENER_CLASS, variable)); addListenerStatement(classNode, args); }