protected void visitAbstractPathExpression(AbstractPathExpression expression) { if (type == LiteralType.PATH_EXPRESSION_IDENTIFICATION_VARIABLE) { expression.getIdentificationVariable().accept(this); } else if (type == LiteralType.PATH_EXPRESSION_ALL_PATH) { literal = expression.toParsedText(); } else if (type == LiteralType.PATH_EXPRESSION_LAST_PATH) { literal = expression.getPath(expression.pathSize() - 1); } } }
private void visitPathExpression(AbstractPathExpression expression, boolean nullAllowed, int lastIndex) { PathResolver resolver = new PathResolver(); resolver.length = lastIndex; resolver.nullAllowed = nullAllowed; resolver.checkMappingType = false; resolver.localExpression = null; resolver.descriptor = null; expression.accept(resolver); queryExpression = resolver.localExpression; }
protected void validatePathExpression(AbstractPathExpression expression) { // Missing identification variable if (!expression.hasIdentificationVariable() && !expression.hasVirtualIdentificationVariable()) { addProblem(expression, AbstractPathExpression_MissingIdentificationVariable); } // Validate the identification variable else { expression.getIdentificationVariable().accept(this); } // Cannot end with a dot if (expression.endsWithDot()) { addProblem(expression, AbstractPathExpression_CannotEndWithComma); } }
boolean isAssociation = false; int count = 1; String fieldName = pathExp.getPath(count++); isEmbeddable = metaModel.isEmbeddable(attrib.getBindableJavaType()); isAssociation = attrib.isAssociation(); while (pathExp.pathSize() > count) String attName = pathExp.getPath(count++); fieldName = fieldName + "." + attName; attrib = (AbstractAttribute) embeddableType.getAttribute(attName); String attName = pathExp.getPath(count++); fieldName = fieldName + "." + attName; EntityType associatedType = metaModel.entity(attrib.getBindableJavaType()); if (!pathExp.getPath(count - 1).equals(discriminatorColumn))
/** * {@inheritDoc} */ @Override protected final void addOrderedChildrenTo(List<Expression> children) { checkPaths(); if (!hasVirtualIdentificationVariable()) { children.add(identificationVariable); } children.add(buildStringExpression(getText())); }
if (!expression.hasIdentificationVariable() || expression.startsWithDot()) { Resolver resolver = queryContext.getResolver(expression.getIdentificationVariable()); for (int index = expression.hasVirtualIdentificationVariable() ? 0 : 1, count = expression.pathSize(); index < count; index++) { String path = expression.getPath(index); Resolver childResolver = resolver.getChild(path); int extraOffset = expression.toParsedText(0, index).length() + 1 /* '.' */; addTextEdit(expression, extraOffset, oldAttributeName, newAttributeName); break;
private void visitPathExpression(AbstractPathExpression expression) { expression.getIdentificationVariable().accept(this); for (int index = expression.hasVirtualIdentificationVariable() ? 0 : 1, count = expression.pathSize(); index < count; index++) { String path = expression.getPath(index); mapping = descriptor.getObjectBuilder().getMappingForAttributeName(path);
/** * Attempts to resolve the path expression as a fully qualified enum constant. * * @param expression The {@link AbstractPathExpression} that might represent an enum constant * @return <code>true</code> if the path was a fully qualified enum constant; <code>false</code> * if it's an actual path expression */ protected boolean resolveEnumConstant(AbstractPathExpression expression) { String fullPath = expression.toParsedText(); Class<?> enumType = queryContext.getEnumType(fullPath); if (enumType != null) { // Make sure we keep track of the enum type type[0] = enumType; // Retrieve the enum constant String path = expression.getPath(expression.pathSize() - 1); Enum<?> enumConstant = retrieveEnumConstant(enumType, path); // Create the Expression localExpression = new ConstantExpression(enumConstant, new ExpressionBuilder()); return true; } return false; }
int length = 0; for (int index = 0, count = expression.pathSize(); index < count; index++) { String path = expression.getPath(index); resolver = queryContext.getResolver(expression.getIdentificationVariable()); else if ((index + 1 < count) || expression.endsWithDot()) { Resolver childResolver = resolver.getChild(path); if (childResolver == null) {
protected final void toParsedText(StringBuilder writer, boolean actual) { checkPaths(); for (int index = 0, count = pathSize(); index < count; index++) { if ((index == 0) && hasIdentificationVariable()) { identificationVariable.toParsedText(writer, actual);
private void visitAbstractPathExpression(AbstractPathExpression expression) { if (!expression.startsWithDot()) { // Visit the general identification variable to make sure it's not a map key, map entry // or map value expression GeneralIdentificationVariableVisitor visitor = generalIdentificationVariableVisitor(); expression.getIdentificationVariable().accept(visitor); if (visitor.expression == null) { expression.setVirtualIdentificationVariable(variableName); } } }
private void resolvePath(AbstractPathExpression expression) { for (int index = expression.hasVirtualIdentificationVariable() ? 0 : 1, count = length; index < count; index++) { String path = expression.getPath(index); DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(path); boolean last = (index + 1 == count);
private Class<?> resolveMappingType(AbstractPathExpression expression) { PathResolver resolver = pathResolver(); QueryKey oldQueryKey = resolver.queryKey; DatabaseMapping oldMapping = resolver.mapping; ClassDescriptor oldDescriptor = resolver.descriptor; try { resolver.mapping = null; resolver.descriptor = null; resolver.queryKey = null; expression.accept(resolver); if (resolver.mapping != null) { return calculateMappingType(resolver.mapping); } else if (resolver.queryKey != null) { return calculateQueryKeyType(resolver.queryKey); } else { return queryContext.getEnumType(expression.toParsedText()); } } finally { resolver.mapping = oldMapping; resolver.queryKey = oldQueryKey; resolver.descriptor = oldDescriptor; } }
/** * Determines whether the path ends with a dot or not. * * @return <code>true</code> if the path ends with a dot; <code>false</code> otherwise */ public final boolean endsWithDot() { checkPaths(); return endsWithDot; }
private void resolveVirtualPath(AbstractPathExpression expression) { String path = expression.getPath(1); localExpression = localExpression.get(path); }
/** * {@inheritDoc} */ public void acceptChildren(ExpressionVisitor visitor) { getIdentificationVariable().accept(visitor); }
String text = getText(); char character = '\0'; StringBuilder singlePath = new StringBuilder(); identificationVariable = buildNullExpression();
protected void visitEnumConstant(AbstractPathExpression expression) { int position = queryPosition.getPosition(expression); String text = expression.toActualText(); int lastDotIndex = text.lastIndexOf(DOT); // Check to see if an enum constant can be used at the expression's location if (isEnumAllowed(expression)) { boolean enumConstant = false; // The position is after the last dot, check for enum constants if (position > lastDotIndex) { // Retrieve the enum type if the path up to the last dot is a fully qualified enum type String enumType = expression.toParsedText().substring(0, lastDotIndex); IType type = queryContext.getType(enumType); // The path expression before the last dot is an enum type if (type.isResolvable() && type.isEnum()) { enumConstant = true; // Now retrieve the portion of the enum constant based on the cursor position String word = text.substring(lastDotIndex + 1, position); // Add the enum constants and filter them based on what's already proposed addEnumConstants(type, word); } } // Enum type if (!enumConstant) { // Now retrieve the portion of the enum constant based on the cursor position text = text.substring(0, position); // Set the possible starting of a fully qualified enum type proposals.setClassNamePrefix(text, ClassType.ENUM); } } }
String text = expression.toActualText(); int dotIndex = text.indexOf(DOT); expression.getIdentificationVariable(), LiteralType.IDENTIFICATION_VARIABLE );
private void visitPathExpression(AbstractPathExpression expression) { expression.getIdentificationVariable().accept(this); for (int index = expression.hasVirtualIdentificationVariable() ? 0 : 1, count = expression.pathSize(); index < count; index++) { String path = expression.getPath(index); mapping = descriptor.getObjectBuilder().getMappingForAttributeName(path);