/** * Creates a new descriptor. * * @param element the configuration element to read * @throws InvalidRegistryObjectException if the configuration element is not valid any longer * @throws CoreException if the configuration does not contain mandatory attributes */ ProposalSorterHandle(IConfigurationElement element) throws InvalidRegistryObjectException, CoreException { Assert.isLegal(element != null); fElement= element; fId= element.getAttribute(ID); checkNotNull(fId, ID); String name= element.getAttribute(NAME); if (name == null) fName= fId; else fName= name; fClass= element.getAttribute(CLASS); checkNotNull(fClass, CLASS); }
IStatus status; try { AbstractProposalSorter sorter= getSorter(); PerformanceStats stats= startMeter(SORT, sorter); sorter.endSorting(); status= stopMeter(stats, SORT); return; status= createAPIViolationStatus(SORT); status= createExceptionStatus(x); } catch (CoreException x) { status= createExceptionStatus(x); } catch (RuntimeException x) { status= createExceptionStatus(x);
Status createExceptionStatus(InvalidRegistryObjectException x) { // extension has become invalid - log & disable String disable= createBlameMessage(); String reason= JavaTextMessages.CompletionProposalComputerDescriptor_reason_invalid; return new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, disable + " " + reason, x); //$NON-NLS-1$ }
/** * Returns a cached instance of the sorter as described in the extension's xml. The sorter is * {@link #createSorter() created} the first time that this method is called and then cached. * * @return a new instance of the proposal sorter as described by this descriptor * @throws CoreException if the creation fails * @throws InvalidRegistryObjectException if the extension is not valid any longer (e.g. due to * plug-in unloading) */ private synchronized AbstractProposalSorter getSorter() throws CoreException, InvalidRegistryObjectException { if (fSorter == null && (fActivate || isPluginLoaded())) fSorter= createSorter(); return fSorter; }
ProposalSorterHandle handle= new ProposalSorterHandle(element); final String id= handle.getId(); sorters.put(id, handle); if (DEFAULT_ID.equals(id))
/** * Sets the current proposal sorter into the content assistant. * * @since 3.8 * @see ProposalSorterRegistry#getCurrentSorter() the sorter used if <code>true</code> */ private void setContentAssistSorter() { ProposalSorterHandle currentSorter= ProposalSorterRegistry.getDefault().getCurrentSorter(); try { fAssistant.setSorter(currentSorter.getSorter()); } catch (InvalidRegistryObjectException x) { JavaPlugin.log(currentSorter.createExceptionStatus(x)); } catch (CoreException x) { JavaPlugin.log(currentSorter.createExceptionStatus(x)); } catch (RuntimeException x) { JavaPlugin.log(currentSorter.createExceptionStatus(x)); } }
public void select(ProposalSorterHandle handle) { Assert.isTrue(handle != null); String id= handle.getId(); fPreferenceStore.setValue(fKey, id); } }
private IStatus stopMeter(final PerformanceStats stats, String operation) { if (MEASURE_PERFORMANCE) { stats.endRun(); if (stats.isFailure()) return createPerformanceStatus(operation); } return null; }
/** * Returns a cached instance of the sorter as described in the extension's xml. The sorter is * {@link #createSorter() created} the first time that this method is called and then cached. * * @return a new instance of the proposal sorter as described by this descriptor * @throws CoreException if the creation fails * @throws InvalidRegistryObjectException if the extension is not valid any longer (e.g. due to * plug-in unloading) */ synchronized AbstractProposalSorter getSorter() throws CoreException, InvalidRegistryObjectException { if (fSorter == null) fSorter= createSorter(); return fSorter; }
private synchronized void ensureSortersRead() { if (fSorters != null) return; Map<String, ProposalSorterHandle> sorters= new LinkedHashMap<>(); IExtensionRegistry registry= Platform.getExtensionRegistry(); List<IConfigurationElement> elements= new ArrayList<>(Arrays.asList(registry.getConfigurationElementsFor(JavaPlugin.getPluginId(), EXTENSION_POINT))); for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) { IConfigurationElement element= iter.next(); try { ProposalSorterHandle handle= new ProposalSorterHandle(element); final String id= handle.getId(); sorters.put(id, handle); if (DEFAULT_ID.equals(id)) fDefaultSorter= handle; } catch (InvalidRegistryObjectException x) { /* * Element is not valid any longer as the contributing plug-in was unloaded or for * some other reason. Do not include the extension in the list and inform the user * about it. */ Object[] args= { element.toString() }; String message= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_invalid_message, args); IStatus status= new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, message, x); informUser(status); } catch (CoreException x) { informUser(x.getStatus()); } } fSorters= sorters; }
/** * Sets the current proposal sorter into the content assistant. * * @since 3.8 * @see ProposalSorterRegistry#getCurrentSorter() the sorter used if <code>true</code> */ private void setContentAssistSorter() { ProposalSorterHandle currentSorter= ProposalSorterRegistry.getDefault().getCurrentSorter(); try { fAssistant.setSorter(currentSorter.getSorter()); } catch (InvalidRegistryObjectException x) { JavaPlugin.log(currentSorter.createExceptionStatus(x)); } catch (CoreException x) { JavaPlugin.log(currentSorter.createExceptionStatus(x)); } catch (RuntimeException x) { JavaPlugin.log(currentSorter.createExceptionStatus(x)); } }
public void select(ProposalSorterHandle handle) { Assert.isTrue(handle != null); String id= handle.getId(); fPreferenceStore.setValue(fKey, id); } }
private IStatus stopMeter(final PerformanceStats stats, String operation) { if (MEASURE_PERFORMANCE) { stats.endRun(); if (stats.isFailure()) return createPerformanceStatus(operation); } return null; }
/** * Returns a cached instance of the sorter as described in the extension's xml. The sorter is * {@link #createSorter() created} the first time that this method is called and then cached. * * @return a new instance of the proposal sorter as described by this descriptor * @throws CoreException if the creation fails * @throws InvalidRegistryObjectException if the extension is not valid any longer (e.g. due to * plug-in unloading) */ synchronized AbstractProposalSorter getSorter() throws CoreException, InvalidRegistryObjectException { if (fSorter == null) fSorter= createSorter(); return fSorter; }
IStatus status; try { AbstractProposalSorter sorter= getSorter(); PerformanceStats stats= startMeter(SORT, sorter); sorter.endSorting(); status= stopMeter(stats, SORT); return; status= createAPIViolationStatus(SORT); status= createExceptionStatus(x); } catch (CoreException x) { status= createExceptionStatus(x); } catch (RuntimeException x) { status= createExceptionStatus(x);
Status createExceptionStatus(CoreException x) { // unable to instantiate the extension - log & disable String disable= createBlameMessage(); String reason= JavaTextMessages.CompletionProposalComputerDescriptor_reason_instantiation; return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, disable + " " + reason, x); //$NON-NLS-1$ }
private synchronized void ensureSortersRead() { if (fSorters != null) return; Map<String, ProposalSorterHandle> sorters= new LinkedHashMap<>(); IExtensionRegistry registry= Platform.getExtensionRegistry(); List<IConfigurationElement> elements= new ArrayList<>(Arrays.asList(registry.getConfigurationElementsFor(JavaPlugin.getPluginId(), EXTENSION_POINT))); for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) { IConfigurationElement element= iter.next(); try { ProposalSorterHandle handle= new ProposalSorterHandle(element); final String id= handle.getId(); sorters.put(id, handle); if (DEFAULT_ID.equals(id)) fDefaultSorter= handle; } catch (InvalidRegistryObjectException x) { /* * Element is not valid any longer as the contributing plug-in was unloaded or for * some other reason. Do not include the extension in the list and inform the user * about it. */ Object[] args= { element.toString() }; String message= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_invalid_message, args); IStatus status= new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, message, x); informUser(status); } catch (CoreException x) { informUser(x.getStatus()); } } fSorters= sorters; }