Java Code Examples for org.eclipse.jdt.internal.core.util.Util#getProblemArgumentsFromMarker()

The following examples show how to use org.eclipse.jdt.internal.core.util.Util#getProblemArgumentsFromMarker() . 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: CorrectionEngine.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Performs code correction for the given marker,
 * reporting results to the given correction requestor.
 *
 * Correction results are answered through a requestor.
 *
 * @param marker
 * 		the marker which describe the problem to correct.
 * @param targetUnit
 * 		replace the compilation unit given by the marker. Ignored if null.
 * @param positionOffset
 * 		the offset of position given by the marker.
 * @param requestor
 * 		the given correction requestor
 * @exception IllegalArgumentException if <code>requestor</code> is <code>null</code>
 * @exception JavaModelException currently this exception is never thrown, but the opportunity to thrown an exception
 * 	when the correction failed is kept for later.
 * @since 2.0
 */
public void computeCorrections(IMarker marker, ICompilationUnit targetUnit, int positionOffset, ICorrectionRequestor requestor) throws JavaModelException {

	IJavaElement element = targetUnit == null ? JavaCore.create(marker.getResource()) : targetUnit;

	if(!(element instanceof ICompilationUnit))
		return;

	ICompilationUnit unit = (ICompilationUnit) element;

	int id = marker.getAttribute(IJavaModelMarker.ID, -1);
	String[] args = Util.getProblemArgumentsFromMarker(marker.getAttribute(IJavaModelMarker.ARGUMENTS, "")); //$NON-NLS-1$
	int start = marker.getAttribute(IMarker.CHAR_START, -1);
	int end = marker.getAttribute(IMarker.CHAR_END, -1);

	computeCorrections(unit, id, start + positionOffset, end + positionOffset, args, requestor);
}
 
Example 2
Source File: CorrectionEngine.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Helper method for decoding problem marker attributes. Returns an array of String arguments
 * extracted from the problem marker "arguments" attribute, or <code>null</code> if the marker
 * "arguments" attribute is missing or ill-formed.
 *
 * @param problemMarker
 * 		the problem marker to decode arguments from.
 * @return an array of String arguments, or <code>null</code> if unable to extract arguments
 * @since 2.1
 */
public static String[] getProblemArguments(IMarker problemMarker){
	String argumentsString = problemMarker.getAttribute(IJavaModelMarker.ARGUMENTS, null);
	return Util.getProblemArgumentsFromMarker(argumentsString);
}