org.eclipse.jdt.core.compiler.CompilationParticipant Java Examples

The following examples show how to use org.eclipse.jdt.core.compiler.CompilationParticipant. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReconcileWorkingCopyOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void notifyParticipants(final CompilationUnit workingCopy) {
	IJavaProject javaProject = getWorkingCopy().getJavaProject();
	CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject);
	if (participants == null) return;

	final ReconcileContext context = new ReconcileContext(this, workingCopy);
	for (int i = 0, length = participants.length; i < length; i++) {
		final CompilationParticipant participant = participants[i];
		SafeRunner.run(new ISafeRunnable() {
			public void handleException(Throwable exception) {
				if (exception instanceof Error) {
					throw (Error) exception; // errors are not supposed to be caught
				} else if (exception instanceof OperationCanceledException)
					throw (OperationCanceledException) exception;
				else if (exception instanceof UnsupportedOperationException) {
					// might want to disable participant as it tried to modify the buffer of the working copy being reconciled
					Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$
				} else
					Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$
			}
			public void run() throws Exception {
				participant.reconcile(context);
			}
		});
	}
}
 
Example #2
Source File: JavaModelManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public CompilationParticipant[] getCompilationParticipants(IJavaProject project) {
	final Object[][] participantsPerSource = getRegisteredParticipants();
	if (participantsPerSource == NO_PARTICIPANTS)
		return null;
	String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true/*inherit options*/);
	final int sourceLevelIndex = indexForSourceLevel(sourceLevel);
	final Object[] participants = participantsPerSource[sourceLevelIndex];
	int length = participants.length;
	CompilationParticipant[] result = new CompilationParticipant[length];
	int index = 0;
	for (int i = 0; i < length; i++) {
		if (participants[i] instanceof IConfigurationElement) {
			final IConfigurationElement configElement = (IConfigurationElement) participants[i];
			final int participantIndex = i;
			SafeRunner.run(new ISafeRunnable() {
				public void handleException(Throwable exception) {
					Util.log(exception, "Exception occurred while creating compilation participant"); //$NON-NLS-1$
				}
				public void run() throws Exception {
					Object executableExtension = configElement.createExecutableExtension("class"); //$NON-NLS-1$
					for (int j = sourceLevelIndex; j < MAX_SOURCE_LEVEL; j++)
						participantsPerSource[j][participantIndex] = executableExtension;
				}
			});
		}
		CompilationParticipant participant;
		if ((participants[i] instanceof CompilationParticipant) && (participant = (CompilationParticipant) participants[i]).isActive(project))
			result[index++] = participant;
	}
	if (index == 0)
		return null;
	if (index < length)
		System.arraycopy(result, 0, result = new CompilationParticipant[index], 0, index);
	return result;
}