@Override public boolean equals(Object obj) { if (obj == this) return true; // avoid unnecessary calls for identical objects if (obj instanceof TypeNameMatch) { TypeNameMatch match = (TypeNameMatch) obj; if (this.type == null) { return match.getType() == null && match.getModifiers() == this.modifiers; } return this.type.equals(match.getType()) && match.getModifiers() == this.modifiers; } return false; }
public String getQualifiedText(TypeNameMatch type) { StringBuffer result= new StringBuffer(); result.append(type.getSimpleTypeName()); String containerName= type.getTypeContainerName(); result.append(JavaElementLabels.CONCAT_STRING); if (containerName.length() > 0) { result.append(containerName); } else { result.append(JavaUIMessages.FilteredTypesSelectionDialog_default_package); } return result.toString(); }
@Override public void acceptTypeNameMatch(TypeNameMatch typeNameMatch) { final boolean isTopLevelType = typeNameMatch.getType().getDeclaringType() == null; if (isTopLevelType) { if (!pkgName.equals(typeNameMatch.getPackageName())) { // sanity check failed throw new IllegalStateException("Expected package '" + typeNameMatch.getPackageName() + "' to be equal to '" + pkgName + "'"); } QName qname = QName.valueOf(typeNameMatch.getFullyQualifiedName()); types.addName(FQN.fromImport(qname, true)); } } };
private boolean matchesScope(TypeNameMatch type) { if (fIsWorkspaceScope) return true; return fScope.encloses(type.getType()); }
private boolean isVisible(TypeNameMatch curr) { int flags= curr.getModifiers(); if (Flags.isPrivate(flags)) { return false; } if (Flags.isPublic(flags) || Flags.isProtected(flags)) { return true; } return curr.getPackageName().equals(fCurrPackage.getElementName()); }
protected void setResult(List newResult) { List resultToReturn= new ArrayList(); for (int i= 0; i < newResult.size(); i++) { if (newResult.get(i) instanceof TypeNameMatch) { IType type= ((TypeNameMatch) newResult.get(i)).getType(); if (type.exists()) { // items are added to history in the // org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#computeResult() // method resultToReturn.add(type); } else { TypeNameMatch typeInfo= (TypeNameMatch) newResult.get(i); IPackageFragmentRoot root= typeInfo.getPackageFragmentRoot(); String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED); String message= Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName }); MessageDialog.openError(getShell(), fTitle, message); getSelectionHistory().remove(typeInfo); } } } super.setResult(resultToReturn); }
private boolean isVisible(TypeNameMatch curr) { int flags= curr.getModifiers(); if (Flags.isPrivate(flags)) { return false; } boolean isPublic; try { isPublic= JdtFlags.isPublic(curr.getType()); } catch (JavaModelException e) { isPublic= Flags.isPublic(flags); } if (isPublic || Flags.isProtected(flags)) { return true; } return curr.getPackageName().equals(fCurrPackage.getElementName()); }
protected IStatus validateItem(Object item) { if (item == null) return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, "", null); //$NON-NLS-1$ if (fValidator != null) { IType type= ((TypeNameMatch) item).getType(); if (!type.exists()) return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_error_type_doesnot_exist, ((TypeNameMatch) item).getFullyQualifiedName()), null); Object[] elements= { type }; return fValidator.validate(elements); } else return new Status(IStatus.OK, JavaPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$ }
private String getTypeContainerName(TypeNameMatch info) { String result= info.getTypeContainerName(); if (result.length() > 0) return result; return JavaUIMessages.FilteredTypesSelectionDialog_default_package; }
public String getElementName(Object item) { if(item instanceof TypeNameMatch) { return ((TypeNameMatch)item).getSimpleTypeName(); } return null; }
private int getElementTypeCategory(TypeNameMatch type) { try { if (type.getPackageFragmentRoot().getKind() == IPackageFragmentRoot.K_SOURCE) return 0; } catch (JavaModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 1; } }
public synchronized TypeNameMatch[] getFilteredTypeInfos(TypeInfoFilter filter) { Collection<TypeNameMatch> values= getValues(); List<TypeNameMatch> result= new ArrayList<>(); for (Iterator<TypeNameMatch> iter= values.iterator(); iter.hasNext();) { TypeNameMatch type= iter.next(); if ((filter == null || filter.matchesHistoryElement(type)) && !TypeFilter.isFiltered(type.getFullyQualifiedName())) result.add(type); } Collections.reverse(result); return result.toArray(new TypeNameMatch[result.size()]); }
private boolean isFiltered(TypeNameMatch match) { boolean filteredByPattern= filter(match.getFullyQualifiedName()); if (filteredByPattern) return true; int accessibility= match.getAccessibility(); switch (accessibility) { case IAccessRule.K_NON_ACCESSIBLE: return JavaCore.ENABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK)); case IAccessRule.K_DISCOURAGED: return JavaCore.ENABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK)); default: return false; } }
@Override public String getPackageName() { return fMatch.getPackageName(); }
public ImageDescriptor getImageDescriptor(Object element) { TypeNameMatch type= (TypeNameMatch)element; if (fProviderExtension != null) { fAdapter.setMatch(type); ImageDescriptor descriptor= fProviderExtension.getImageDescriptor(fAdapter); if (descriptor != null) return descriptor; } return JavaElementImageProvider.getTypeImageDescriptor( isInnerType(type), false, type.getModifiers(), false); }
public void acceptTypeNameMatch(TypeNameMatch match) { if (SelectionEngine.this.requestor instanceof SelectionRequestor) { SelectionEngine.this.noProposal = false; ((SelectionRequestor)SelectionEngine.this.requestor).acceptType(match.getType()); } } };
private boolean isVisible(TypeNameMatch curr) { int flags= curr.getModifiers(); if (Flags.isPrivate(flags)) { return false; } if (Flags.isPublic(flags) || Flags.isProtected(flags)) { return true; } return curr.getPackageName().equals(fCurrPackage.getElementName()); }
for (int i= 0; i < selected.length; i++) { TypeNameMatch typeInfo= selected[i]; IType type= typeInfo.getType(); if (!type.exists()) { String title= JavaUIMessages.TypeSelectionDialog_errorTitle; IPackageFragmentRoot root= typeInfo.getPackageFragmentRoot(); String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED); String message= Messages.format(JavaUIMessages.TypeSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName }); MessageDialog.openError(getShell(), title, message); history.remove(typeInfo);
protected void handleWidgetSelected(TypeNameMatch[] selection) { IStatus status= null; if (selection.length == 0) { status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, "",null); //$NON-NLS-1$ } else { if (fValidator != null) { List jElements= new ArrayList(); for (int i= 0; i < selection.length; i++) { IType type= selection[i].getType(); if (type != null) { jElements.add(type); } else { status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, Messages.format(JavaUIMessages.TypeSelectionDialog_error_type_doesnot_exist, selection[i].getFullyQualifiedName()), null); break; } } if (status == null) { status= fValidator.validate(jElements.toArray()); } } else { status= new Status(IStatus.OK, JavaPlugin.getPluginId(), IStatus.OK, "",null); //$NON-NLS-1$ } } updateStatus(status); }
private String getTypeContainerName(TypeNameMatch info) { String result= info.getTypeContainerName(); if (result.length() > 0) return result; return JavaUIMessages.TypeInfoViewer_default_package; }