org.eclipse.jdt.core.IProblemRequestor Java Examples

The following examples show how to use org.eclipse.jdt.core.IProblemRequestor. 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: JavaSpellingReconcileStrategy.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void accept(SpellingProblem problem) {
	IProblemRequestor requestor= fRequestor;
	if (requestor != null) {
		try {
			int line= getDocument().getLineOfOffset(problem.getOffset()) + 1;
			String word= getDocument().get(problem.getOffset(), problem.getLength());
			boolean dictionaryMatch= false;
			boolean sentenceStart= false;
			if (problem instanceof JavaSpellingProblem) {
				dictionaryMatch= ((JavaSpellingProblem)problem).isDictionaryMatch();
				sentenceStart= ((JavaSpellingProblem) problem).isSentenceStart();
			}
			// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514
			IEditorInput editorInput= fEditor.getEditorInput();
			if (editorInput != null) {
				CoreSpellingProblem iProblem= new CoreSpellingProblem(problem.getOffset(), problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, sentenceStart, getDocument(), editorInput.getName());
				requestor.acceptProblem(iProblem);
			}
		} catch (BadLocationException x) {
			// drop this SpellingProblem
		}
	}
}
 
Example #2
Source File: MavenClasspathTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private WorkingCopyOwner getWorkingCopy(IProblemRequestor handler) {
	return new WorkingCopyOwner() {

		@Override
		public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) {
			return handler;
		}
	};
}
 
Example #3
Source File: LanguageServerWorkingCopyOwner.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IProblemRequestor getProblemRequestor(ICompilationUnit cu) {
	return new DiagnosticsHandler(connection, cu);
}
 
Example #4
Source File: CompilationUnitDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected FileInfo createFileInfo(Object element) throws CoreException {
	ICompilationUnit original= null;
	if (element instanceof IFileEditorInput) {
		IFileEditorInput input= (IFileEditorInput) element;
		original= createCompilationUnit(input.getFile());
		if (original == null)
			return null;
	}

	FileInfo info= super.createFileInfo(element);
	if (!(info instanceof CompilationUnitInfo))
		return null;

	if (original == null)
		original= createFakeCompiltationUnit(element, false);
	if (original == null)
		return null;

	CompilationUnitInfo cuInfo= (CompilationUnitInfo) info;
	setUpSynchronization(cuInfo);

	IProblemRequestor requestor= cuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) cuInfo.fModel : null;
	if (requestor instanceof IProblemRequestorExtension) {
		IProblemRequestorExtension extension= (IProblemRequestorExtension) requestor;
		extension.setIsActive(false);
		extension.setIsHandlingTemporaryProblems(isHandlingTemporaryProblems());
	}

	IResource resource= original.getResource();
	if (JavaModelUtil.isPrimary(original) && (resource == null || resource.exists()))
		original.becomeWorkingCopy(requestor, getProgressMonitor());
	cuInfo.fCopy= original;

	if (cuInfo.fModel instanceof CompilationUnitAnnotationModel)   {
		CompilationUnitAnnotationModel model= (CompilationUnitAnnotationModel) cuInfo.fModel;
		model.setCompilationUnit(cuInfo.fCopy);
	}

	if (cuInfo.fModel != null)
		cuInfo.fModel.addAnnotationModelListener(fGlobalAnnotationModelListener);

	return cuInfo;
}
 
Example #5
Source File: JavaSpellingReconcileStrategy.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Update the problem requester based on the current editor
 */
private void updateProblemRequester() {
	IAnnotationModel model= getAnnotationModel();
	fRequestor= (model instanceof IProblemRequestor) ? (IProblemRequestor) model : null;
}