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); } } }
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); } } }
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); } } }
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; } }
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; } }
/** * 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; }
/** * 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 extraOffset = expression.toParsedText(0, index).length() + 1 /* '.' */; addTextEdit(expression, extraOffset, oldAttributeName, newAttributeName); break;