01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *
11: *******************************************************************************/package org.eclipse.jdt.ui.text.java;
12:
13: import org.eclipse.core.runtime.CoreException;
14:
15: import org.eclipse.jdt.core.ICompilationUnit;
16:
17: /**
18: * Interface to be implemented by contributors to the extension point
19: * <code>org.eclipse.jdt.ui.quickFixProcessors</code>.
20: * <p>Since 3.2, each extension specifies the marker types it can handle, and {@link #hasCorrections(ICompilationUnit, int)} and
21: * {@link #getCorrections(IInvocationContext, IProblemLocation[])} are called if (and only if) quick fix is
22: * required for a problem of these types.</p>
23: * <p>Note, if a extension does not specify marker types it will be only called for problem of type
24: * <code>org.eclipse.jdt.core.problem</code>, <code>org.eclipse.jdt.core.buildpath_problem</code>
25: * and <code>org.eclipse.jdt.core.task</code>; compatible with the behavior prior to 3.2</p>
26: *
27: * @since 3.0
28: */
29: public interface IQuickFixProcessor {
30:
31: /**
32: * Returns <code>true</code> if the processor has proposals for the given problem. This test should be an
33: * optimistic guess and be very cheap.
34: *
35: * @param unit the compilation unit
36: * @param problemId the problem Id. The id is of a problem of the problem type(s) this processor specified in
37: * the extension point.
38: * @return <code>true</code> if the processor has proposals for the given problem
39: */
40: boolean hasCorrections(ICompilationUnit unit, int problemId);
41:
42: /**
43: * Collects corrections or code manipulations for the given context.
44: *
45: * @param context Defines current compilation unit, position and a shared AST
46: * @param locations Problems are the current location.
47: * @return the corrections applicable at the location or <code>null</code> if no proposals
48: * can be offered
49: * @throws CoreException CoreException can be thrown if the operation fails
50: */
51: IJavaCompletionProposal[] getCorrections(
52: IInvocationContext context, IProblemLocation[] locations)
53: throws CoreException;
54:
55: }
|