org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider. 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: QuickFixXpectMethod.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * CollectAll resolutions under the cursor at offset.
 *
 */
List<IssueResolution> collectAllResolutions(XtextResource resource, RegionWithCursor offset,
		Multimap<Integer, Issue> offset2issue) {

	EObject script = resource.getContents().get(0);
	ICompositeNode scriptNode = NodeModelUtils.getNode(script);
	ILeafNode offsetNode = NodeModelUtils.findLeafNodeAtOffset(scriptNode, offset.getGlobalCursorOffset());
	int offStartLine = offsetNode.getTotalStartLine();
	List<Issue> allIssues = QuickFixTestHelper.extractAllIssuesInLine(offStartLine, offset2issue);

	List<IssueResolution> resolutions = Lists.newArrayList();

	for (Issue issue : allIssues) {
		if (issue.getLineNumber() == offsetNode.getStartLine()
				&& issue.getLineNumber() <= offsetNode.getEndLine()) {

			IssueResolutionProvider quickfixProvider = resource.getResourceServiceProvider()
					.get(IssueResolutionProvider.class);
			Display.getDefault().syncExec(() -> resolutions.addAll(quickfixProvider.getResolutions(issue)));
		}
	}
	return resolutions;
}
 
Example #2
Source File: OwnResourceValidatorAwareValidatingEditorCallback.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private ValidationJob newValidationJob(final XtextEditor editor) {

		final IXtextDocument document = editor.getDocument();
		final IAnnotationModel annotationModel = editor.getInternalSourceViewer().getAnnotationModel();

		final IssueResolutionProvider issueResolutionProvider = getService(editor, IssueResolutionProvider.class);
		final MarkerTypeProvider markerTypeProvider = getService(editor, MarkerTypeProvider.class);
		final MarkerCreator markerCreator = getService(editor, MarkerCreator.class);

		final IValidationIssueProcessor issueProcessor = new CompositeValidationIssueProcessor(
				new AnnotationIssueProcessor(document, annotationModel, issueResolutionProvider),
				new MarkerIssueProcessor(editor.getResource(), annotationModel, markerCreator, markerTypeProvider));

		return editor.getDocument().modify(resource -> {
			final IResourceServiceProvider serviceProvider = resource.getResourceServiceProvider();
			final IResourceValidator resourceValidator = serviceProvider.getResourceValidator();
			return new ValidationJob(resourceValidator, editor.getDocument(), issueProcessor, ALL);
		});
	}
 
Example #3
Source File: JSONUiExtensionRegistry.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Initializes the registry by querying the {@link IExtensionRegistry} for all
 * registered JSON validator extensions.
 */
private void initialize() {
	if (this.isInitialized) {
		LOGGER.warn("JSONUiExtensionRegistry has already been initialized.");
		return;
	}
	// make sure fields are set to non-null value
	this.quickfixProviderExtensions = new HashSet<>();
	this.proposalProviderExtensions = new HashSet<>();
	this.hyperlinkHelperExtensions = new HashSet<>();

	this.isInitialized = true;

	// query the extension registry for JSON quickfix extensions and register them
	createExecutableExtensions(JSON_QUICKFIXPROVIDER_EXTENSIONS_POINT_ID, IssueResolutionProvider.class)
			.forEach(this::register);
	// query the extension registry for JSON proposal extensions and register them
	createExecutableExtensions(JSON_PROPOSALPROVIDER_EXTENSIONS_POINT_ID, IJSONProposalProvider.class)
			.forEach(this::register);
	// query the extension registry for JSON hyperlink extensions and register them
	createExecutableExtensions(JSON_HYPERLINKHELPER_EXTENSIONS_POINT_ID, IJSONHyperlinkHelperExtension.class)
			.forEach(this::register);
}
 
Example #4
Source File: WorkbenchResolutionAdaptorRunTest.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void configure() {
  bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("com.avaloq.tools.dsl.TestLang"); //$NON-NLS-1$
  bind(IWorkbench.class).toInstance(mock(IWorkbench.class));
  bind(IResourceDescriptions.class).toInstance(mock(IResourceDescriptions.class));
  bind(IWorkspace.class).toInstance(mock(IWorkspace.class));

  bind(IModificationContextRegistry.class).toInstance(mock(IModificationContextRegistry.class));

  bind(WorkbenchMarkerResolutionGenerator.RegistryProvider.class).toInstance(mockRegistryProvider);
  bind(IStorage2UriMapper.class).toInstance(mockStorage2UriMapper);
  bind(ILanguageResourceHelper.class).toInstance(mockLanguageResourceHelper);
  bind(IssueResolutionProvider.class).toInstance(mockIssueResolutionProvider);

  bind(IResourceSetProvider.class).toInstance(mockResourceSetProvider);
  bind(IDirtyStateManager.class).toInstance(mockDirtyStateManager);
}
 
Example #5
Source File: ValidValidatorFragment.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Set<Binding> getGuiceBindingsUi(final Grammar grammar) {
  if (hasQuickfixes(getValidModel(grammar))) {
    final BindFactory addTypeToInstance = new BindFactory().addTypeToType(IssueResolutionProvider.class.getName(), getQuickfixProviderName(grammar, getNaming()));
    return addTypeToInstance.getBindings();
  } else {
    return Collections.emptySet();
  }
}
 
Example #6
Source File: AnnotationIssueProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public AnnotationIssueProcessor(IXtextDocument xtextDocument, IAnnotationModel annotationModel,
		IssueResolutionProvider issueResolutionProvider) {
	super();
	this.annotationModel = annotationModel;
	if(annotationModel == null) 
		throw new IllegalArgumentException("Annotation model cannot be null");
	annotationModel.addAnnotationModelListener(this);
	this.xtextDocument = xtextDocument;
	this.issueResolutionProvider = issueResolutionProvider;
}
 
Example #7
Source File: AbstractPureXbaseUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return PureXbaseQuickfixProvider.class;
}
 
Example #8
Source File: AbstractEcore2XtextTestUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return Ecore2XtextTestQuickfixProvider.class;
}
 
Example #9
Source File: AbstractDomainmodelUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return DomainmodelQuickfixProvider.class;
}
 
Example #10
Source File: AbstractStatemachineUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return StatemachineQuickfixProvider.class;
}
 
Example #11
Source File: AbstractRuleEngineUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return RuleEngineQuickfixProvider.class;
}
 
Example #12
Source File: AbstractArithmeticsUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return ArithmeticsQuickfixProvider.class;
}
 
Example #13
Source File: AbstractBuilderTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return BuilderTestLanguageQuickfixProvider.class;
}
 
Example #14
Source File: DefaultUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return DefaultQuickfixProvider.class;
}
 
Example #15
Source File: AbstractXbaseUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return XbaseQuickfixProvider.class;
}
 
Example #16
Source File: AbstractXbaseWithAnnotationsUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return XbaseWithAnnotationsQuickfixProvider.class;
}
 
Example #17
Source File: AbstractCodetemplatesUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return CodetemplatesQuickfixProvider.class;
}
 
Example #18
Source File: DotHtmlLabelQuickfixDelegator.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
private List<IssueResolution> getResolutions(Issue issue) {
	IssueResolutionProvider quickfixProvider = injector
			.getInstance(IssueResolutionProvider.class);
	return quickfixProvider.getResolutions(issue);
}
 
Example #19
Source File: AbstractXtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return XtendQuickfixProvider.class;
}
 
Example #20
Source File: AbstractHelloWorldUiModule.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return HelloWorldQuickfixProvider.class;
}
 
Example #21
Source File: AbstractQuickFixTest.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
private IssueResolutionProvider getIssueResolutionProvider() {
  return getXtextTestUtil().get(IssueResolutionProvider.class);
}
 
Example #22
Source File: StyledTextXtextAdapter.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected IssueResolutionProvider getResolutionProvider() {
	return this.resolutionProvider;
}
 
Example #23
Source File: AbstractGamlUiModule.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return GamlQuickfixProvider.class;
}
 
Example #24
Source File: AbstractSARLUiModule.java    From sarl with Apache License 2.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return SARLQuickfixProvider.class;
}
 
Example #25
Source File: AbstractMyDslUiModule.java    From M2Doc with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return MyDslQuickfixProvider.class;
}
 
Example #26
Source File: AbstractN4JSUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return N4JSQuickfixProvider.class;
}
 
Example #27
Source File: AbstractRegularExpressionUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return RegularExpressionQuickfixProvider.class;
}
 
Example #28
Source File: AbstractJSONUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IssueResolutionProvider> bindIssueResolutionProvider() {
	return JSONQuickfixProvider.class;
}
 
Example #29
Source File: JSONUiExtensionRegistry.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns a list of all {@link IJSONValidatorExtension}s that were registered
 * via the JSON quickfix extension point.
 */
public Collection<IssueResolutionProvider> getQuickfixProviderExtensions() {
	ensureInitialization(); // trigger lazy initialization, if required
	return this.quickfixProviderExtensions;
}
 
Example #30
Source File: JSONUiExtensionRegistry.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Registers the given {@code quickfixProviderExtension} with the
 * {@link JSONUiExtensionRegistry}.
 */
private void register(IssueResolutionProvider quickfixProviderExtension) {
	ensureInitialization(); // trigger lazy initialization, if required
	this.quickfixProviderExtensions.add(quickfixProviderExtension);
}