/** * {@inheritDoc} */ @Override protected void visitThirdPartyPathExpression(AbstractPathExpression expression, String variableName) { // Check to see if a column name can be resolved int position = queryPosition.getPosition(expression); String text = expression.toActualText(); int dotIndex = text.indexOf(DOT); int secondDotIndex = (dotIndex > -1) ? text.indexOf(DOT, dotIndex + 1) : -1; // The cursor position is after the first dot and either there is no second dot or the // position is before the second dot, which means a table name and column names could // potentially be resolved if ((secondDotIndex == -1) || (position < secondDotIndex)) { String tableName = getTableName(variableName); if (tableName != ExpressionTools.EMPTY_STRING) { tableName = ExpressionTools.unquote(tableName); proposals.setTableName(tableName, text.substring(dotIndex + 1, position)); } } }
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);