New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AADL Navigator: No error/warning decorations on expanded file content #1431

Closed
lwrage opened this Issue Aug 3, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@lwrage
Contributor

lwrage commented Aug 3, 2018

No description provided.

@AaronGreenhouse

This comment has been minimized.

AaronGreenhouse commented Sep 18, 2018

Problem is in org.osate.ui.navigator.AadlElementLabelProvider, I think.

@AaronGreenhouse AaronGreenhouse added in progress and removed next labels Sep 18, 2018

@AaronGreenhouse

This comment has been minimized.

AaronGreenhouse commented Sep 21, 2018

I found the solution in org.eclipse.ui.internal.navigator.resources.workbench.ResourceExtensionLabelProvider.

	protected ImageDescriptor decorateImage(ImageDescriptor input, Object element) {
		ImageDescriptor descriptor = super.decorateImage(input, element);
		if (descriptor == null) {
			return null;
		}
		IResource resource = Adapters.adapt(element, IResource.class);
		if (resource != null && (resource.getType() != IResource.PROJECT || ((IProject) resource).isOpen())) {
			ImageDescriptor overlay = null;
			switch (getHighestProblemSeverity(resource)) {
			case IMarker.SEVERITY_ERROR:
				overlay = PlatformUI.getWorkbench().getSharedImages()
						.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR);
				break;
			case IMarker.SEVERITY_WARNING:
				overlay = PlatformUI.getWorkbench().getSharedImages()
						.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING);
				break;
			}
			if (overlay != null) {
				descriptor = new DecorationOverlayIcon(descriptor, overlay, IDecoration.BOTTOM_LEFT);
			}
		}
		return descriptor;
	}


	private int getHighestProblemSeverity(IResource resource) {
		int problemSeverity = -1;
		try {
			for (IMarker marker : resource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)) {
				problemSeverity = Math.max(problemSeverity, marker.getAttribute(IMarker.SEVERITY, -1));
			}
		} catch (CoreException e) {
			// Mute error to prevent pop-up in case of concurrent modification
			// of markers.
		}
		return problemSeverity;
	}

This is called from getImage() in the super class WorkbenchLabelProvider:

    @Override
	public final Image getImage(Object element) {
        //obtain the base image by querying the element
        IWorkbenchAdapter adapter = getAdapter(element);
        if (adapter == null) {
            return null;
        }
        ImageDescriptor descriptor = adapter.getImageDescriptor(element);
        if (descriptor == null) {
            return null;
        }

        //add any annotations to the image descriptor
        descriptor = decorateImage(descriptor, element);

		return (Image) getResourceManager().get(descriptor);
    }

Need to smush this into our getImage() method.

@AaronGreenhouse

This comment has been minimized.

AaronGreenhouse commented Sep 24, 2018

So the above is directly applicable, but it gives the general idea.

Some issues I've noticed are that the AadlElements in the AadlElementLabelProvider are not annotated with position information. This may not be a problem because the markers generated by OSATE analsyes don't seem to have position information either. Instead they carry a URI. See MarkerAnalysisErrorReporter.

Not sure what the parser errors look like at the moment.

@AaronGreenhouse

This comment has been minimized.

AaronGreenhouse commented Sep 25, 2018

Okay, need to get the URI from the marker, which comes from one of two attributes:

  1. uri from OSATE analysis error reporters
  2. URI_KEY from Xtext validation errors

Can convert the URI to an EObject using ResourceSet.getEObject(). Can check if the marked object is a descendant of the selected object using EcoreUtil.isAncestor()

Can then get the max marker severity and add the decorator

@AaronGreenhouse

This comment has been minimized.

AaronGreenhouse commented Sep 25, 2018

Done. Not to complicated once you figure out where to get all the information from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment