Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2019-09-06 09:04:20 -0400
committerJuergen Haug2019-10-09 08:05:33 -0400
commit018ff97a5c9ff8b12f090496a302ad1fadf71372 (patch)
treedd25099d836af65784b6d252008e2b31257c7aa3
parent105760a8e143d474638d3d1b3ee443a9ed666fc8 (diff)
downloadorg.eclipse.etrice-018ff97a5c9ff8b12f090496a302ad1fadf71372.tar.gz
org.eclipse.etrice-018ff97a5c9ff8b12f090496a302ad1fadf71372.tar.xz
org.eclipse.etrice-018ff97a5c9ff8b12f090496a302ad1fadf71372.zip
Bug 550612 - [ui] Diagrams should be openable for non-critical
validation issues Introduced the concept of blocking issues preventing the diagram editors to open. Change-Id: I0d90a578f8de66a4da022e7dbeff82df3d390feb
-rw-r--r--plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/IssueUtils.java46
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java3
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java22
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/editor/RoomEditor.java24
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomFragmentProvider.java22
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java5
6 files changed, 97 insertions, 25 deletions
diff --git a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/IssueUtils.java b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/IssueUtils.java
new file mode 100644
index 000000000..6fcbb23a7
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/IssueUtils.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2019 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+package org.eclipse.etrice.core.common.validation;
+
+import org.eclipse.xtext.diagnostics.Diagnostic;
+import org.eclipse.xtext.diagnostics.Severity;
+import org.eclipse.xtext.validation.Issue;
+
+/**
+ * handle special data for issues blocking opening a diagram editor
+ *
+ */
+public class IssueUtils {
+
+ public static final String DUMMY_CODE = "no_special_code";
+ public static final String BLOCKING_MARKER = "blocking_marker";
+
+ private IssueUtils() {
+ // static methods only
+ }
+
+ public static boolean isBlocking(Issue issue) {
+ if (issue.getSeverity()==Severity.ERROR) {
+ if(Diagnostic.LINKING_DIAGNOSTIC.equals(issue.getCode())) {
+ return true;
+ }
+ for (String data : issue.getData()) {
+ if (BLOCKING_MARKER.equals(data)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java
index 54ae0b083..479290fd4 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java
@@ -12,6 +12,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.etrice.core.common.converter.BaseConverterService;
import org.eclipse.etrice.core.common.converter.CCStringIndentation;
+import org.eclipse.etrice.core.common.validation.IssueUtils;
import org.eclipse.etrice.core.fsm.fSM.ChoicePoint;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.core.fsm.fSM.FSMPackage;
@@ -244,6 +245,6 @@ public class FSMJavaValidator extends org.eclipse.etrice.core.fsm.validation.Abs
}
private void error(Result result) {
- error(result.getMsg(), result.getSource(), result.getFeature(), result.getIndex());
+ error(result.getMsg(), result.getSource(), result.getFeature(), result.getIndex(), IssueUtils.DUMMY_CODE, IssueUtils.BLOCKING_MARKER);
}
}
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java
index 4a3adb044..6d8812d6a 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java
@@ -70,6 +70,9 @@ public class FSMValidationUtil extends FSMValidationUtilXtend {
return result;
if (tgt instanceof TrPointTerminal) {
+ if (((TrPointTerminal) tgt).getTrPoint().eIsProxy()) {
+ return Result.error("transition target not found", tgt, FSMPackage.eINSTANCE.getTrPointTerminal_TrPoint(), 0);
+ }
if (((TrPointTerminal) tgt).getTrPoint() instanceof EntryPoint)
return Result.error("entry point can not be transition target", tgt, FSMPackage.eINSTANCE.getTrPointTerminal_TrPoint(), 0);
@@ -112,10 +115,18 @@ public class FSMValidationUtil extends FSMValidationUtilXtend {
// ExitPoint can be multiply connected inside a state
}
else if (tgt instanceof SubStateTrPointTerminal) {
+ if (((SubStateTrPointTerminal) tgt).getTrPoint().eIsProxy()) {
+ return Result.error("transition target not found", tgt, FSMPackage.eINSTANCE.getSubStateTrPointTerminal_TrPoint(), 0);
+ }
if (((SubStateTrPointTerminal) tgt).getTrPoint() instanceof ExitPoint)
return Result.error("sub state exit point can not be transition target", tgt, FSMPackage.eINSTANCE.getSubStateTrPointTerminal_TrPoint(), 0);
// sub state EntryPoint is valid as destination
}
+ else if (tgt instanceof StateTerminal) {
+ if (((StateTerminal) tgt).getState().eIsProxy()) {
+ return Result.error("transition target not found", tgt, FSMPackage.eINSTANCE.getStateTerminal_State(), 0);
+ }
+ }
return Result.ok();
}
@@ -136,6 +147,9 @@ public class FSMValidationUtil extends FSMValidationUtilXtend {
}
else if (src instanceof TrPointTerminal) {
TrPoint srcTP = ((TrPointTerminal) src).getTrPoint();
+ if (srcTP.eIsProxy()) {
+ return Result.error("transition source not found", trans, FSMPackage.eINSTANCE.getTrPointTerminal_TrPoint(), 0);
+ }
if (srcTP instanceof ExitPoint)
return Result.error("exit point can not be transition source", trans, FSMPackage.eINSTANCE.getTrPointTerminal_TrPoint(), 0);
// TransitionPoint and EntryPoint are valid
@@ -170,6 +184,9 @@ public class FSMValidationUtil extends FSMValidationUtilXtend {
}
}
else if (src instanceof SubStateTrPointTerminal) {
+ if (((SubStateTrPointTerminal) src).getTrPoint().eIsProxy()) {
+ return Result.error("transition source not found", src, FSMPackage.eINSTANCE.getSubStateTrPointTerminal_TrPoint(), 0);
+ }
if (((SubStateTrPointTerminal) src).getTrPoint() instanceof EntryPoint)
return Result.error("sub state entry point can not be transition source", src, FSMPackage.eINSTANCE.getSubStateTrPointTerminal_TrPoint(), 0);
// ExitPoint is valid as source
@@ -186,6 +203,11 @@ public class FSMValidationUtil extends FSMValidationUtilXtend {
}
}
}
+ else if (src instanceof StateTerminal) {
+ if (((StateTerminal) src).getState().eIsProxy()) {
+ return Result.error("transition target not found", src, FSMPackage.eINSTANCE.getStateTerminal_State(), 0);
+ }
+ }
return Result.ok();
}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/editor/RoomEditor.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/editor/RoomEditor.java
index 8819b3ed6..936e4ec4d 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/editor/RoomEditor.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/editor/RoomEditor.java
@@ -16,10 +16,10 @@ import java.util.List;
import org.eclipse.etrice.core.common.ui.editor.IValidatingEditor;
import org.eclipse.etrice.core.common.ui.editor.SaveOnFocusLostListener;
+import org.eclipse.etrice.core.common.validation.IssueUtils;
import org.eclipse.etrice.core.ui.preferences.RoomPreferenceConstants;
import org.eclipse.help.IContextProvider;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.xtext.diagnostics.Severity;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.XtextEditor;
import org.eclipse.xtext.util.CancelIndicator;
@@ -77,8 +77,12 @@ public class RoomEditor extends XtextEditor implements IValidatingEditor {
});
if (!result.isEmpty()) {
for (Issue issue : result) {
- if (issue.isSyntaxError() || issue.getSeverity()==Severity.ERROR)
+ if (issue.isSyntaxError()) {
return false;
+ }
+ if (IssueUtils.isBlocking(issue)) {
+ return false;
+ }
}
}
return true;
@@ -87,19 +91,11 @@ public class RoomEditor extends XtextEditor implements IValidatingEditor {
}
@Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class key) {
- if (key.equals(IContextProvider.class)) {
- return new SelectedModelHelpProvider(this);
+ public <T> T getAdapter(Class<T> adapter) {
+ if (IContextProvider.class.isAssignableFrom(adapter)) {
+ return adapter.cast(new SelectedModelHelpProvider(this));
}
- return super.getAdapter(key);
+ return super.getAdapter(adapter);
}
- // TODO: with Xtext 2.15 replace with implementation below
-// public <T> T getAdapter(Class<T> key) {
-// if (key.equals(IContextProvider.class)) {
-// return key.cast(new SelectedModelHelpProvider(this));
-// }
-// return super.getAdapter(key);
-//
-//}
}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomFragmentProvider.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomFragmentProvider.java
index 2353dfce0..0357a29ba 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomFragmentProvider.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomFragmentProvider.java
@@ -160,7 +160,7 @@ public class RoomFragmentProvider extends FSMFragmentProvider {
if (path != null)
return path;
- return fallback.getFragment(obj);
+ return fallback!=null ? fallback.getFragment(obj) : null;
}
protected String getFragment(EObject obj) {
@@ -182,19 +182,21 @@ public class RoomFragmentProvider extends FSMFragmentProvider {
}
public static boolean isActorClass(String fragment) {
- if (fragment.startsWith(RoomPackage.eINSTANCE.getActorClass().getName()))
+ if (fragment!=null && fragment.startsWith(RoomPackage.eINSTANCE.getActorClass().getName()))
return true;
return false;
}
public static boolean isStructureClass(String fragment) {
- if (fragment.startsWith(RoomPackage.eINSTANCE.getActorClass().getName()))
- return true;
- if (fragment.startsWith(RoomPackage.eINSTANCE.getSubSystemClass().getName()))
- return true;
- if (fragment.startsWith(RoomPackage.eINSTANCE.getLogicalSystem().getName()))
- return true;
+ if (fragment!=null) {
+ if (fragment.startsWith(RoomPackage.eINSTANCE.getActorClass().getName()))
+ return true;
+ if (fragment.startsWith(RoomPackage.eINSTANCE.getSubSystemClass().getName()))
+ return true;
+ if (fragment.startsWith(RoomPackage.eINSTANCE.getLogicalSystem().getName()))
+ return true;
+ }
return false;
}
@@ -239,6 +241,10 @@ public class RoomFragmentProvider extends FSMFragmentProvider {
}
protected EObject getEObject(RoomModel model, String fragment) {
+ if (fragment==null) {
+ return null;
+ }
+
int begin = 0;
int end = fragment.indexOf(TYPE_SEP);
if (end<0)
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
index b9089e545..9334c4863 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
@@ -36,6 +36,7 @@ import org.eclipse.etrice.core.common.base.BooleanLiteral;
import org.eclipse.etrice.core.common.base.Import;
import org.eclipse.etrice.core.common.base.LiteralType;
import org.eclipse.etrice.core.common.base.util.ImportHelpers;
+import org.eclipse.etrice.core.common.validation.IssueUtils;
import org.eclipse.etrice.core.common.validation.ValidationHelpers;
import org.eclipse.etrice.core.common.validation.ValidationHelpers.NamedObject;
import org.eclipse.etrice.core.common.validation.ValidationHelpers.NamedObjectList;
@@ -212,7 +213,7 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
ActorClass ac = (ActorClass) ar.eContainer();
if (roomHelpers.isReferencing(ar.getType(), ac)) {
- error("Actor reference is circular", RoomPackage.eINSTANCE.getActorRef_Type());
+ error("Actor reference is circular", RoomPackage.eINSTANCE.getActorRef_Type(), IssueUtils.DUMMY_CODE, IssueUtils.BLOCKING_MARKER);
}
}
@@ -814,7 +815,7 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
private void error(Result result) {
- error(result.getMsg(), result.getSource(), result.getFeature(), result.getIndex());
+ error(result.getMsg(), result.getSource(), result.getFeature(), result.getIndex(), IssueUtils.DUMMY_CODE, IssueUtils.BLOCKING_MARKER);
}
@Check

Back to the top