diff --git a/com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF index c71d434ad..210056714 100644 --- a/com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF @@ -18,7 +18,6 @@ Require-Bundle: com.avaloq.tools.ddk.check.core, org.eclipse.ui.ide, org.eclipse.core.runtime, org.eclipse.xtend.lib, - org.eclipse.xtext.junit4, org.eclipse.xtext.ui.testing, org.eclipse.xtext.testing, org.junit, @@ -26,7 +25,6 @@ Require-Bundle: com.avaloq.tools.ddk.check.core, com.avaloq.tools.ddk.check.runtime.core, org.eclipse.ui.workbench;resolution:=optional, org.eclipse.xtext.xbase, - org.eclipse.xtext.xbase.junit, org.eclipse.xtext.xbase.lib, org.apache.logging.log4j, org.apache.commons.lang, diff --git a/com.avaloq.tools.ddk.check.runtime.core.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.check.runtime.core.test/META-INF/MANIFEST.MF index b555ac438..1f02ba972 100644 --- a/com.avaloq.tools.ddk.check.runtime.core.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.check.runtime.core.test/META-INF/MANIFEST.MF @@ -11,8 +11,7 @@ Require-Bundle: org.eclipse.ui, com.avaloq.tools.ddk.test.ui, com.avaloq.tools.ddk.check.runtime.core, org.junit, - com.google.guava, - org.eclipse.xtext.junit4 + com.google.guava Export-Package: com.avaloq.tools.ddk.check.runtime.test.core Import-Package: org.mockito, org.mockito.stubbing diff --git a/com.avaloq.tools.ddk.check.test.runtime.tests/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.check.test.runtime.tests/META-INF/MANIFEST.MF index 9d596d89a..907d99fd0 100644 --- a/com.avaloq.tools.ddk.check.test.runtime.tests/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.check.test.runtime.tests/META-INF/MANIFEST.MF @@ -12,7 +12,6 @@ Require-Bundle: com.avaloq.tools.ddk.check.runtime.core, org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.xtext, - org.eclipse.xtext.junit4, org.eclipse.xtext.testing, org.eclipse.xtext.ui.testing, org.junit, diff --git a/com.avaloq.tools.ddk.check.test.runtime/src-gen/com/avaloq/tools/ddk/check/validation/ExecutionEnvironmentCheckImpl.java b/com.avaloq.tools.ddk.check.test.runtime/src-gen/com/avaloq/tools/ddk/check/validation/ExecutionEnvironmentCheckImpl.java index ddbfd236f..5f8905b19 100644 --- a/com.avaloq.tools.ddk.check.test.runtime/src-gen/com/avaloq/tools/ddk/check/validation/ExecutionEnvironmentCheckImpl.java +++ b/com.avaloq.tools.ddk.check.test.runtime/src-gen/com/avaloq/tools/ddk/check/validation/ExecutionEnvironmentCheckImpl.java @@ -1,8 +1,7 @@ package com.avaloq.tools.ddk.check.validation; -import com.avaloq.tools.ddk.check.runtime.issue.AbstractDispatchingCheckImpl; +import com.avaloq.tools.ddk.check.runtime.issue.DispatchingCheckImpl; import com.avaloq.tools.ddk.check.testLanguage.Greeting; -import com.avaloq.tools.ddk.xtext.tracing.ResourceValidationRuleSummaryEvent; import com.google.common.collect.ImmutableMap; import com.google.inject.Inject; import org.eclipse.emf.ecore.EObject; @@ -15,7 +14,7 @@ * Validator for ExecutionEnvironment. */ @SuppressWarnings("all") -public class ExecutionEnvironmentCheckImpl extends AbstractDispatchingCheckImpl { +public class ExecutionEnvironmentCheckImpl extends DispatchingCheckImpl { @Inject private ExecutionEnvironmentCheckCatalog executionEnvironmentCatalog; @@ -28,19 +27,19 @@ public final ImmutableMap getIssueCodeToLabelMap() { } @Override - public void validate(final CheckMode checkMode, final EObject object, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector, final ResourceValidationRuleSummaryEvent.Collector eventCollector) { + public void validate(final CheckMode checkMode, final EObject object, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { if (checkMode.shouldCheck(CheckType.NORMAL)) { diagnosticCollector.setCurrentCheckType(CheckType.NORMAL); if (object instanceof final com.avaloq.tools.ddk.check.testLanguage.Greeting castObject) { validate("greetingNameLengthGreeting", "ExecutionEnvironment.greetingNameLengthGreeting", object, - () -> greetingNameLengthGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector); + () -> greetingNameLengthGreeting(castObject, diagnosticCollector), diagnosticCollector); } } } private class GreetingNameLengthClass { - public void runGreeting(final Greeting g, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { + public void runGreeting(final Greeting g, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { int _length = g.getName().length(); boolean _greaterThan = (_length > 5); if (_greaterThan) { @@ -78,7 +77,7 @@ public void runGreeting(final Greeting g, final AbstractDispatchingCheckImpl.Dia * greetingNameLengthGreeting. */ @Check(CheckType.NORMAL) - public void greetingNameLengthGreeting(final Greeting context, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { + public void greetingNameLengthGreeting(final Greeting context, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { greetingNameLengthImpl.runGreeting(context, diagnosticCollector); } } diff --git a/com.avaloq.tools.ddk.check.test.runtime/src-gen/com/avaloq/tools/ddk/check/validation/LibraryChecksCheckImpl.java b/com.avaloq.tools.ddk.check.test.runtime/src-gen/com/avaloq/tools/ddk/check/validation/LibraryChecksCheckImpl.java index bc6978961..16130ef29 100644 --- a/com.avaloq.tools.ddk.check.test.runtime/src-gen/com/avaloq/tools/ddk/check/validation/LibraryChecksCheckImpl.java +++ b/com.avaloq.tools.ddk.check.test.runtime/src-gen/com/avaloq/tools/ddk/check/validation/LibraryChecksCheckImpl.java @@ -1,9 +1,8 @@ package com.avaloq.tools.ddk.check.validation; import com.avaloq.tools.ddk.check.lib.IResourceCache; -import com.avaloq.tools.ddk.check.runtime.issue.AbstractDispatchingCheckImpl; +import com.avaloq.tools.ddk.check.runtime.issue.DispatchingCheckImpl; import com.avaloq.tools.ddk.check.testLanguage.Greeting; -import com.avaloq.tools.ddk.xtext.tracing.ResourceValidationRuleSummaryEvent; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.inject.Inject; @@ -21,7 +20,7 @@ * Validator for LibraryChecks. */ @SuppressWarnings("all") -public class LibraryChecksCheckImpl extends AbstractDispatchingCheckImpl { +public class LibraryChecksCheckImpl extends DispatchingCheckImpl { @Inject private LibraryChecksCheckCatalog libraryChecksCatalog; @@ -37,18 +36,18 @@ public final ImmutableMap getIssueCodeToLabelMap() { } @Override - public void validate(final CheckMode checkMode, final EObject object, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector, final ResourceValidationRuleSummaryEvent.Collector eventCollector) { + public void validate(final CheckMode checkMode, final EObject object, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { if (checkMode.shouldCheck(CheckType.FAST)) { diagnosticCollector.setCurrentCheckType(CheckType.FAST); if (object instanceof final com.avaloq.tools.ddk.check.testLanguage.Greeting castObject) { validate("checkCatalogIsActiveGreeting", "LibraryChecks.checkCatalogIsActiveGreeting", object, - () -> checkCatalogIsActiveGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector); + () -> checkCatalogIsActiveGreeting(castObject, diagnosticCollector), diagnosticCollector); validate("cacheInjectionFailedGreeting", "LibraryChecks.cacheInjectionFailedGreeting", object, - () -> cacheInjectionFailedGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector); + () -> cacheInjectionFailedGreeting(castObject, diagnosticCollector), diagnosticCollector); validate("cacheDoesntWorkGreeting", "LibraryChecks.cacheDoesntWorkGreeting", object, - () -> cacheDoesntWorkGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector); + () -> cacheDoesntWorkGreeting(castObject, diagnosticCollector), diagnosticCollector); validate("formalParametersGreeting", "LibraryChecks.formalParametersGreeting", object, - () -> formalParametersGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector); + () -> formalParametersGreeting(castObject, diagnosticCollector), diagnosticCollector); } } } @@ -57,7 +56,7 @@ public void validate(final CheckMode checkMode, final EObject object, final Abst * checkCatalogIsActiveGreeting. */ @Check(CheckType.FAST) - public void checkCatalogIsActiveGreeting(final Greeting it, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {// Issue diagnostic + public void checkCatalogIsActiveGreeting(final Greeting it, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {// Issue diagnostic libraryChecksCatalog.accept(diagnosticCollector, // it, // context EObject null, // EStructuralFeature @@ -72,7 +71,7 @@ public void checkCatalogIsActiveGreeting(final Greeting it, final AbstractDispat * cacheInjectionFailedGreeting. */ @Check(CheckType.FAST) - public void cacheInjectionFailedGreeting(final Greeting g, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { + public void cacheInjectionFailedGreeting(final Greeting g, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { if ((LibraryChecksCheckImpl.this.cache == null)) {// Issue diagnostic libraryChecksCatalog.accept(diagnosticCollector, // g, // context EObject @@ -89,7 +88,7 @@ public void cacheInjectionFailedGreeting(final Greeting g, final AbstractDispatc * cacheDoesntWorkGreeting. */ @Check(CheckType.FAST) - public void cacheDoesntWorkGreeting(final Greeting it, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { + public void cacheDoesntWorkGreeting(final Greeting it, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { String _qualifiedCatalogName = this.getQualifiedCatalogName(); final String key = (_qualifiedCatalogName + ".testValue"); try { @@ -132,7 +131,7 @@ private class FormalParametersClass { - public void runGreeting(final Greeting it, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { + public void runGreeting(final Greeting it, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { final String p1 = libraryChecksCatalog.getFormalParameters_Param1(it); final boolean p2 = false; final List expectedNames = ImmutableList.of("foo", "bar", "ba\u0001\nz"); @@ -255,7 +254,7 @@ public void runGreeting(final Greeting it, final AbstractDispatchingCheckImpl.Di * formalParametersGreeting. */ @Check(CheckType.FAST) - public void formalParametersGreeting(final Greeting context, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { + public void formalParametersGreeting(final Greeting context, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) { formalParametersImpl.runGreeting(context, diagnosticCollector); } } diff --git a/com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF index 82f9336cd..941186fd9 100644 --- a/com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF @@ -17,7 +17,6 @@ Require-Bundle: org.junit, org.eclipse.xtext.common.types.ui, org.eclipse.jdt.core, org.eclipse.ui.ide, - org.eclipse.xtext.junit4, org.eclipse.xtext.xbase.lib, org.eclipse.core.runtime, org.slf4j.ext, diff --git a/com.avaloq.tools.ddk.checkcfg.core.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.checkcfg.core.test/META-INF/MANIFEST.MF index 0fcb179f6..d28b4bf7b 100644 --- a/com.avaloq.tools.ddk.checkcfg.core.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.checkcfg.core.test/META-INF/MANIFEST.MF @@ -17,7 +17,6 @@ Require-Bundle: com.avaloq.tools.ddk.test.core, org.eclipse.ui.ide, org.eclipse.core.runtime, org.eclipse.xtend.lib, - org.eclipse.xtext.junit4, org.eclipse.xtext.ui.testing, org.junit, org.eclipse.xtext.xbase.lib, diff --git a/com.avaloq.tools.ddk.feature/feature.xml b/com.avaloq.tools.ddk.feature/feature.xml index 7496e429b..db34d8b01 100644 --- a/com.avaloq.tools.ddk.feature/feature.xml +++ b/com.avaloq.tools.ddk.feature/feature.xml @@ -209,11 +209,4 @@ version="0.0.0" unpack="false"/> - - diff --git a/com.avaloq.tools.ddk.sample.helloworld.ui.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.sample.helloworld.ui.test/META-INF/MANIFEST.MF index f62427ed9..7bbcf9c91 100644 --- a/com.avaloq.tools.ddk.sample.helloworld.ui.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.sample.helloworld.ui.test/META-INF/MANIFEST.MF @@ -9,14 +9,12 @@ Bundle-ActivationPolicy: lazy Require-Bundle: com.avaloq.tools.ddk.sample.helloworld, com.avaloq.tools.ddk.sample.helloworld.ui, org.junit, - org.eclipse.xtext.junit4, org.eclipse.xtext.ui.testing, org.eclipse.xtext.testing, org.eclipse.xtext.xbase.testing, org.eclipse.xtext.xbase.lib, org.eclipse.core.runtime, org.eclipse.ui.workbench;resolution:=optional, - org.eclipse.xtext.xbase.junit, com.avaloq.tools.ddk.check.runtime.core, com.avaloq.tools.ddk.check.runtime.ui, com.avaloq.tools.ddk.check.core.test, diff --git a/com.avaloq.tools.ddk.source.feature/feature.xml b/com.avaloq.tools.ddk.source.feature/feature.xml index 217f3faed..23745a086 100644 --- a/com.avaloq.tools.ddk.source.feature/feature.xml +++ b/com.avaloq.tools.ddk.source.feature/feature.xml @@ -159,11 +159,4 @@ version="0.0.0" unpack="false"/> - - diff --git a/com.avaloq.tools.ddk.xtext.format.ui.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtext.format.ui.test/META-INF/MANIFEST.MF index a1b78156b..1928d1c26 100644 --- a/com.avaloq.tools.ddk.xtext.format.ui.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.xtext.format.ui.test/META-INF/MANIFEST.MF @@ -8,7 +8,6 @@ Bundle-ActivationPolicy: lazy Export-Package: com.avaloq.tools.ddk.xtext.format.ui;x-internal=true Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui.workbench;resolution:=optional, - org.eclipse.xtext.junit4, org.eclipse.xtext.testing, org.eclipse.xtext.xbase.junit, org.eclipse.xtext.xbase.testing, diff --git a/com.avaloq.tools.ddk.xtext.generator.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtext.generator.test/META-INF/MANIFEST.MF index e0e1b598a..5cd26c156 100644 --- a/com.avaloq.tools.ddk.xtext.generator.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.xtext.generator.test/META-INF/MANIFEST.MF @@ -13,7 +13,6 @@ Require-Bundle: com.avaloq.tools.ddk.test.core, org.eclipse.xtend, org.eclipse.xtend.typesystem.emf, org.eclipse.xtext, - org.eclipse.xtext.junit4, org.junit, org.mockito, com.avaloq.tools.ddk.xtext.ui, diff --git a/com.avaloq.tools.ddk.xtext.test.core/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtext.test.core/META-INF/MANIFEST.MF index ab926b957..4e7783727 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.xtext.test.core/META-INF/MANIFEST.MF @@ -16,7 +16,6 @@ Require-Bundle: com.avaloq.tools.ddk.xtext, org.eclipse.pde.core, org.eclipse.ui.ide, org.eclipse.xtend.lib, - org.eclipse.xtext.junit4;visibility:=reexport, org.eclipse.xtext.testing;visibility:=reexport, org.eclipse.xtext.ui.testing;visibility:=reexport, org.eclipse.xtext.ui, diff --git a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidValidationTest.java b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidValidationTest.java index 9455d1b4b..315cd1a0c 100644 --- a/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidValidationTest.java +++ b/com.avaloq.tools.ddk.xtext.test.core/src/com/avaloq/tools/ddk/xtext/test/validation/AbstractValidValidationTest.java @@ -13,12 +13,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; -import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.ecore.EObject; -import org.eclipse.xtext.junit4.validation.AssertableDiagnostics; -import org.eclipse.xtext.junit4.validation.AssertableDiagnostics.DiagnosticPredicate; -import org.eclipse.xtext.junit4.validation.ValidatorTester; -import org.eclipse.xtext.validation.AbstractValidationDiagnostic; +import org.eclipse.xtext.testing.validation.AssertableDiagnostics.Pred; +import org.eclipse.xtext.testing.validation.ValidatorTester; import com.avaloq.tools.ddk.xtext.test.AbstractXtextTestUtil; import com.avaloq.tools.ddk.xtext.validation.AbstractDeclarativeValidValidator; @@ -29,48 +26,13 @@ /** * Base class for valid validation tests. */ -@SuppressWarnings({"deprecation", "removal"}) +@SuppressWarnings("nls") public abstract class AbstractValidValidationTest extends AbstractValidationTest { // -------------------------------------------------------------------------- // ValidAssertableDiagnostics // -------------------------------------------------------------------------- - /** - * This class can be removed once https://bugs.eclipse.org/bugs/show_bug.cgi?id=374743 is solved. - */ - protected static class ValidAssertableDiagnostics extends AssertableDiagnostics { - - public ValidAssertableDiagnostics(final Diagnostic diag) { - super(diag); - throw new UnsupportedOperationException(); - } - - /** - * Returns predicate matching any diagnostic with given issue code and message fragment. - * - * @param issueCode - * issue code to match - * @param messageFragment - * message fragment (substring) to match - * @return predicate - */ - public static Pred diagnostic(final String issueCode, final String messageFragment) { - return new Pred(null, null, issueCode, messageFragment); - } - - /** - * Returns predicate matching any diagnostic with given issue code. - * - * @param issueCode - * issue code to match - * @return predicate - */ - public static Pred diagnostic(final String issueCode) { - return new Pred(null, null, issueCode, null); - } - } - /** The tester. */ private ValidatorTester tester; @@ -106,7 +68,7 @@ protected ValidatorTester getTester() { */ protected void validate(final EObject element, final String... issueCodes) { for (String issueCode : issueCodes) { - getTester().validate(element).assertAny(ValidAssertableDiagnostics.diagnostic(issueCode)); + getTester().validate(element).assertAny(d -> new Pred(null, null, issueCode, null).apply(d)); } } @@ -122,21 +84,9 @@ protected void validate(final EObject element, final String... issueCodes) { */ protected void validateNot(final EObject element, final String... issueCodes) { for (String issueCode : issueCodes) { - assertNot(getTester().validate(element), ValidAssertableDiagnostics.diagnostic(issueCode)); - } - } - - /** - * Checks that there is no occurrence of a diagnostic predicate in a diagnostic list. - * - * @param validate - * the diagnostic list in which to look for a diagnostic predicate - * @param predicate - * the predicate diagnostic to look for - */ - private void assertNot(final AssertableDiagnostics validate, final DiagnosticPredicate predicate) { - if (Iterables.any(Iterables.filter(validate.getAllDiagnostics(), AbstractValidationDiagnostic.class), predicate)) { - fail("Predicate " + predicate.toString() + " found."); + if (!Iterables.isEmpty(Iterables.filter(getTester().validate(element).getAllDiagnostics(), d -> new Pred(null, null, issueCode, null).apply(d)))) { + fail("predicate found"); + } } } diff --git a/com.avaloq.tools.ddk.xtext.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtext.test/META-INF/MANIFEST.MF index a4d084462..ce22df10e 100644 --- a/com.avaloq.tools.ddk.xtext.test/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.xtext.test/META-INF/MANIFEST.MF @@ -13,7 +13,6 @@ Require-Bundle: com.avaloq.tools.ddk.xtext, org.eclipse.emf.mwe2.launch;resolution:=optional, org.eclipse.xtext, org.eclipse.xtext.xtext.generator, - org.eclipse.xtext.junit4, org.eclipse.xtext.util, org.eclipse.xtext.ui, com.avaloq.tools.ddk.xtext.ui, @@ -27,7 +26,6 @@ Require-Bundle: com.avaloq.tools.ddk.xtext, com.avaloq.tools.ddk.test.core, org.eclipse.pde.core, org.eclipse.xtext.xbase.lib, - org.eclipse.xtext.junit4, org.eclipse.emf.ecore, org.slf4j.ext Import-Package: org.apache.log4j, @@ -43,7 +41,6 @@ Import-Package: org.apache.log4j, com.avaloq.tools.ddk.xtext.test.export, com.avaloq.tools.ddk.xtext.test.format, com.avaloq.tools.ddk.xtext.ui.test, - com.avaloq.tools.ddk.xtextspy.test, com.avaloq.tools.ddk.sample.helloworld.test Export-Package: com.avaloq.tools.ddk.xtext, com.avaloq.tools.ddk.xtext.formatter, diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/AllTests.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/AllTests.java index 9e08dbc05..1522846c0 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/AllTests.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/AllTests.java @@ -28,7 +28,6 @@ import com.avaloq.tools.ddk.xtext.test.export.ExportTestSuite; import com.avaloq.tools.ddk.xtext.test.format.FormatTestSuite; import com.avaloq.tools.ddk.xtext.ui.test.XtextUiTestSuite; -import com.avaloq.tools.ddk.xtextspy.test.XtextSpyTestSuite; /** @@ -52,7 +51,6 @@ CheckUiTestSuite.class, CheckCfgUiTestSuite.class, CheckCfgTestSuite.class, - XtextSpyTestSuite.class, TypeSystemTestSuite.class }) // @Format-On diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/builder/XtextBuildTriggerTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/builder/XtextBuildTriggerTest.java index e4d27504b..21f8b1f11 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/builder/XtextBuildTriggerTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/builder/XtextBuildTriggerTest.java @@ -24,7 +24,7 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.xtext.builder.impl.BuildScheduler; import org.eclipse.xtext.builder.impl.IBuildFlag; -import org.eclipse.xtext.junit4.AbstractXtextTests; +import org.eclipse.xtext.testing.AbstractXtextTests; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; diff --git a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/AbstractSelectorFragmentProviderTest.java b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/AbstractSelectorFragmentProviderTest.java index a46370977..1ac4353de 100644 --- a/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/AbstractSelectorFragmentProviderTest.java +++ b/com.avaloq.tools.ddk.xtext.test/src/com/avaloq/tools/ddk/xtext/resource/AbstractSelectorFragmentProviderTest.java @@ -21,7 +21,7 @@ import org.eclipse.xtext.Keyword; import org.eclipse.xtext.XtextPackage; import org.eclipse.xtext.XtextRuntimeModule; -import org.eclipse.xtext.junit4.AbstractXtextTests; +import org.eclipse.xtext.testing.AbstractXtextTests; import org.eclipse.xtext.resource.IFragmentProvider; import org.eclipse.xtext.util.Modules2; import org.junit.Before; diff --git a/com.avaloq.tools.ddk.xtextspy.test/.classpath b/com.avaloq.tools.ddk.xtextspy.test/.classpath deleted file mode 100644 index b0bfa5067..000000000 --- a/com.avaloq.tools.ddk.xtextspy.test/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/com.avaloq.tools.ddk.xtextspy.test/.project b/com.avaloq.tools.ddk.xtextspy.test/.project deleted file mode 100644 index dd12ec8c1..000000000 --- a/com.avaloq.tools.ddk.xtextspy.test/.project +++ /dev/null @@ -1,99 +0,0 @@ - - - com.avaloq.tools.ddk.xtextspy.test - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.xtext.ui.shared.xtextBuilder - - - - - net.sf.eclipsecs.core.CheckstyleBuilder - - - - - net.sourceforge.pmd.eclipse.plugin.pmdBuilder - - - - - edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - org.eclipse.xtext.ui.shared.xtextNature - net.sourceforge.pmd.eclipse.plugin.pmdNature - net.sf.eclipsecs.core.CheckstyleNature - edu.umd.cs.findbugs.plugin.eclipse.findbugsNature - - - - .checkstyle - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.checkstyle - - - .fbprefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.fbprefs - - - .pmd - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.pmd - - - .settings/edu.umd.cs.findbugs.plugin.eclipse.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/edu.umd.cs.findbugs.plugin.eclipse.prefs - - - .settings/org.eclipse.core.resources.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.core.resources.prefs - - - .settings/org.eclipse.core.runtime.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.core.runtime.prefs - - - .settings/org.eclipse.jdt.core.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.jdt.core.prefs - - - .settings/org.eclipse.jdt.ui.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.jdt.ui.prefs - - - .settings/org.eclipse.pde.core.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.pde.core.prefs - - - diff --git a/com.avaloq.tools.ddk.xtextspy.test/.settings/.gitignore b/com.avaloq.tools.ddk.xtextspy.test/.settings/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/com.avaloq.tools.ddk.xtextspy.test/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtextspy.test/META-INF/MANIFEST.MF deleted file mode 100644 index 6a97886e5..000000000 --- a/com.avaloq.tools.ddk.xtextspy.test/META-INF/MANIFEST.MF +++ /dev/null @@ -1,20 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: com.avaloq.tools.ddk.xtextspy.test -Bundle-SymbolicName: com.avaloq.tools.ddk.xtextspy.test;singleton:=true -Bundle-Version: 14.1.0.qualifier -Bundle-Vendor: Avaloq Group AG -Bundle-RequiredExecutionEnvironment: JavaSE-17 -Bundle-ActivationPolicy: lazy -Fragment-Host: com.avaloq.tools.ddk.xtextspy -Require-Bundle: org.eclipse.core.resources, - org.eclipse.xtext, - org.eclipse.xtext.junit4, - org.eclipse.xtext.util, - org.eclipse.emf.ecore, - org.eclipse.emf.common, - org.junit, - org.mockito -Import-Package: org.apache.log4j -Export-Package: com.avaloq.tools.ddk.xtextspy.test -Automatic-Module-Name: com.avaloq.tools.ddk.xtextspy.test diff --git a/com.avaloq.tools.ddk.xtextspy.test/build.properties b/com.avaloq.tools.ddk.xtextspy.test/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/com.avaloq.tools.ddk.xtextspy.test/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/com.avaloq.tools.ddk.xtextspy.test/pom.xml b/com.avaloq.tools.ddk.xtextspy.test/pom.xml deleted file mode 100644 index 9379c1607..000000000 --- a/com.avaloq.tools.ddk.xtextspy.test/pom.xml +++ /dev/null @@ -1,13 +0,0 @@ - - 4.0.0 - - ddk-parent - com.avaloq.tools.ddk - 14.1.0-SNAPSHOT - ../ddk-parent - - - com.avaloq.tools.ddk.xtextspy.test - eclipse-test-plugin - - \ No newline at end of file diff --git a/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/EClassTypeContentProviderTest.java b/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/EClassTypeContentProviderTest.java deleted file mode 100644 index a66842f20..000000000 --- a/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/EClassTypeContentProviderTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy.test; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.xtext.junit4.AbstractXtextTests; -import org.junit.Before; -import org.junit.Test; - -import com.avaloq.tools.ddk.xtextspy.EClassNode; -import com.avaloq.tools.ddk.xtextspy.EClassTypeContentProvider; -import com.avaloq.tools.ddk.xtextspy.XtextSpyModule; -import com.avaloq.tools.ddk.xtextspy.internal.Activator; -import com.google.common.collect.Lists; - - -/** - * Testing EClassTypeContentProvider. - */ -@SuppressWarnings({"deprecation", "removal"}) -public class EClassTypeContentProviderTest extends AbstractXtextTests { - - private static final String NO_CHILDREN_EXPECTED = "No children expected"; - - private EClassTypeContentProvider contentProvider; - - @Before - @Override - public void setUp() throws Exception { - super.setUp(); - with(new XtextSpyModule(Activator.getDefault())); - contentProvider = get(EClassTypeContentProvider.class); - } - - /** - * Verify that hasChildren() delegates to {@link EClassNode}. - */ - @Test - public void hasChildren() { - assertFalse(NO_CHILDREN_EXPECTED, contentProvider.hasChildren(null)); - assertFalse(NO_CHILDREN_EXPECTED, contentProvider.hasChildren(new Object())); - EClassNode mockNode = mock(EClassNode.class); - contentProvider.hasChildren(mockNode); - verify(mockNode).hasChildren(); - } - - /** - * Verify that getChildren() delegates to {@link EClassNode}. - */ - @Test - public void getChildren() { - assertEquals(NO_CHILDREN_EXPECTED, 0, contentProvider.getChildren(null).length); - assertEquals(NO_CHILDREN_EXPECTED, 0, contentProvider.getChildren(new Object()).length); - EClassNode mockNode = mock(EClassNode.class); - when(mockNode.getChildren()).thenReturn(Lists. newArrayList()); - contentProvider.getChildren(mockNode); - verify(mockNode).getChildren(); - } - - /** - * Verify that getParent() delegates to {@link EClassNode}. - */ - @Test - public void getParent() { - assertNull("No parent expected for null", contentProvider.getParent(null)); - assertNull("No parent expected for Object", contentProvider.getParent(new Object())); - EClassNode mockNode = mock(EClassNode.class); - contentProvider.getParent(mockNode); - verify(mockNode).getParent(); - } - - /** - * Verify that getElements() instantiates {@link EClassNode}. - */ - @Test - public void getElements() { - assertEquals("Empty list expected for null", 0, contentProvider.getElements(null).length); - assertEquals("Empty list expected for Object", 0, contentProvider.getElements(new Object()).length); - - EClass mockEClass = mock(EClass.class); - Object[] elements = contentProvider.getElements(mockEClass); - assertEquals("Elements expected for EClass", 1, elements.length); - assertEquals("EClassNode expected for EClass", mockEClass, ((EClassNode) elements[0]).getEClass()); - - EObject mockEObject = mock(EObject.class); - when(mockEObject.eClass()).thenReturn(mockEClass); - elements = contentProvider.getElements(mockEObject); - assertEquals("Elements expected for EObject", 1, elements.length); - assertEquals("EClassNode expected for EObject", mockEClass, ((EClassNode) elements[0]).getEClass()); - } - -} diff --git a/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/EObjectContentProviderTest.java b/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/EObjectContentProviderTest.java deleted file mode 100644 index 6a382ecbd..000000000 --- a/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/EObjectContentProviderTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy.test; - -import static com.google.common.collect.Lists.newArrayList; -import static com.google.inject.util.Modules.override; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; - -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.xtext.junit4.AbstractXtextTests; -import org.eclipse.xtext.ui.editor.XtextEditor; -import org.eclipse.xtext.ui.editor.model.IXtextDocument; -import org.eclipse.xtext.util.concurrent.IUnitOfWork; -import org.junit.Before; -import org.junit.Test; - -import com.avaloq.tools.ddk.xtextspy.EObjectContentProvider; -import com.avaloq.tools.ddk.xtextspy.EObjectContentProvider.AttributeValuePair; -import com.avaloq.tools.ddk.xtextspy.XtextElementSelectionListener; -import com.avaloq.tools.ddk.xtextspy.XtextSpyModule; -import com.avaloq.tools.ddk.xtextspy.internal.Activator; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; -import com.google.inject.AbstractModule; - - -/** - * Testing EObjectContentProvider. - */ -@SuppressWarnings({"deprecation", "removal"}) -public class EObjectContentProviderTest extends AbstractXtextTests { - - /** - * Module binding XtextElementSelectionListener to a specific instance. - */ - public static class TestModule extends AbstractModule { - private final XtextElementSelectionListener selectionListener; - - public TestModule(final XtextElementSelectionListener selectionListener) { - this.selectionListener = selectionListener; - } - - @Override - protected void configure() { - bind(XtextElementSelectionListener.class).toInstance(selectionListener); - } - } - - @SuppressWarnings("PMD.SingularField") - private XtextElementSelectionListener mockSelectionListener; - private EObjectContentProvider contentProvider; - - @Before - @Override - public void setUp() throws Exception { - super.setUp(); - mockSelectionListener = mock(XtextElementSelectionListener.class); - with(override(new XtextSpyModule(Activator.getDefault())).with(new TestModule(mockSelectionListener))); - contentProvider = get(EObjectContentProvider.class); - } - - @Test - public void hasChildren() { - assertFalse("No children expected", contentProvider.hasChildren(new Object())); - } - - @Test - public void getParent() { - assertNull("No parent expected", contentProvider.getParent(new Object())); - } - - /** - * Mocks XtextEditor and XtextElementSelectionListener to return an element selection that has: - * - given EAttribute with a specific value (AttributeValuePair) - * - given EStructuralFeature - * - given EOperation. - * - * @param attributeValuePair - * EAttribute with a specific value - * @param feature - * the EStructuralFeature - * @param operation - * the EOperation - * @return the EClass of the "selected" element - */ - @SuppressWarnings("unchecked") - private EClass mockSelectedElement(final AttributeValuePair attributeValuePair, final EStructuralFeature feature, final EOperation operation) { - EClass mockSelectionEClass = mock(EClass.class); - when(mockSelectionListener.getSelectedElementType()).thenReturn(mockSelectionEClass); - // Mockups for returning AttributeValuePair - URI elementUri = URI.createURI(""); - when(mockSelectionListener.getSelectedElementUri()).thenReturn(elementUri); - XtextEditor mockEditor = mock(XtextEditor.class); - when(mockSelectionListener.getEditor()).thenReturn(mockEditor); - IXtextDocument mockDocument = mock(IXtextDocument.class); - when(mockEditor.getDocument()).thenReturn(mockDocument); - when(mockDocument.> readOnly(any(IUnitOfWork.class))).thenReturn(newArrayList(attributeValuePair)); // NOPMD LooseCoupling - // Mockups for returning EOperation - EList mockEOperationsList = new BasicEList(); - mockEOperationsList.add(operation); - when(mockSelectionEClass.getEAllOperations()).thenReturn(mockEOperationsList); - // Mockups for returning EStructuralFeature - EList mockEStructuralFeatureList = new BasicEList(); - mockEStructuralFeatureList.add(feature); - mockEStructuralFeatureList.add(attributeValuePair.getAttribute()); - when(mockSelectionEClass.getEAllStructuralFeatures()).thenReturn(mockEStructuralFeatureList); - return mockSelectionEClass; - } - - /** - * Verify that getElements()/getChildren() returns EAttributes, EStructuralFeatures and EOperations for - * a selected element. - */ - @Test - public void getElementsAndChildren() { - EClass mockInput = mock(EClass.class); - EOperation mockOperation = mock(EOperation.class); - EStructuralFeature mockFeature = mock(EStructuralFeature.class); - EAttribute mockAttribute = mock(EAttribute.class); - Object attributeValue = new Object(); - AttributeValuePair attributeValuePair = new AttributeValuePair(mockAttribute, attributeValue); - EClass mockSelectionEClass = mockSelectedElement(attributeValuePair, mockFeature, mockOperation); - Object[] elements; - - elements = contentProvider.getElements(null); - assertEquals("No elements expected", 0, elements.length); - - when(mockInput.isSuperTypeOf(eq(mockSelectionEClass))).thenReturn(false); - elements = contentProvider.getElements(mockInput); - assertEquals("No elements expected for incompatible EClass", 0, elements.length); - - when(mockInput.isSuperTypeOf(eq(mockSelectionEClass))).thenReturn(true); - elements = contentProvider.getElements(mockInput); - assertEquals("Expected elements for compatible EClass", 3, elements.length); - assertSame("Content provider did not include expected attribute", attributeValuePair, Iterables.find(newArrayList(elements), Predicates.instanceOf(AttributeValuePair.class))); - assertSame("Content provider did not include expected feature", mockFeature, Iterables.find(newArrayList(elements), Predicates.instanceOf(EStructuralFeature.class))); - assertSame("Content provider did not include expected operation", mockOperation, Iterables.find(newArrayList(elements), Predicates.instanceOf(EOperation.class))); - } -} diff --git a/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/XtextElementSelectionListenerTest.java b/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/XtextElementSelectionListenerTest.java deleted file mode 100644 index bc4b04227..000000000 --- a/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/XtextElementSelectionListenerTest.java +++ /dev/null @@ -1,236 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy.test; - -import static com.google.inject.util.Modules.override; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.xtext.AbstractRule; -import org.eclipse.xtext.junit4.AbstractXtextTests; -import org.eclipse.xtext.nodemodel.ILeafNode; -import org.eclipse.xtext.nodemodel.util.NodeModelUtils; -import org.eclipse.xtext.ui.editor.XtextEditor; -import org.eclipse.xtext.ui.editor.model.IXtextDocument; -import org.eclipse.xtext.util.concurrent.IUnitOfWork; -import org.junit.Before; -import org.junit.Test; - -import com.avaloq.tools.ddk.xtextspy.IEditorUtils; -import com.avaloq.tools.ddk.xtextspy.XtextElementSelectionListener; -import com.avaloq.tools.ddk.xtextspy.XtextSpyModule; -import com.avaloq.tools.ddk.xtextspy.internal.Activator; -import com.google.inject.AbstractModule; - - -/** - * Testing of XtextElementSelectionListener. - */ -@SuppressWarnings({"deprecation", "removal"}) -public class XtextElementSelectionListenerTest extends AbstractXtextTests { - - /** - * Module binding IEditorUtils to a specific instance. - */ - public static class TestModule extends AbstractModule { - private final IEditorUtils editorUtils; - - public TestModule(final IEditorUtils editorUtils) { - this.editorUtils = editorUtils; - } - - @Override - protected void configure() { - bind(IEditorUtils.class).toInstance(editorUtils); - } - } - - private IEditorUtils mockEditorUtils; - private XtextElementSelectionListener selectionListener; - - @Before - @Override - public void setUp() throws Exception { - super.setUp(); - mockEditorUtils = mock(IEditorUtils.class); - with(override(new XtextSpyModule(Activator.getDefault())).with(new TestModule(mockEditorUtils))); - selectionListener = get(XtextElementSelectionListener.class); - } - - /** - * Mocks an XtextEditor and instruments mockEditorUtils to return that. - * - * @return the mocked active XtextEditor - */ - private XtextEditor mockActiveEditor() { - XtextEditor mockEditor = mock(XtextEditor.class); - when(mockEditorUtils.getActiveXtextEditor()).thenReturn(mockEditor); - return mockEditor; - } - - /** - * Mocks a text selection and causes the (mocked) XtextEditor to return an ILeafNode on any read(IUnitOfWork). - * - * @return the mocked ILeafNode - */ - @SuppressWarnings("unchecked") - private ILeafNode mockNodeAtSelection(final XtextEditor mockEditor) { - IXtextDocument mockDocument = mock(IXtextDocument.class); - ILeafNode mockNode = mock(ILeafNode.class); - when(mockEditor.getDocument()).thenReturn(mockDocument); - when(mockDocument. priorityReadOnly(any(IUnitOfWork.class))).thenReturn(mockNode); - when(mockDocument. readOnly(any(IUnitOfWork.class))).thenReturn(mockNode); - // when(mockDocument.readOnly(any(IUnitOfWork.class))).thenReturn(mockLeafNode); - selectionListener.selectionChanged(null, mock(ITextSelection.class)); - return mockNode; - } - - /** - * Setting selection is not supported. - */ - @Test(expected = UnsupportedOperationException.class) - public void setSelection() { - selectionListener.setSelection(new TextSelection(0, 0)); - } - - /** - * Verify that selection is updated. - */ - @Test - public void getSelection() { - ISelection mockSelection = mock(TextSelection.class); - assertTrue("Expected empty selection", selectionListener.getSelection().isEmpty()); - selectionListener.selectionChanged(null, mockSelection); - assertSame("Expected selection", mockSelection, selectionListener.getSelection()); - } - - /** - * Verify that SelectionChangedListener are notified. - */ - @Test - public void fireSelectionChanged() { - ISelectionChangedListener mockListener = mock(ISelectionChangedListener.class); - selectionListener.addSelectionChangedListener(mockListener); - ISelection mockSelection = mock(TextSelection.class); - selectionListener.selectionChanged(null, mockSelection); - verify(mockListener).selectionChanged(any(SelectionChangedEvent.class)); - } - - /** - * Verify that getRule() returns null when no text selection exists in an editor. - */ - @Test - public void getNoRule() { - assertNull("No rule expected for no selection", selectionListener.getRule()); - ISelection mockSelection = mock(TextSelection.class); - selectionListener.selectionChanged(null, mockSelection); - assertNull("No rule expected for no editor", selectionListener.getRule()); - mockActiveEditor(); - mockSelection = mock(ISelection.class); - selectionListener.selectionChanged(null, mockSelection); - assertNull("No rule expected for non text selection", selectionListener.getRule()); - } - - /** - * Verify that AbstractRule is returned on getRule() if TextSelection and XtextEditor are given. - */ - @Test - public void getRule() { - ILeafNode mockNode = mockNodeAtSelection(mockActiveEditor()); - AbstractRule mockRule = mock(AbstractRule.class); - when(mockNode.getGrammarElement()).thenReturn(mockRule); - selectionListener.selectionChanged(null, mock(TextSelection.class)); - assertSame("Expected mocked AbstractRule", mockRule, selectionListener.getRule()); - } - - /** - * Verify that editor is updated on selection changes. - */ - @Test - public void getEditor() { - assertNull("No editor expected", selectionListener.getEditor()); - XtextEditor mockEditor = mockActiveEditor(); - selectionListener.selectionChanged(null, null); - assertSame("Expected same editor", mockEditor, selectionListener.getEditor()); - mockActiveEditor(); - selectionListener.selectionChanged(null, null); - assertNotSame("Did not expect same editor", mockEditor, selectionListener.getEditor()); - } - - /** - * Verify that selected node's grammar element is returned. - */ - @Test - public void getNodeGrammarElement() { - assertNull("No selection, thus no GE expected", selectionListener.getNodeGrammarElement()); - ILeafNode mockNode = mockNodeAtSelection(mockActiveEditor()); - selectionListener.getNodeGrammarElement(); - verify(mockNode).getGrammarElement(); - } - - /** - * Verify that an EClass can be determined for a text selection. - */ - @Test - public void getSelectedElementTypeForTextSelection() { - ILeafNode mockNode = mockNodeAtSelection(mockActiveEditor()); - when(mockNode.hasDirectSemanticElement()).thenReturn(true); - EObject mockEObject = mock(EObject.class); - when(mockNode.utils()).thenReturn(NodeModelUtils.Implementation.Default.INSTANCE); // fixes NPE - when(mockNode.getSemanticElement()).thenReturn(mockEObject); - selectionListener.getSelectedElementType(); - verify(mockEObject).eClass(); - } - - /** - * Verify that an EClass can be determined for a structured selection, provided selected EObject has a Resource. - */ - @Test - public void getSelectedElementTypeForStructuredSelection() { - IStructuredSelection mockSelection = mock(IStructuredSelection.class); - EObject mockEObject = mock(EObject.class); - when(mockSelection.getFirstElement()).thenReturn(mockEObject); - selectionListener.selectionChanged(null, mockSelection); - assertNull("Null expected as selected object has no eResource", selectionListener.getSelectedElementType()); - verify(mockEObject).eResource(); - Resource mockResource = mock(Resource.class); - when(mockEObject.eResource()).thenReturn(mockResource); - selectionListener.getSelectedElementType(); - verify(mockEObject).eClass(); - } - - /** - * Verify that an URI can be determined for a text selection. - */ - @Test - public void getSelectedElementUriForTextSelection() { - ILeafNode mockNode = mockNodeAtSelection(mockActiveEditor()); - when(mockNode.hasDirectSemanticElement()).thenReturn(true); - InternalEObject mockEObject = mock(InternalEObject.class); - when(mockNode.getSemanticElement()).thenReturn(mockEObject); - when(mockNode.utils()).thenReturn(NodeModelUtils.Implementation.Default.INSTANCE); // fixes NPE - when(mockEObject.eProxyURI()).thenReturn(URI.createURI("")); // this prevents NPE in EcoreUtil - selectionListener.getSelectedElementUri(); - verify(mockEObject).eProxyURI(); - } -} diff --git a/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/XtextSpyTestSuite.java b/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/XtextSpyTestSuite.java deleted file mode 100644 index e281fb89b..000000000 --- a/com.avaloq.tools.ddk.xtextspy.test/src/com/avaloq/tools/ddk/xtextspy/test/XtextSpyTestSuite.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy.test; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - - -/** - * Empty class serving only as holder for JUnit4 annotations. - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({XtextElementSelectionListenerTest.class, EClassTypeContentProviderTest.class, EObjectContentProviderTest.class}) -public class XtextSpyTestSuite { -} diff --git a/com.avaloq.tools.ddk.xtextspy/.classpath b/com.avaloq.tools.ddk.xtextspy/.classpath deleted file mode 100644 index b6ada0807..000000000 --- a/com.avaloq.tools.ddk.xtextspy/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/com.avaloq.tools.ddk.xtextspy/.project b/com.avaloq.tools.ddk.xtextspy/.project deleted file mode 100644 index ebfeb774c..000000000 --- a/com.avaloq.tools.ddk.xtextspy/.project +++ /dev/null @@ -1,99 +0,0 @@ - - - com.avaloq.tools.ddk.xtextspy - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.xtext.ui.shared.xtextBuilder - - - - - net.sf.eclipsecs.core.CheckstyleBuilder - - - - - net.sourceforge.pmd.eclipse.plugin.pmdBuilder - - - - - edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - org.eclipse.xtext.ui.shared.xtextNature - net.sourceforge.pmd.eclipse.plugin.pmdNature - net.sf.eclipsecs.core.CheckstyleNature - edu.umd.cs.findbugs.plugin.eclipse.findbugsNature - - - - .checkstyle - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.checkstyle - - - .fbprefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.fbprefs - - - .pmd - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.pmd - - - .settings/edu.umd.cs.findbugs.plugin.eclipse.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/edu.umd.cs.findbugs.plugin.eclipse.prefs - - - .settings/org.eclipse.core.resources.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.core.resources.prefs - - - .settings/org.eclipse.core.runtime.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.core.runtime.prefs - - - .settings/org.eclipse.jdt.core.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.jdt.core.prefs - - - .settings/org.eclipse.jdt.ui.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.jdt.ui.prefs - - - .settings/org.eclipse.pde.core.prefs - 1 - PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.pde.core.prefs - - - diff --git a/com.avaloq.tools.ddk.xtextspy/.settings/.gitignore b/com.avaloq.tools.ddk.xtextspy/.settings/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/com.avaloq.tools.ddk.xtextspy/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtextspy/META-INF/MANIFEST.MF deleted file mode 100644 index 17e6dc2e1..000000000 --- a/com.avaloq.tools.ddk.xtextspy/META-INF/MANIFEST.MF +++ /dev/null @@ -1,21 +0,0 @@ -Manifest-Version: 1.0 -Eclipse-ExtensibleAPI: true -Bundle-ManifestVersion: 2 -Bundle-Name: com.avaloq.tools.ddk.xtextspy -Bundle-SymbolicName: com.avaloq.tools.ddk.xtextspy; singleton:=true -Bundle-Version: 14.1.0.qualifier -Bundle-Activator: com.avaloq.tools.ddk.xtextspy.internal.Activator -Bundle-Vendor: Avaloq Group AG -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.xtext, - org.eclipse.jdt.core, - org.eclipse.core.resources, - org.eclipse.jface.text, - org.eclipse.xtext.ui, - org.eclipse.jdt.ui, - org.eclipse.ui.ide -Bundle-RequiredExecutionEnvironment: JavaSE-17 -Bundle-ActivationPolicy: lazy -Export-Package: com.avaloq.tools.ddk.xtextspy -Automatic-Module-Name: com.avaloq.tools.ddk.xtextspy diff --git a/com.avaloq.tools.ddk.xtextspy/build.properties b/com.avaloq.tools.ddk.xtextspy/build.properties deleted file mode 100644 index 4b8162ab8..000000000 --- a/com.avaloq.tools.ddk.xtextspy/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = plugin.xml,\ - META-INF/,\ - .,\ - icons/ diff --git a/com.avaloq.tools.ddk.xtextspy/icons/EAttribute.gif b/com.avaloq.tools.ddk.xtextspy/icons/EAttribute.gif deleted file mode 100644 index bc9944a7d..000000000 Binary files a/com.avaloq.tools.ddk.xtextspy/icons/EAttribute.gif and /dev/null differ diff --git a/com.avaloq.tools.ddk.xtextspy/icons/EClass.gif b/com.avaloq.tools.ddk.xtextspy/icons/EClass.gif deleted file mode 100644 index 2b8da630d..000000000 Binary files a/com.avaloq.tools.ddk.xtextspy/icons/EClass.gif and /dev/null differ diff --git a/com.avaloq.tools.ddk.xtextspy/icons/EEnum.gif b/com.avaloq.tools.ddk.xtextspy/icons/EEnum.gif deleted file mode 100644 index 343d08634..000000000 Binary files a/com.avaloq.tools.ddk.xtextspy/icons/EEnum.gif and /dev/null differ diff --git a/com.avaloq.tools.ddk.xtextspy/icons/EEnumLiteral.gif b/com.avaloq.tools.ddk.xtextspy/icons/EEnumLiteral.gif deleted file mode 100644 index 7bb44f59c..000000000 Binary files a/com.avaloq.tools.ddk.xtextspy/icons/EEnumLiteral.gif and /dev/null differ diff --git a/com.avaloq.tools.ddk.xtextspy/icons/EOccurrenceZeroToUnbounded.gif b/com.avaloq.tools.ddk.xtextspy/icons/EOccurrenceZeroToUnbounded.gif deleted file mode 100644 index 533dad7a6..000000000 Binary files a/com.avaloq.tools.ddk.xtextspy/icons/EOccurrenceZeroToUnbounded.gif and /dev/null differ diff --git a/com.avaloq.tools.ddk.xtextspy/icons/EOperation.gif b/com.avaloq.tools.ddk.xtextspy/icons/EOperation.gif deleted file mode 100644 index 60824bba1..000000000 Binary files a/com.avaloq.tools.ddk.xtextspy/icons/EOperation.gif and /dev/null differ diff --git a/com.avaloq.tools.ddk.xtextspy/icons/EReference.gif b/com.avaloq.tools.ddk.xtextspy/icons/EReference.gif deleted file mode 100644 index 88cdf2ad8..000000000 Binary files a/com.avaloq.tools.ddk.xtextspy/icons/EReference.gif and /dev/null differ diff --git a/com.avaloq.tools.ddk.xtextspy/icons/sample.gif b/com.avaloq.tools.ddk.xtextspy/icons/sample.gif deleted file mode 100644 index 34fb3c9d8..000000000 Binary files a/com.avaloq.tools.ddk.xtextspy/icons/sample.gif and /dev/null differ diff --git a/com.avaloq.tools.ddk.xtextspy/plugin.xml b/com.avaloq.tools.ddk.xtextspy/plugin.xml deleted file mode 100644 index 16d3f8731..000000000 --- a/com.avaloq.tools.ddk.xtextspy/plugin.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/com.avaloq.tools.ddk.xtextspy/pom.xml b/com.avaloq.tools.ddk.xtextspy/pom.xml deleted file mode 100644 index e56ed9620..000000000 --- a/com.avaloq.tools.ddk.xtextspy/pom.xml +++ /dev/null @@ -1,12 +0,0 @@ - - 4.0.0 - - ddk-parent - com.avaloq.tools.ddk - 14.1.0-SNAPSHOT - ../ddk-parent - - - com.avaloq.tools.ddk.xtextspy - eclipse-plugin - \ No newline at end of file diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/ASMDEditorUtils.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/ASMDEditorUtils.java deleted file mode 100644 index da1e4e28f..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/ASMDEditorUtils.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.xtext.ui.editor.XtextEditor; - - -/** - * Implementation of IEditorUtils that will *not* invoke object.getAdapter(XtextEditor.class), as that plays - * havoc with the current ASMD TableEditor and ASMD WfdEditor. - */ -public class ASMDEditorUtils implements IEditorUtils { - - @Override - public XtextEditor getActiveXtextEditor() { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - if (workbenchWindow == null) { - return null; - } - IWorkbenchPage activePage = workbenchWindow.getActivePage(); - if (activePage == null) { - return null; - } - IEditorPart activeEditor = activePage.getActiveEditor(); - if (activeEditor instanceof XtextEditor) { - return (XtextEditor) activeEditor; - // return null; - } - // XtextEditor xtextEditor = (XtextEditor) activeEditor.getAdapter(XtextEditor.class); - // return xtextEditor; - return null; - } - - @Override - public XtextEditor getXtextEditor(final IEditorPart openEditor) { - if (openEditor instanceof XtextEditor) { - return (XtextEditor) openEditor; - } - return null; - } - -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EClassNode.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EClassNode.java deleted file mode 100644 index 47e2dfe92..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EClassNode.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; - -import com.google.common.collect.Lists; - - -/** - * Representation of an EClass in a tree. - */ -public class EClassNode { - - private final EClass eClass; - private final EClassNode parentNode; - private List children; - - /** - * Instantiates a new e class node. - * - * @param eClass - * the e class - * @param parent - * the parent - */ - public EClassNode(final EClass eClass, final EClassNode parent) { - this.eClass = eClass; - this.parentNode = parent; - } - - /** - * Gets the e class. - * - * @return the e class - */ - public EClass getEClass() { - return eClass; - } - - /** - * Gets the parent. - * - * @return the parent - */ - public EClassNode getParent() { - return parentNode; - } - - /** - * Gets the children. - * - * @return the children - */ - public List getChildren() { - if (children == null) { - initializeChildren(); - } - return children; - } - - /** - * Checks for children. - * - * @return true, if successful - */ - public boolean hasChildren() { - return !eClass.getESuperTypes().isEmpty(); - } - - /** - * Initialize children. - */ - private void initializeChildren() { - children = Lists.newArrayList(); - for (EClass superEClass : eClass.getESuperTypes()) { - children.add(new EClassNode(superEClass, this)); - } - } -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EClassTypeContentProvider.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EClassTypeContentProvider.java deleted file mode 100644 index 1c4b5712f..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EClassTypeContentProvider.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import java.util.Collection; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; - -import com.google.inject.Singleton; - - -/** - * ContentProvider for {@link EClassTypeViewer} - provides the (super-)type hierarchy for an EClass instance. - */ -@Singleton -public class EClassTypeContentProvider implements ITreeContentProvider { - - @Override - public void dispose() { - } - - @Override - public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { - } - - @Override - public Object[] getElements(final Object inputElement) { - if (inputElement instanceof EClass) { - return new EClassNode[] {new EClassNode((EClass) inputElement, null)}; - } else if (inputElement instanceof EObject) { - return getElements(((EObject) inputElement).eClass()); - } - return new Object[] {}; - } - - @Override - public Object[] getChildren(final Object parentElement) { - if (parentElement instanceof EClassNode) { - Collection children = ((EClassNode) parentElement).getChildren(); - return children.toArray(new EClassNode[children.size()]); - } - return new Object[] {}; - } - - @Override - public Object getParent(final Object element) { - if (element instanceof EClassNode) { - return ((EClassNode) element).getParent(); - } - return null; - } - - @Override - public boolean hasChildren(final Object element) { - return element instanceof EClassNode && ((EClassNode) element).hasChildren(); - } - -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EClassTypeViewer.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EClassTypeViewer.java deleted file mode 100644 index b290df613..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EClassTypeViewer.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.widgets.Composite; - - -/** - * TreeViewer used to display an EClass' inheritance/super-type hierarchy. - */ -public class EClassTypeViewer extends TreeViewer implements ISelectionProvider, ISelectionChangedListener { - - public EClassTypeViewer(final Composite parent, final int style) { - super(parent, style); - setAutoExpandLevel(ALL_LEVELS); - } - - @Override - public void selectionChanged(final SelectionChangedEvent event) { - if (!event.getSelection().isEmpty() && event.getSource() instanceof XtextElementSelectionListener) { - setInput(((XtextElementSelectionListener) event.getSource()).getSelectedElementType()); - } - } - -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EObjectContentProvider.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EObjectContentProvider.java deleted file mode 100644 index 33b3a2b3b..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EObjectContentProvider.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import static com.google.common.collect.Lists.newArrayList; - -import java.util.List; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.xtext.resource.XtextResource; -import org.eclipse.xtext.ui.editor.XtextEditor; -import org.eclipse.xtext.util.concurrent.IUnitOfWork; - -import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.inject.Inject; - - -/** - * ContentProvider for the currently selected EObject. - * Provides: - * - key-value pairs where the key is the EAttribute and the value its corresponding value - * - EStructuralFeatures - * - EOperations. - */ -public class EObjectContentProvider implements ITreeContentProvider { - - @Inject - private XtextElementSelectionListener xtextElementSelectionListener; - - @Override - public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { - } - - @Override - public Object[] getElements(final Object inputElement) { - EClass selectionElementType = xtextElementSelectionListener.getSelectedElementType(); - if (inputElement instanceof EClass && selectionElementType != null && ((EClass) inputElement).isSuperTypeOf(selectionElementType)) { - return getChildren(selectionElementType); - } - return new Object[] {}; - } - - @Override - public Object[] getChildren(final Object parentElement) { - EClass selectionElementType = xtextElementSelectionListener.getSelectedElementType(); - if (selectionElementType != null) { - return Iterables.toArray(Iterables.concat(valuesForAttributes(selectionElementType.getEAllAttributes()), getReferenceFeatures(selectionElementType), selectionElementType.getEAllOperations()), Object.class); - } - return new Object[] {}; - } - - /** - * Gets all EStructuralFeatures that are not EAttributes. - * - * @param eClass - * the EClass - * @return EStructuralFeatures - */ - private Iterable getReferenceFeatures(final EClass eClass) { - return Iterables.filter(eClass.getEAllStructuralFeatures(), Predicates.not(Predicates.instanceOf(EAttribute.class))); - } - - /** - * Retrieve the object's values for the given EAttributes. - * - * @param attributes - * the EAttributes - * @return List> the attribute+values - possibly containing null entries - */ - private List valuesForAttributes(final EList attributes) { - final URI elementUri = xtextElementSelectionListener.getSelectedElementUri(); - XtextEditor editor = xtextElementSelectionListener.getEditor(); - if (editor != null && elementUri != null) { - return editor.getDocument().readOnly(new IUnitOfWork, XtextResource>() { - @Override - @SuppressWarnings("PMD.SignatureDeclareThrowsException") - public List exec(final XtextResource state) throws Exception { - final EObject eObject = state.getEObject(elementUri.fragment()); - List pairs = Lists.transform(attributes, new Function() { - @Override - public AttributeValuePair apply(final EAttribute from) { - return new AttributeValuePair(from, eObject.eGet(from)); - } - }); - return pairs; - } - }); - } - return newArrayList(); - } - - @Override - public void dispose() { - } - - @Override - public Object getParent(final Object element) { - return null; - } - - @Override - public boolean hasChildren(final Object element) { - return false; - } - - /** - * AttributeValuePair aggregates an EAttribute and an EObject's corresponding value. - */ - public static class AttributeValuePair { - private final EAttribute attribute; - private final Object value; - - public AttributeValuePair(final EAttribute attribute, final Object value) { - this.attribute = attribute; - this.value = value; - } - - public EAttribute getAttribute() { - return attribute; - } - - public Object getValue() { - return value; - } - } -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EObjectOutline.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EObjectOutline.java deleted file mode 100644 index 82d78a3d5..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/EObjectOutline.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.widgets.Composite; - -import com.avaloq.tools.ddk.xtextspy.EObjectContentProvider.AttributeValuePair; - - -/** - * Provides a tree view on the currently selected EObject. - * The viewer is intended to display information provided by {@link EObjectContentProvider}. - */ -public class EObjectOutline extends TreeViewer implements ISelectionChangedListener { - - private final ViewerComparator sorter = new EObjectOutlineSorter(); - private EClass selectedElementType; - - public EObjectOutline(final Composite parent, final int style) { - super(parent, style); - setAutoExpandLevel(ALL_LEVELS); - setComparator(sorter); - } - - @Override - public void selectionChanged(final SelectionChangedEvent event) { - if (!event.getSelection().isEmpty() && event.getSelectionProvider() instanceof XtextElementSelectionListener) { - selectedElementType = ((XtextElementSelectionListener) event.getSelectionProvider()).getSelectedElementType(); - setInput(selectedElementType); - } else if (selectedElementType != null && event.getSelection() instanceof IStructuredSelection) { - Object element = ((IStructuredSelection) event.getSelection()).getFirstElement(); - if (element instanceof EClassNode && ((EClassNode) element).getEClass().isSuperTypeOf(selectedElementType)) { - setInput(((EClassNode) element).getEClass()); - } - } - } - - /** - * ViewerSorter that provides sorting by EClass and by attribute/feature/operation. - */ - public static class EObjectOutlineSorter extends ViewerComparator { - private static final int OPERATION_CATEGORY = 3; - private static final int REFERENCE_CATEGORY = 2; - private static final int ATTRIBUTE_CATEGORY = 1; - private static final int MAGNITUDE = 100; - private boolean groupByEClass; - private boolean groupByElementKind; - - @Override - public int category(final Object element) { - int category = 1; - if (groupByElementKind) { - category *= MAGNITUDE; - if (element instanceof AttributeValuePair) { - category += ATTRIBUTE_CATEGORY; - } else if (element instanceof EStructuralFeature) { - category += REFERENCE_CATEGORY; - } else if (element instanceof EOperation) { - category += OPERATION_CATEGORY; - } - } - if (groupByEClass) { - category *= MAGNITUDE; - if (element instanceof AttributeValuePair) { - category += ((AttributeValuePair) element).getAttribute().getEContainingClass().getClassifierID(); - } else if (element instanceof EOperation) { - category += ((EOperation) element).getEContainingClass().getClassifierID(); - } else if (element instanceof EStructuralFeature) { - category += ((EStructuralFeature) element).getEContainingClass().getClassifierID(); - } - } - return category; - } - - public boolean isGroupByEClass() { - return groupByEClass; - } - - public void setGroupByEClass(final boolean sortByEClass) { - this.groupByEClass = sortByEClass; - } - - public boolean isGroupByElementKind() { - return groupByElementKind; - } - - public void setGroupByElementKind(final boolean groupByElementKind) { - this.groupByElementKind = groupByElementKind; - } - } - - /** - * ViewerFilter will only show features/operations if the are defined in the input element EClass, i.e. the EClass currently selected in - * {@link EClassTypeViewer}. - */ - public static class SelectedEClassOnlyFilter extends ViewerFilter { - @Override - public boolean select(final Viewer viewer, final Object parentElement, final Object element) { - if (element instanceof AttributeValuePair) { - return viewer.getInput() == ((AttributeValuePair) element).getAttribute().getEContainingClass(); - } else if (element instanceof EOperation) { - return viewer.getInput() == ((EOperation) element).getEContainingClass(); - } else if (element instanceof EStructuralFeature) { - return viewer.getInput() == ((EStructuralFeature) element).getEContainingClass(); - } - return true; - } - } -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/GrammarView.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/GrammarView.java deleted file mode 100644 index 4036f8523..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/GrammarView.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.xtext.AbstractRule; -import org.eclipse.xtext.CrossReference; -import org.eclipse.xtext.EnumLiteralDeclaration; -import org.eclipse.xtext.EnumRule; -import org.eclipse.xtext.GrammarUtil; -import org.eclipse.xtext.Keyword; -import org.eclipse.xtext.RuleCall; -import org.eclipse.xtext.TerminalRule; -import org.eclipse.xtext.util.XtextSwitch; - - -/** - * A composite with displaying the name of the Xtext rule corresponding to the current selection. - */ -public class GrammarView extends Composite implements ISelectionChangedListener { - - private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - private static final int COLUMNS = 4; - private final Text grammarText; - private final Text ruleText; - private final Text offsetText; - private final Text nodeText; - - /** - * Instantiates a new grammar view. - * - * @param parent - * the parent - * @param style - * the style - */ - public GrammarView(final Composite parent, final int style) { - super(parent, style); - GridLayout layout = new GridLayout(COLUMNS, false); - setLayout(layout); - - GridData gridData = new GridData(); - Label grammarLabel = new Label(this, SWT.NONE); - grammarLabel.setText(Messages.GrammarView_GrammarLabel); - grammarLabel.setLayoutData(gridData); - - gridData = new GridData(); - grammarText = new Text(this, SWT.READ_ONLY); - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalAlignment = GridData.FILL; - grammarText.setLayoutData(gridData); - - gridData = new GridData(); - Label nodeLabel = new Label(this, SWT.NONE); - nodeLabel.setText(Messages.GrammarView_NodeLabel); - nodeLabel.setLayoutData(gridData); - - nodeText = new Text(this, SWT.READ_ONLY); - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalAlignment = GridData.FILL; - nodeText.setLayoutData(gridData); - - gridData = new GridData(); - Label ruleLabel = new Label(this, SWT.NONE); - ruleLabel.setText(Messages.GrammarView_RuleLabel); - ruleLabel.setLayoutData(gridData); - - ruleText = new Text(this, SWT.READ_ONLY); - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalAlignment = GridData.FILL; - ruleText.setLayoutData(gridData); - - gridData = new GridData(); - Label offsetLabel = new Label(this, SWT.NONE); - offsetLabel.setText(Messages.GrammarView_OffsetLabel); - offsetLabel.setLayoutData(gridData); - - offsetText = new Text(this, SWT.READ_ONLY); - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalAlignment = GridData.FILL; - offsetText.setLayoutData(gridData); - } - - /** - * Set the parser rule name corresponding to the selection. {@inheritDoc} - * - * @param event - * the event - */ - @Override - @SuppressWarnings("PMD.NPathComplexity") - public void selectionChanged(final SelectionChangedEvent event) { - XtextElementSelectionListener source = (XtextElementSelectionListener) event.getSelectionProvider(); - AbstractRule rule = source.getRule(); - EObject nodeAbstractElement = source.getNodeGrammarElement(); - String grammarName = rule == null ? (nodeAbstractElement == null ? EMPTY_STRING : GrammarUtil.getGrammar(nodeAbstractElement).getName()) - : GrammarUtil.getGrammar(rule).getName(); - ruleText.setText(rule == null ? EMPTY_STRING : rule.getName()); - grammarText.setText(grammarName); - nodeText.setText(getText(nodeAbstractElement)); - Integer offset = source.getOffset(); - offsetText.setText(offset == null ? EMPTY_STRING : offset.toString()); - } - - /** - * Gets the text. - * - * @param grammarElement - * the grammar element - * @return the text - */ - private String getText(final EObject grammarElement) { - if (grammarElement == null) { - return EMPTY_STRING; - } - return new XtextSwitch() { - @Override - public String caseKeyword(final Keyword object) { - return Keyword.class.getSimpleName(); - } - - @Override - public String caseTerminalRule(final TerminalRule object) { - return object.getName(); - } - - @Override - public String caseEnumRule(final EnumRule object) { - return object.getName(); - } - - @Override - @SuppressWarnings("nls") - public String caseEnumLiteralDeclaration(final EnumLiteralDeclaration object) { - return "EnumLiteral"; - } - - @Override - public String caseRuleCall(final RuleCall object) { - return object.getRule().getName(); - } - - @Override - public String caseCrossReference(final CrossReference object) { - return doSwitch(object.getTerminal()); - } - - @Override - public String defaultCase(final EObject object) { - return EMPTY_STRING; - } - }.doSwitch(grammarElement); - } - -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/IEditorUtils.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/IEditorUtils.java deleted file mode 100644 index ddd3f7561..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/IEditorUtils.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.xtext.ui.editor.XtextEditor; -import org.eclipse.xtext.ui.editor.utils.EditorUtils; - -import com.google.inject.ImplementedBy; - - -/** - * Interface duplicating API of org.eclipse.xtext.ui.editor.utils.EditorUtils. - * This is intended to allow for an implementation that will *not* invoke object.getAdapter(XtextEditor.class) as that plays - * havoc with the current ASMD TableEditor and ASMD WfdEditor. - */ -@ImplementedBy(IEditorUtils.DefaultEditorUtils.class) -public interface IEditorUtils { - - /** - * Gets the active XtextEditor. - * - * @return the active XtextEditor or null - */ - XtextEditor getActiveXtextEditor(); - - /** - * Gets the XtextEditor associated with editor part. - * - * @param openEditor - * the editor part - * @return the XtextEditor or null - */ - XtextEditor getXtextEditor(IEditorPart openEditor); - - /** - * Default implementation of IEditorUtils. - * This is backed by {@link EditorUtils}. - */ - class DefaultEditorUtils implements IEditorUtils { - - @Override - public XtextEditor getActiveXtextEditor() { - return EditorUtils.getActiveXtextEditor(); - } - - @Override - public XtextEditor getXtextEditor(final IEditorPart openEditor) { - return EditorUtils.getXtextEditor(openEditor); - } - - } -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/Messages.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/Messages.java deleted file mode 100644 index 920bf4843..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/Messages.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.osgi.util.NLS; - - -//CHECKSTYLE:OFF -public class Messages extends NLS { - private static final String BUNDLE_NAME = "com.avaloq.tools.ddk.xtextspy.messages"; //$NON-NLS-1$ - public static String GrammarView_GrammarLabel; - public static String GrammarView_NodeLabel; - public static String GrammarView_OffsetLabel; - public static String GrammarView_RuleLabel; - public static String SpyViewPart_GroupByEClass; - public static String SpyViewPart_GroupByEClassTT; - public static String SpyViewPart_GroupByFeature; - public static String SpyViewPart_GroupByFeatureTT; - public static String SpyViewPart_LimitToEClass; - public static String SpyViewPart_LimitToEClassTT; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - super(); - } -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/SpyViewPart.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/SpyViewPart.java deleted file mode 100644 index 8a7eb33d6..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/SpyViewPart.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.part.ViewPart; - -import com.avaloq.tools.ddk.xtextspy.EObjectOutline.EObjectOutlineSorter; -import com.avaloq.tools.ddk.xtextspy.EObjectOutline.SelectedEClassOnlyFilter; -import com.google.common.collect.Iterables; -import com.google.inject.Inject; - - -/** - * Viewpart displaying information about the current selection in any Xtext-based language. - */ -public class SpyViewPart extends ViewPart { - - /** - * The ID of the view as specified by the extension. - */ - public static final String ID = "com.avaloq.tools.ddk.xtextspy.SpyView"; //$NON-NLS-1$ - - @Inject - private XtextElementSelectionListener selectionListener; - @Inject - private EObjectContentProvider objectContentProvider; - @Inject - private EClassTypeContentProvider typeContentProvider; - @Inject - private ILabelProvider labelProvider; - - private GrammarView grammarView; - private EObjectOutline eObjectOutline; - private EClassTypeViewer eClassTypeView; - - @Override - public void dispose() { - super.dispose(); - uninstallSelectionListeners(); - } - - /** - * Install selection listeners. - */ - private void installSelectionListeners() { - ISelectionService service = getSite().getService(ISelectionService.class); - service.addPostSelectionListener(selectionListener); - selectionListener.addSelectionChangedListener(grammarView); - selectionListener.addSelectionChangedListener(eClassTypeView); - eClassTypeView.addPostSelectionChangedListener(eObjectOutline); - selectionListener.addSelectionChangedListener(eObjectOutline); - } - - /** - * Uninstall selection listeners. - */ - private void uninstallSelectionListeners() { - ISelectionService service = getSite().getService(ISelectionService.class); - service.removePostSelectionListener(selectionListener); - selectionListener.removeSelectionChangedListener(grammarView); - selectionListener.removeSelectionChangedListener(eClassTypeView); - eClassTypeView.removePostSelectionChangedListener(eObjectOutline); - selectionListener.removeSelectionChangedListener(eObjectOutline); - } - - // //////////////////////// - @Override - public void createPartControl(final Composite parent) { - GridLayout layout = new GridLayout(); - parent.setLayout(layout); - // Grammar view - grammarView = new GrammarView(parent, SWT.NONE | SWT.BORDER); - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalAlignment = GridData.FILL; - grammarView.setLayoutData(gridData); - - // Sash containing EClassType and EObjectContent views - gridData = new GridData(); - gridData.verticalAlignment = GridData.FILL; - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.horizontalAlignment = GridData.FILL; - SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); - sashForm.setLayoutData(gridData); - eClassTypeView = new EClassTypeViewer(sashForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - eClassTypeView.setContentProvider(typeContentProvider); - eClassTypeView.setLabelProvider(labelProvider); - eObjectOutline = new EObjectOutline(sashForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - eObjectOutline.setLabelProvider(labelProvider); - eObjectOutline.setContentProvider(objectContentProvider); - - contributeMenuActions(); - // install selection listeners - installSelectionListeners(); - } - - @Override - public void setFocus() { - } - - /** - * Contribute menu actions "Group by EClass", "Group by feature/operation" and "Limit to EClass selection". - */ - private void contributeMenuActions() { - final Action selectedEClassOnlyAction = new Action(Messages.SpyViewPart_LimitToEClass, Action.AS_CHECK_BOX) { - private final ViewerFilter filter = new SelectedEClassOnlyFilter(); - - @Override - public String getToolTipText() { - return Messages.SpyViewPart_LimitToEClassTT; - } - - @Override - public void run() { - boolean hasFilter = Iterables.contains(Iterables.cycle(eObjectOutline.getFilters()), filter); - if (hasFilter) { - eObjectOutline.removeFilter(filter); - } else { - eObjectOutline.addFilter(filter); - } - setChecked(!hasFilter); - } - }; - Action groupByEClassAction = new Action(Messages.SpyViewPart_GroupByEClass, Action.AS_CHECK_BOX) { - @Override - public String getToolTipText() { - return Messages.SpyViewPart_GroupByEClassTT; - } - - @Override - public void run() { - EObjectOutlineSorter sorter = (EObjectOutlineSorter) eObjectOutline.getComparator(); - sorter.setGroupByEClass(!sorter.isGroupByEClass()); - setChecked(sorter.isGroupByEClass()); - eObjectOutline.refresh(); - } - - @Override - public boolean isEnabled() { - return super.isEnabled() && !selectedEClassOnlyAction.isChecked(); - } - }; - Action groupByElementKindAction = new Action(Messages.SpyViewPart_GroupByFeature, Action.AS_CHECK_BOX) { - @Override - public String getToolTipText() { - return Messages.SpyViewPart_GroupByFeatureTT; - } - - @Override - public void run() { - EObjectOutlineSorter sorter = (EObjectOutlineSorter) eObjectOutline.getComparator(); - sorter.setGroupByElementKind(!sorter.isGroupByElementKind()); - setChecked(sorter.isGroupByElementKind()); - eObjectOutline.refresh(); - } - }; - getViewSite().getActionBars().getMenuManager().add(groupByEClassAction); - getViewSite().getActionBars().getMenuManager().add(groupByElementKindAction); - getViewSite().getActionBars().getMenuManager().add(selectedEClassOnlyAction); - } -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextElementSelectionListener.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextElementSelectionListener.java deleted file mode 100644 index b519ad797..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextElementSelectionListener.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.xtext.AbstractRule; -import org.eclipse.xtext.GrammarUtil; -import org.eclipse.xtext.nodemodel.ILeafNode; -import org.eclipse.xtext.nodemodel.INode; -import org.eclipse.xtext.nodemodel.util.NodeModelUtils; -import org.eclipse.xtext.resource.XtextResource; -import org.eclipse.xtext.ui.editor.XtextEditor; -import org.eclipse.xtext.ui.editor.outline.impl.EObjectNode; -import org.eclipse.xtext.util.concurrent.IUnitOfWork; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - - -/** - * Listens to Xtext element selections and notifies listeners. - * Provides information about the element corresponding to the current selection: - * - grammar rule - * - semantic element URI - * - grammar element - * - type/EClass of semantic element - */ -@Singleton -public class XtextElementSelectionListener implements ISelectionListener, ISelectionProvider { - - private XtextEditor editor; - private ISelection selection; - @Inject - private IEditorUtils editorUtils; - - private final ListenerList listenerList = new ListenerList<>(); - private final ISelection emptySelection = new ISelection() { - @Override - public boolean isEmpty() { - return true; - } - }; - - @Override - public void selectionChanged(final IWorkbenchPart part, final ISelection sel) { - editor = editorUtils.getActiveXtextEditor(); - selection = sel; - fireSelectionChanged(); - } - - /** - * Returns the ILeafNode at the current selection if it is a ITextSelection, null otherwise. - * - * @return ILeafNode or null - */ - private ILeafNode nodeAtTextSelection() { - if (editor != null && selection instanceof ITextSelection) { - return editor.getDocument().readOnly(new IUnitOfWork() { - @Override - @SuppressWarnings({"PMD.SignatureDeclareThrowsException"}) - public ILeafNode exec(final XtextResource resource) throws Exception { - INode node = NodeModelUtils.getNode(resource.getContents().get(0)); - if (node == null) { - return null; - } - return NodeModelUtils.findLeafNodeAtOffset(node, ((ITextSelection) selection).getOffset()); - } - }); - } - return null; - } - - /** - * Notify all ISelectionChangedListener. - */ - private void fireSelectionChanged() { - SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection()); - for (Object listener : listenerList.getListeners()) { - ((ISelectionChangedListener) listener).selectionChanged(event); - } - } - - @Override - public void addSelectionChangedListener(final ISelectionChangedListener listener) { - listenerList.add(listener); - } - - @Override - public void removeSelectionChangedListener(final ISelectionChangedListener listener) { - listenerList.remove(listener); - } - - @Override - public void setSelection(final ISelection selection) { - throw new UnsupportedOperationException(); - } - - @Override - public ISelection getSelection() { - if (selection != null) { - return selection; - } - return emptySelection; - } - - /** - * Gets the parser rule at current selection. - * - * @return AbstractRule or null if no selection or no active XtextEditor - */ - public AbstractRule getRule() { - INode node = nodeAtTextSelection(); - if (node != null && node.getGrammarElement() != null) { - return GrammarUtil.containingRule(node.getGrammarElement()); - } - return null; - } - - /** - * Gets the XtextEditor corresponding to the current selection. - * - * @return the editor or null - */ - public XtextEditor getEditor() { - return editor; - } - - /** - * Gets the offset of the current selection or null. - * - * @return Integer or null - */ - @SuppressWarnings("PMD.NullAssignment") - public Integer getOffset() { - return selection instanceof ITextSelection ? ((ITextSelection) selection).getOffset() : null; - } - - /** - * Gets the GrammarElement at the current selection. - * - * @return GrammarElement or null if no text selection - */ - public EObject getNodeGrammarElement() { - ILeafNode node = nodeAtTextSelection(); - return node == null ? null : node.getGrammarElement(); - } - - /** - * Gets the EClass of the semantic element currently selected. - * - * @return EClass or null - */ - public EClass getSelectedElementType() { - if (selection instanceof IStructuredSelection) { - if (((IStructuredSelection) selection).getFirstElement() instanceof EObject) { - // structured selection, e.g. GMFEditor - EObject eObject = (EObject) ((IStructuredSelection) selection).getFirstElement(); - if (eObject.eResource() != null) { - return eObject.eClass(); - } - } else if (((IStructuredSelection) selection).getFirstElement() instanceof EObjectNode) { - // selection in outline - return ((EObjectNode) ((IStructuredSelection) selection).getFirstElement()).getEClass(); - } - } else { - ILeafNode node = nodeAtTextSelection(); - EObject semanticObject = NodeModelUtils.findActualSemanticObjectFor(node); - if (semanticObject != null) { - return semanticObject.eClass(); - } - } - return null; - } - - /** - * Gets the URI of the semantic element currently selected. - * - * @return URI or null - */ - public URI getSelectedElementUri() { - if (selection instanceof IStructuredSelection) { - if (((IStructuredSelection) selection).getFirstElement() instanceof InternalEObject) { - // structured selection, e.g. GMFEditor - return EcoreUtil.getURI((EObject) ((IStructuredSelection) selection).getFirstElement()); - } else if (((IStructuredSelection) selection).getFirstElement() instanceof EObjectNode) { - // selection in outline - return ((EObjectNode) ((IStructuredSelection) selection).getFirstElement()).getEObjectURI(); - } - } else { - ILeafNode node = nodeAtTextSelection(); - EObject semanticObject = NodeModelUtils.findActualSemanticObjectFor(node); - if (semanticObject != null) { - return EcoreUtil.getURI(semanticObject); - } - } - return null; - } -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextSpyExecutableExtensionFactory.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextSpyExecutableExtensionFactory.java deleted file mode 100644 index bb604e992..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextSpyExecutableExtensionFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.xtext.ui.guice.AbstractGuiceAwareExecutableExtensionFactory; -import org.osgi.framework.Bundle; - -import com.avaloq.tools.ddk.xtextspy.internal.Activator; -import com.google.inject.Injector; - - -/** - * This class was generated. Customizations should only happen in a newly - * introduced subclass. - */ -// CHECKSTYLE:OFF -public class XtextSpyExecutableExtensionFactory extends AbstractGuiceAwareExecutableExtensionFactory { - // CHECKSTYLE:ON - - @Override - protected Bundle getBundle() { - return Activator.getDefault().getBundle(); - } - - @Override - protected Injector getInjector() { - return Activator.getDefault().getInjector(); - } - -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextSpyLabelProvider.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextSpyLabelProvider.java deleted file mode 100644 index 0c4be55df..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextSpyLabelProvider.java +++ /dev/null @@ -1,344 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import java.util.Collections; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EEnumLiteral; -import org.eclipse.emf.ecore.ENamedElement; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EParameter; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.DecorationOverlayIcon; -import org.eclipse.jface.viewers.IDecoration; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; -import org.eclipse.xtext.ui.label.DeclarativeLabelProvider; -import org.eclipse.xtext.util.Pair; -import org.eclipse.xtext.util.PolymorphicDispatcher; -import org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler; -import org.eclipse.xtext.util.Tuples; - -import com.avaloq.tools.ddk.xtextspy.EObjectContentProvider.AttributeValuePair; -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.collect.Iterables; - - -/** - * LabelProvider for ECore objects displayed in XtextSpy View. - */ -@SuppressWarnings("nls") -public class XtextSpyLabelProvider extends DeclarativeLabelProvider { - - private static final String MANY_DECORATOR = "EOccurrenceZeroToUnbounded.gif"; - private final PolymorphicDispatcher> decoratorDispatcher = new PolymorphicDispatcher>("decorate", 1, 1, Collections.singletonList(this), new ErrorHandler>() { - @Override - public Pair handle(final Object[] params, final Throwable e) { - return null; - } - }); - - @Override - @SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts") - public Image getImage(final Object element) { - Image image = super.getImage(element); - if (image != null) { - Pair decoration = getDecoration(element); - if (decoration != null && decoration.getFirst() != null) { - Image overlay = convertToImage(decoration.getFirst()); - if (overlay != null) { - image = new DecorationOverlayIcon(image, ImageDescriptor.createFromImage(overlay), decoration.getSecond()).createImage(); - } - } - } - return image; - } - - /** - * Gets a decoration for an element. - * - * @param element - * the element - * @return Pair with decoration object and quadrant or null - */ - public Pair getDecoration(final Object element) { - return decoratorDispatcher.invoke(element); - } - - /** - * Decorate Object. - * - * @param obj - * the obj - * @return null - */ - protected Pair decorate(final Object obj) { - return null; - } - - /** - * Decorate Void. - * - * @param obj - * the obj - * @return null - */ - protected Pair decorate(final Void obj) { - return null; - } - - /** - * Decorate EStructuralFeature - if feature has multiplicity add * decoration. - * - * @param feature - * the feature - * @return multiplicity decorator if feature is many, else null - */ - protected Pair decorate(final EStructuralFeature feature) { - if (feature.isMany()) { - return Tuples. create(MANY_DECORATOR, IDecoration.BOTTOM_LEFT); - } - return null; - } - - /** - * Decorate EOperation - if operation has multiplicity add * decoration. - * - * @param operation - * the operation - * @return multiplicity decorator if feature is many, else null - */ - protected Pair decorate(final EOperation operation) { - if (operation.isMany()) { - return Tuples. create(MANY_DECORATOR, IDecoration.BOTTOM_LEFT); - } - return null; - } - - /** - * Simple name of a Class unless it is EOperation, EAttribute or EStructuralFeature. - * - * @param clazz - * the clazz - * @return the name - */ - protected String text(final Class clazz) { - if (clazz == EOperation.class) { - return "Operations"; - } - if (clazz == EStructuralFeature.class) { - return "References"; - } - if (clazz == EAttribute.class) { - return "Attributes"; - } - return clazz.getSimpleName(); - } - - /** - * Icon for a Class if it is EOperation, EAttribute or EStructuralFeature - null otherwise. - * - * @param clazz - * the clazz - * @return the image or null - */ - protected Object image(final Class clazz) { - if (clazz == EOperation.class || clazz == EStructuralFeature.class || clazz == EAttribute.class) { - return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT); - // return org.eclipse.jdt.internal.ui.JavaPluginImages.get(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_LOGICAL_PACKAGE); - // return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_LOGICAL_PACKAGE); - // return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ISharedImages.IMG_OBJ_PROJECT); - } - return null; - } - - /** - * Text for ENamedElement. - * - * @param eNamedElement - * the ENamedElement - * @return the name - */ - protected String text(final ENamedElement eNamedElement) { - return eNamedElement.getName(); - } - - /** - * Image for EClassifier. - * - * @param eClassifier - * the EClassifier - * @return the image name - */ - protected Object image(final EClassifier eClassifier) { - return "EClass.gif"; - // return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS); - } - - /** - * Text for EDataType. - * - * @param eDataType - * the EDataType - * @return the primitive name - */ - protected String text(final EDataType eDataType) { - return eDataType.getInstanceClass().getSimpleName(); - } - - /** - * Image for EDataType. - * - * @param eDataType - * the EDataType - * @return the image name - */ - protected Object image(final EDataType eDataType) { - return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS_DEFAULT); - } - - /** - * Text for EStructuralFeature. - * - * @param eStructuralFeature - * the EStructuralFeature - * @return the name - */ - protected String text(final EStructuralFeature eStructuralFeature) { - return Joiner.on(" : ").join(eStructuralFeature.getName(), getText(eStructuralFeature.getEType())); - } - - /** - * Text for attribute-value pair provided by {@link EObjectContentProvider}. - * - * @param attributeValuePair - * the attribute-value pair - * @return name of attribute and value - */ - protected String text(final AttributeValuePair attributeValuePair) { - String attribute = getText(attributeValuePair.getAttribute()); - String value = attributeValuePair.getValue() == null ? "" : attributeValuePair.getValue().toString(); - return attribute + " (" + value + ")"; - } - - /** - * Image for attribute-value pair provided by {@link EObjectContentProvider}. - * - * @param attributeValuePair - * the attribute-value pair - * @return image for attribute - */ - protected Object image(final AttributeValuePair attributeValuePair) { - return getImage(attributeValuePair.getAttribute()); - } - - /** - * Text for EStructuralFeature. - * - * @param eStructuralFeature - * the EStructuralFeature - * @return the image name - */ - protected Object image(final EStructuralFeature eStructuralFeature) { - return "EReference.gif"; - } - - /** - * Text for EAttribute. - * - * @param eAttribute - * the EAttribute - * @return the image name - */ - protected Object image(final EAttribute eAttribute) { - - // return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PUBLIC); - return "EAttribute.gif"; - } - - /** - * Text for EOperation. - * - * @param eOperation - * the EOperation - * @return the name and types of all EParameters - */ - protected String text(final EOperation eOperation) { - return eOperation.getName() + "(" + Joiner.on(", ").join(Iterables.transform(eOperation.getEParameters(), new Function() { - @Override - public String apply(final EParameter input) { - return getText(input.getEType()); - } - })) + ") : " + (eOperation.getEType() == null ? "Void" : getText(eOperation.getEType())); - } - - /** - * Image for EOperation. - * - * @param eOperation - * the EOperation - * @return the image name - */ - protected Object image(final EOperation eOperation) { - return "EOperation.gif"; - // return "platform:/plugin/org.eclipse.emf.ecore.edit/icons/full/obj16/EOperation.gif"; - } - - /** - * Text for an EClassNode. - * - * @param eClassNode - * the EClassNode - * @return text for the EClass - */ - protected String text(final EClassNode eClassNode) { - return getText(eClassNode.getEClass()); - } - - /** - * Image for an EClassNode. - * - * @param eClassNode - * the EClassNode - * @return image for the EClass - */ - protected Object image(final EClassNode eClassNode) { - return getImage(eClassNode.getEClass()); - } - - /** - * Image for an EEnum. - * - * @param eEnum - * the EEnum - * @return image for the EEnum - */ - protected Object image(final EEnum eEnum) { - return getImage("EEnum.gif"); - } - - /** - * Image for an EEnumLiteral. - * - * @param eEnumLiteral - * the EEnumLiteral - * @return image for the EEnumLiteral - */ - protected Object image(final EEnumLiteral eEnumLiteral) { - return getImage("EEnumLiteral.gif"); - } -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextSpyModule.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextSpyModule.java deleted file mode 100644 index 696d1df69..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/XtextSpyModule.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy; - -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.xtext.service.AbstractGenericModule; -import org.eclipse.xtext.ui.IImageHelper; -import org.eclipse.xtext.ui.PluginImageHelper; - -import com.google.inject.Binder; -import com.google.inject.Module; - - -/** - * Guice Module for XtextSpy. - */ -public class XtextSpyModule extends AbstractGenericModule implements Module { - - private final AbstractUIPlugin plugin; - - public XtextSpyModule(final AbstractUIPlugin plugin) { - this.plugin = plugin; - } - - /** - * Bind IEditorUtils. - * - * @return the ASMDEditorUtils - */ - public Class bindEditorUtils() { - return ASMDEditorUtils.class; - } - - /** - * Bind ILabelProvider. - * - * @return XtextSpyLabelProvider - */ - public Class bindLabelProvider() { - return XtextSpyLabelProvider.class; - } - - /** - * Bind IImageHelper. - * - * @return PluginImageHelper - */ - public Class bindImageHelper() { - return PluginImageHelper.class; - } - - @Override - public void configure(final Binder binder) { - super.configure(binder); - binder.bind(AbstractUIPlugin.class).toInstance(plugin); - } - -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/internal/Activator.java b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/internal/Activator.java deleted file mode 100644 index d0e581fa6..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/internal/Activator.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Avaloq Group AG and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Avaloq Group AG - initial API and implementation - *******************************************************************************/ -package com.avaloq.tools.ddk.xtextspy.internal; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -import com.avaloq.tools.ddk.xtextspy.XtextSpyModule; -import com.google.inject.Guice; -import com.google.inject.Injector; - - -/** - * The activator class controls the plug-in life cycle. - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.avaloq.tools.ddk.xtextspy"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - private Injector injector; - - @Override - @SuppressWarnings({"PMD.SignatureDeclareThrowsException"}) - public void start(final BundleContext context) throws Exception { - super.start(context); - plugin = this; - injector = Guice.createInjector(getModule()); - } - - @Override - @SuppressWarnings({"PMD.NullAssignment", "PMD.SignatureDeclareThrowsException"}) - public void stop(final BundleContext context) throws Exception { - plugin = null; - injector = null; - super.stop(context); - } - - public Injector getInjector() { - return injector; - } - - /** - * Gets the Guice module. - * - * @return XtextSpyModule - */ - protected XtextSpyModule getModule() { - return new XtextSpyModule(this); - } - - /** - * Returns the shared instance. - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns an image descriptor for the image file at the given - * plug-in relative path. - * - * @param path - * the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(final String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } -} diff --git a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/messages.properties b/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/messages.properties deleted file mode 100644 index 8f028bad1..000000000 --- a/com.avaloq.tools.ddk.xtextspy/src/com/avaloq/tools/ddk/xtextspy/messages.properties +++ /dev/null @@ -1,10 +0,0 @@ -GrammarView_GrammarLabel=Grammar: -GrammarView_NodeLabel=Node grammar element: -GrammarView_OffsetLabel=Offset: -GrammarView_RuleLabel=Grammar rule: -SpyViewPart_GroupByEClass=Group by EClass -SpyViewPart_GroupByEClassTT=Group features and operations by EClass -SpyViewPart_GroupByFeature=Group by feature/operation -SpyViewPart_GroupByFeatureTT=Group by attribute, feature and operation -SpyViewPart_LimitToEClass=Limit to EClass selection -SpyViewPart_LimitToEClassTT=Only display features and operations defined for selected EClass diff --git a/ddk-parent/pom.xml b/ddk-parent/pom.xml index a0c6e618a..844e9bd8d 100644 --- a/ddk-parent/pom.xml +++ b/ddk-parent/pom.xml @@ -55,7 +55,7 @@ 3.24.0 7.4.0 4.0.8 - 2.35.0 + 2.36.0 @@ -125,8 +125,6 @@ ../com.avaloq.tools.ddk.sample.helloworld.ui.test ../com.avaloq.tools.ddk.typesystem ../com.avaloq.tools.ddk.typesystem.test - ../com.avaloq.tools.ddk.xtextspy - ../com.avaloq.tools.ddk.xtextspy.test diff --git a/ddk-target/ddk-antlr.target b/ddk-target/ddk-antlr.target index 6d977e8ae..81441e8ee 100644 --- a/ddk-target/ddk-antlr.target +++ b/ddk-target/ddk-antlr.target @@ -1,6 +1,6 @@ - + @@ -11,8 +11,8 @@ - - + + diff --git a/ddk-target/ddk.target b/ddk-target/ddk.target index c94642c4b..99fe614ed 100644 --- a/ddk-target/ddk.target +++ b/ddk-target/ddk.target @@ -1,6 +1,6 @@ - + @@ -24,13 +24,13 @@ - + - +