/* (non-Javadoc) * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) */ public Color getForeground(Object element) { if (fMethodsViewer.isShowInheritedMethods() && element instanceof IFunction) { IFunction curr = (IFunction) element; IMember declaringType = curr.getDeclaringType(); if (declaringType == null || !declaringType.equals(fMethodsViewer.getInput())) { return JFaceResources.getColorRegistry().get(ColoredViewersManager.INHERITED_COLOR_NAME); } } return null; }
private static IMember getMember(IStructuredSelection selection) throws JavaScriptModelException { if (selection.size() != 1) return null; Object element = selection.getFirstElement(); if (!(element instanceof IMember)) return null; if (element instanceof IFunction) { IFunction method = (IFunction) element; String returnType = method.getReturnType(); if (PrimitiveType.toCode(Signature.toString(returnType)) != null) return null; return method; } else if (element instanceof IField) { return (IField) element; } return null; }
private IType getDefiningType(Object element) throws JavaScriptModelException { int kind = ((IJavaScriptElement) element).getElementType(); if (kind != IJavaScriptElement.METHOD && kind != IJavaScriptElement.FIELD && kind != IJavaScriptElement.INITIALIZER) { return null; } IType declaringType = ((IMember) element).getDeclaringType(); if (kind != IJavaScriptElement.METHOD) { return declaringType; } ITypeHierarchy hierarchy = fHierarchy.getHierarchy(); if (hierarchy == null) { return declaringType; } IFunction method = (IFunction) element; MethodOverrideTester tester = new MethodOverrideTester(declaringType, hierarchy); IFunction res = tester.findDeclaringMethod(method, true); if (res == null || method.equals(res)) { return declaringType; } return res.getDeclaringType(); }
/* * Instanciate a method pattern with signatures for generics search */ public MethodPattern( boolean findDeclarations, boolean findReferences, boolean isFunction, char[] selector, char[] declaringQualification, char[] declaringSimpleName, char[] returnQualification, char[] returnSimpleName, String returnSignature, char[][] parameterQualifications, char[][] parameterSimpleNames, String[] parameterSignatures, IFunction method, int matchRule) { this( findDeclarations, findReferences, isFunction, selector, declaringQualification, declaringSimpleName, returnQualification, returnSimpleName, parameterQualifications, parameterSimpleNames, method.getDeclaringType(), matchRule); // Set flags try { this.varargs = (method.getFlags() & Flags.AccVarargs) != 0; } catch (JavaScriptModelException e) { // do nothing } methodParameters = true; if (declaringType != null) { // Store type signature and arguments for declaring type storeTypeSignaturesAndArguments(declaringType); } // Store type signatures and arguments for return type if (returnSignature != null) { returnTypeSignatures = Util.splitTypeLevelsSignature(returnSignature); returnTypeArguments = Util.getAllTypeArguments(returnTypeSignatures); } // Store type signatures and arguments for method parameters type if (parameterSignatures != null) { int length = parameterSignatures.length; if (length > 0) { parametersTypeSignatures = new char[length][][]; parametersTypeArguments = new char[length][][][]; for (int i = 0; i < length; i++) { parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]); parametersTypeArguments[i] = Util.getAllTypeArguments(parametersTypeSignatures[i]); } } } // Store type signatures and arguments for method methodArguments = extractMethodArguments(method); if (hasMethodArguments()) ((InternalSearchPattern) this).mustResolve = true; }