/** * Returns the string representation of the given constant value. * * @param constantValue the constant value * @return the string representation of the given constant value. * @since 3.4 */ private static String formatCompilerConstantValue(Object constantValue) { if (constantValue instanceof String) { StringBuilder result= new StringBuilder(); result.append('"'); String stringConstant= (String)constantValue; if (stringConstant.length() > 80) { result.append(stringConstant.substring(0, 80)); result.append(JavaElementLabels.ELLIPSIS_STRING); } else { result.append(stringConstant); } result.append('"'); return result.toString(); } else { return JavadocHover.getHexConstantValue(constantValue); } }
/** * Returns the string representation of the given constant value. * * @param constantValue the constant value * @return the string representation of the given constant value. * @since 3.4 */ private static String formatCompilerConstantValue(Object constantValue) { if (constantValue instanceof String) { StringBuffer result= new StringBuffer(); result.append('"'); String stringConstant= (String)constantValue; if (stringConstant.length() > 80) { result.append(stringConstant.substring(0, 80)); result.append(JavaElementLabels.ELLIPSIS_STRING); } else { result.append(stringConstant); } result.append('"'); return result.toString(); } else { return JavadocHover.getHexConstantValue(constantValue); } }
/** * Returns the constant value for the given field. * * @param field the field * @param editorInputElement the editor input element * @param hoverRegion the hover region in the editor * @return the constant value for the given field or <code>null</code> if none * @since 3.4 */ private static String getConstantValue(IField field, ITypeRoot editorInputElement, IRegion hoverRegion) { if (!isStaticFinal(field)) return null; Object constantValue; if (editorInputElement == null || hoverRegion == null) { constantValue= JavadocView.computeFieldConstantFromTypeAST(field, null); } else { ASTNode node= getHoveredASTNode(editorInputElement, hoverRegion); if (node == null) return null; constantValue= getVariableBindingConstValue(node, field); } if (constantValue == null) return null; if (constantValue instanceof String) { return ASTNodes.getEscapedStringLiteral((String) constantValue); } else { return getHexConstantValue(constantValue); } }
/** * Returns the constant value for the given field. * * @param field the field * @param editorInputElement the editor input element * @param hoverRegion the hover region in the editor * @return the constant value for the given field or <code>null</code> if none * @since 3.4 */ private static String getConstantValue(IField field, ITypeRoot editorInputElement, IRegion hoverRegion) { if (!isStaticFinal(field)) return null; Object constantValue; if (editorInputElement == null || hoverRegion == null) { constantValue= JavadocView.computeFieldConstantFromTypeAST(field, null); } else { ASTNode node= getHoveredASTNode(editorInputElement, hoverRegion); if (node == null) return null; constantValue= getVariableBindingConstValue(node, field); } if (constantValue == null) return null; if (constantValue instanceof String) { return ASTNodes.getEscapedStringLiteral((String) constantValue); } else { return getHexConstantValue(constantValue); } }