org.eclipse.jface.text.quickassist.IQuickAssistProcessor Java Examples

The following examples show how to use org.eclipse.jface.text.quickassist.IQuickAssistProcessor. 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: PyEditConfiguration.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
    // create a content assistant:
    PyCorrectionAssistant assistant = new PyCorrectionAssistant();

    // next create a content assistant processor to populate the completions window
    IQuickAssistProcessor processor = new PythonCorrectionProcessor(this.getEdit());

    // Correction assist works on all
    assistant.setQuickAssistProcessor(processor);
    assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

    //delay and auto activate set on PyContentAssistant constructor.

    return assistant;
}
 
Example #2
Source File: PydevConsole.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public SourceViewerConfiguration createSourceViewerConfiguration() {
    PyContentAssistant contentAssist = new PyContentAssistant();
    IContentAssistProcessor processor = createConsoleCompletionProcessor(contentAssist);
    contentAssist.setContentAssistProcessor(processor, PydevScriptConsoleSourceViewerConfiguration.PARTITION_TYPE);

    contentAssist.enableAutoActivation(true);
    contentAssist.enableAutoInsert(false);
    contentAssist.setAutoActivationDelay(PyCodeCompletionPreferences.getAutocompleteDelay());

    PyCorrectionAssistant quickAssist = new PyCorrectionAssistant();
    // next create a content assistant processor to populate the completions window
    IQuickAssistProcessor quickAssistProcessor = createConsoleQuickAssistProcessor(quickAssist);

    // Correction assist works on all
    quickAssist.setQuickAssistProcessor(quickAssistProcessor);

    SourceViewerConfiguration cfg = new PydevScriptConsoleSourceViewerConfiguration(createHover(), contentAssist,
            quickAssist);
    return cfg;
}
 
Example #3
Source File: ElementProblem.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * @param length the length of the marker underline. Length == 0 results in a
 *        marker in the vertical ruler and no underline.
 */
ElementProblem(String message, String markerId, int iMarkerSeverity, int iMessageSeverity,
    DocumentLocation start, int length, IQuickAssistProcessor processor) {
  Preconditions.checkNotNull(message, "element name is null");
  Preconditions.checkNotNull(markerId, "markerId is null");
  Preconditions.checkNotNull(start, "start is null");
  Preconditions.checkArgument(length >= 0, "length < 0");
  this.message = message;
  this.start = start;
  this.length = length;
  this.markerId = markerId;
  this.iMarkerSeverity = iMarkerSeverity;
  this.iMessageSeverity = iMessageSeverity;
  this.processor = processor;
}
 
Example #4
Source File: XmlSourceValidator.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a message from a given {@link ElementProblem}.
 */
@VisibleForTesting
void createMessage(IReporter reporter, ElementProblem problem, int offset) {
  IMessage message = new LocalizedMessage(problem.getIMessageSeverity(), problem.getMessage());
  message.setTargetObject(this);
  message.setMarkerId(problem.getMarkerId());
  // TODO offset by line
  int lineNumber = problem.getStart().getLineNumber() + 1;
  message.setLineNo(lineNumber);
  message.setOffset(offset);
  message.setLength(problem.getLength());
  message.setAttribute(IQuickAssistProcessor.class.getName(), problem.getQuickAssistProcessor());
  reporter.addMessage(this, message);
}
 
Example #5
Source File: SpellingQuickfixTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected ICompletionProposal[] computeQuickAssistProposals(int offset) {
	XtextSourceViewer sourceViewer = getSourceViewer();
	XtextReconciler reconciler = (XtextReconciler) sourceViewer.getAdapter(IReconciler.class);
	IReconcilingStrategyExtension reconcilingStrategyExtension = (IReconcilingStrategyExtension) reconciler.getReconcilingStrategy("");
	reconcilingStrategyExtension.initialReconcile();
	QuickAssistAssistant quickAssistAssistant = (QuickAssistAssistant) sourceViewer.getQuickAssistAssistant();
	IQuickAssistProcessor quickAssistProcessor = quickAssistAssistant.getQuickAssistProcessor();
	ICompletionProposal[] quickAssistProposals = quickAssistProcessor
			.computeQuickAssistProposals(new TextInvocationContext(sourceViewer, offset, -1));
	return quickAssistProposals;
}
 
Example #6
Source File: AbstractMultiQuickfixTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected ICompletionProposal[] computeQuickAssistProposals(XtextEditor editor, int offset) {
	IResourcesSetupUtil.waitForBuild();
	XtextSourceViewer sourceViewer = (XtextSourceViewer) editor.getInternalSourceViewer();
	QuickAssistAssistant quickAssistAssistant = (QuickAssistAssistant) sourceViewer.getQuickAssistAssistant();
	IQuickAssistProcessor quickAssistProcessor = quickAssistAssistant.getQuickAssistProcessor();
	ICompletionProposal[] quickAssistProposals = quickAssistProcessor
			.computeQuickAssistProposals(new TextInvocationContext(sourceViewer, offset, -1));
	return quickAssistProposals;
}
 
Example #7
Source File: ElementProblem.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
IQuickAssistProcessor getQuickAssistProcessor() {
  return processor;
}
 
Example #8
Source File: PydevConsole.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected IQuickAssistProcessor createConsoleQuickAssistProcessor(QuickAssistAssistant quickAssist) {
    return new PydevConsoleQuickAssistProcessor((PyCorrectionAssistant) quickAssist);
}
 
Example #9
Source File: ScriptConsole.java    From Pydev with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * @return the assistant that should handle quick assist requests (quick fixes)
 */
protected abstract IQuickAssistProcessor createConsoleQuickAssistProcessor(QuickAssistAssistant quickAssist);