ASTNode node= haveSource ? getHoveredASTNode(editorInputElement, hoverRegion) : null; IBinding binding= getHoverBinding(element, node);
ASTNode node= haveSource ? getHoveredASTNode(editorInputElement, hoverRegion) : null; IBinding binding= getHoverBinding(element, node);
ASTNode node= getHoveredASTNode(editorInputElement, hoverRegion);
/** * 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); } }
private static IBinding getHoveredNodeBinding(IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion) { if (editorInputElement == null || hoverRegion == null) { return null; } IBinding binding; ASTNode node= getHoveredASTNode(editorInputElement, hoverRegion); if (node == null) { ASTParser p= ASTParser.newParser(IASTSharedValues.SHARED_AST_LEVEL); p.setProject(element.getJavaProject()); p.setBindingsRecovery(true); try { binding= p.createBindings(new IJavaElement[] { element }, null)[0]; } catch (OperationCanceledException e) { return null; } } else { binding= resolveBinding(node); } return binding; }
/** * 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); } }