Skip to content

Commit

Permalink
Merge pull request #225 from LorenzoBettini/task_217-Outline_should_h…
Browse files Browse the repository at this point in the history
…ighlight_modified_elements

Task 217 outline should highlight modified elements
  • Loading branch information
LorenzoBettini authored Jul 22, 2020
2 parents 7902ff2 + 9951abf commit 630a2e0
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 129 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* generated by Xtext 2.22.0
*/
package edelta.ui.labeling;

import org.eclipse.xtext.xbase.ui.labeling.XbaseDescriptionLabelProvider;

/**
* Provides labels for IEObjectDescriptions and IResourceDescriptions.
*
* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#label-provider
*/
public class EdeltaDescriptionLabelProvider extends XbaseDescriptionLabelProvider {

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* generated by Xtext 2.10.0
*/
package edelta.ui.labeling;

import static com.google.common.collect.Iterables.filter;
import static org.eclipse.xtext.xbase.lib.IterableExtensions.head;

import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.xtext.common.types.JvmOperation;
import org.eclipse.xtext.xbase.annotations.ui.labeling.XbaseWithAnnotationsLabelProvider;
import org.eclipse.xtext.xbase.jvmmodel.IJvmModelAssociations;

import com.google.inject.Inject;

import edelta.edelta.EdeltaModifyEcoreOperation;
import edelta.edelta.EdeltaOperation;

/**
* Provides labels for EObjects.
*
* See
* https://www.eclipse.org/Xtext/documentation/304_ide_concepts.html#label-provider
*/
public class EdeltaLabelProvider extends XbaseWithAnnotationsLabelProvider {
@Inject
private IJvmModelAssociations jvmModelAssociations;

private AdapterFactoryLabelProvider delegate;

@Inject
public EdeltaLabelProvider(final AdapterFactoryLabelProvider delegate) {
super(delegate);
this.delegate = delegate;
}

public Object text(final EdeltaOperation m) {
return this.text(this.inferredJavaMethod(m));
}

public ImageDescriptor image(final EdeltaOperation m) {
return this.imageDescriptor(this.inferredJavaMethod(m));
}

public Object text(final EdeltaModifyEcoreOperation m) {
return this.text(this.inferredJavaMethod(m));
}

public ImageDescriptor image(final EdeltaModifyEcoreOperation m) {
return this.imageDescriptor(this.inferredJavaMethod(m));
}

public String text(final ENamedElement e) {
// delegate to the default Ecore edit label provider
// for Ecore model elements.
return delegate.getText(e);
}

private JvmOperation inferredJavaMethod(final EObject e) {
return head(filter(
jvmModelAssociations.getJvmElements(e), JvmOperation.class));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* generated by Xtext 2.10.0
*/
package edelta.ui.outline;

import org.eclipse.emf.ecore.EPackage;
import org.eclipse.xtext.ui.editor.outline.IOutlineNode;
import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider;

import com.google.inject.Inject;

import edelta.edelta.EdeltaModifyEcoreOperation;
import edelta.edelta.EdeltaOperation;
import edelta.edelta.EdeltaProgram;
import edelta.resource.derivedstate.EdeltaDerivedStateHelper;

/**
* Customization of the default outline structure.
*
* See https://www.eclipse.org/Xtext/documentation/304_ide_concepts.html#outline
*/
public class EdeltaOutlineTreeProvider extends DefaultOutlineTreeProvider {
@Inject
private EdeltaDerivedStateHelper derivedStateHelper;

protected void _createChildren(final IOutlineNode parentNode, final EdeltaProgram p) {
for (final EdeltaOperation o : p.getOperations()) {
this.createNode(parentNode, o);
}
for (final EdeltaModifyEcoreOperation o : p.getModifyEcoreOperations()) {
this.createNode(parentNode, o);
}
for (final EPackage copiedEPackage : this.derivedStateHelper.getCopiedEPackagesMap(p.eResource()).values()) {
// the cool thing is that we don't need to provide
// customization in the label provider for EPackage and EClass
// since Xtext defaults to the .edit plugin :)
this.createNode(parentNode, copiedEPackage);
}
}

public boolean _isLeaf(final EdeltaOperation m) {
return true;
}

public boolean _isLeaf(final EdeltaModifyEcoreOperation m) {
return true;
}
}

This file was deleted.

6 changes: 6 additions & 0 deletions edelta.parent/edelta/src/edelta/GenerateEdelta.mwe2
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ Workflow {
quickFixProvider = {
generateXtendStub = false
}
outline = {
generateXtendStub = false
}
labelProvider = {
generateXtendStub = false
}
}
}
}
12 changes: 11 additions & 1 deletion edelta.parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<!-- see http://sonarqube.15.x6.nabble.com/sonar-issue-ignore-multicriteria-td5021722.html
and http://stackoverflow.com/questions/21825469/configure-sonar-sonar-issue-ignore-multicriteria-through-maven
for the multicriteria property -->
<sonar.issue.ignore.multicriteria>e11,e6,e12,e13,e14</sonar.issue.ignore.multicriteria>
<sonar.issue.ignore.multicriteria>e11,e6,e12,e13,e14,e15,e16</sonar.issue.ignore.multicriteria>

<!-- AbstractEdelta has methods declaring to throw generic Exception
but we can't predict a dedicated exception -->
Expand All @@ -86,6 +86,16 @@
<sonar.issue.ignore.multicriteria.e14.ruleKey>java:S1128</sonar.issue.ignore.multicriteria.e14.ruleKey>
<sonar.issue.ignore.multicriteria.e14.resourceKey>**/edelta-lib-src-gen/**/*.java</sonar.issue.ignore.multicriteria.e14.resourceKey>

<!-- Method names should comply with a naming convention:
OutlineTreeProvider in Xtext is based on some redefined methods starting with _ -->
<sonar.issue.ignore.multicriteria.e15.ruleKey>java:S100</sonar.issue.ignore.multicriteria.e15.ruleKey>
<sonar.issue.ignore.multicriteria.e15.resourceKey>**/*OutlineTreeProvider.java</sonar.issue.ignore.multicriteria.e15.resourceKey>

<!-- Unused method parameters should be removed:
OutlineTreeProvider in Xtext is based on _isLeaf that typically ignores the parameter -->
<sonar.issue.ignore.multicriteria.e16.ruleKey>java:S1172</sonar.issue.ignore.multicriteria.e16.ruleKey>
<sonar.issue.ignore.multicriteria.e16.resourceKey>**/*OutlineTreeProvider.java</sonar.issue.ignore.multicriteria.e16.resourceKey>

<!-- since this could be used in the pluginManagement section, we need
to make sure the path always points to this pom's directory; project.basedir
will always point to the directory of the pom where the pluginManagement's
Expand Down

0 comments on commit 630a2e0

Please sign in to comment.