public void registerAddedStaticImport(IBinding binding) { if (binding instanceof IVariableBinding) { ITypeBinding declaringType = ((IVariableBinding) binding).getDeclaringClass(); fAddedStaticImports.add( new StaticImportData( Bindings.getRawQualifiedName(declaringType), binding.getName(), true)); } else if (binding instanceof IMethodBinding) { ITypeBinding declaringType = ((IMethodBinding) binding).getDeclaringClass(); fAddedStaticImports.add( new StaticImportData( Bindings.getRawQualifiedName(declaringType), binding.getName(), false)); } else { throw new IllegalArgumentException(binding.toString()); } }
private String[] getVariableNameProposals(ITypeBinding arrayTypeBinding, IJavaProject project) { String[] variableNames = getUsedVariableNames(); String baseName = FOR_LOOP_ELEMENT_IDENTIFIER; String name = fArrayBinding.getName(); if (name.length() > 2 && name.charAt(name.length() - 1) == 's') { baseName = name.substring(0, name.length() - 1); } String[] elementSuggestions = StubUtility.getLocalNameSuggestions(project, baseName, 0, variableNames); String type = arrayTypeBinding.getElementType().getName(); String[] typeSuggestions = StubUtility.getLocalNameSuggestions( project, type, arrayTypeBinding.getDimensions() - 1, variableNames); String[] result = new String[elementSuggestions.length + typeSuggestions.length]; System.arraycopy(elementSuggestions, 0, result, 0, elementSuggestions.length); System.arraycopy(typeSuggestions, 0, result, elementSuggestions.length, typeSuggestions.length); return result; }