diff --git a/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLBehaviorUnitOutlineFilter.java b/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLBehaviorUnitOutlineFilter.java
index 01c46445ba..b22b216225 100644
--- a/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLBehaviorUnitOutlineFilter.java
+++ b/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLBehaviorUnitOutlineFilter.java
@@ -21,10 +21,9 @@
package io.sarl.lang.ui.outline;
-import static io.sarl.lang.sarl.SarlPackage.Literals.SARL_BEHAVIOR_UNIT;
+import static io.sarl.lang.ui.outline.SARLOutlineNodeComparator.isBehaviorUnit;
import com.google.inject.Inject;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.jface.action.Action;
import org.eclipse.xtext.ui.IImageHelper.IImageDescriptorHelper;
import org.eclipse.xtext.ui.editor.outline.IOutlineNode;
@@ -52,16 +51,8 @@ public class SARLBehaviorUnitOutlineFilter extends AbstractFilterOutlineContribu
*/
public static final String ICON_BASENAME = "hide_behavior_units.png"; //$NON-NLS-1$
- @Inject private IImageDescriptorHelper imageHelper;
-
- /** Replies if the given type is a behavior unit.
- *
- * @param type the type to test.
- * @return true
if the given type is for a behavior unit; false
otherwise.
- */
- protected static boolean isBehaviorUnit(EClass type) {
- return type == SARL_BEHAVIOR_UNIT;
- }
+ @Inject
+ private IImageDescriptorHelper imageHelper;
@Override
protected boolean apply(IOutlineNode node) {
diff --git a/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLFieldOutlineFilter.java b/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLFieldOutlineFilter.java
index 2372bada7e..19c321583a 100644
--- a/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLFieldOutlineFilter.java
+++ b/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLFieldOutlineFilter.java
@@ -21,10 +21,9 @@
package io.sarl.lang.ui.outline;
-import static org.eclipse.xtend.core.xtend.XtendPackage.Literals.XTEND_FIELD;
+import static io.sarl.lang.ui.outline.SARLOutlineNodeComparator.isField;
import com.google.inject.Inject;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.jface.action.Action;
import org.eclipse.xtext.ui.IImageHelper.IImageDescriptorHelper;
import org.eclipse.xtext.ui.editor.outline.IOutlineNode;
@@ -55,15 +54,6 @@ public class SARLFieldOutlineFilter extends AbstractFilterOutlineContribution {
@Inject
private IImageDescriptorHelper imageHelper;
- /** Replies if the given type is for a SARL field.
- *
- * @param type the type to test.
- * @return true
if the given type is for SARL fields, false
otherwise.
- */
- protected static boolean isField(EClass type) {
- return type == XTEND_FIELD;
- }
-
@Override
protected boolean apply(IOutlineNode node) {
if (node instanceof EObjectNode) {
diff --git a/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOperationOutlineFilter.java b/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOperationOutlineFilter.java
index 239836b4eb..3f617a0cf9 100644
--- a/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOperationOutlineFilter.java
+++ b/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOperationOutlineFilter.java
@@ -21,12 +21,9 @@
package io.sarl.lang.ui.outline;
-import static io.sarl.lang.sarl.SarlPackage.Literals.SARL_ACTION;
-import static org.eclipse.xtend.core.xtend.XtendPackage.Literals.XTEND_CONSTRUCTOR;
-import static org.eclipse.xtend.core.xtend.XtendPackage.Literals.XTEND_FUNCTION;
+import static io.sarl.lang.ui.outline.SARLOutlineNodeComparator.isAction;
import com.google.inject.Inject;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.jface.action.Action;
import org.eclipse.xtext.ui.IImageHelper.IImageDescriptorHelper;
import org.eclipse.xtext.ui.editor.outline.IOutlineNode;
@@ -57,24 +54,13 @@ public class SARLOperationOutlineFilter extends AbstractFilterOutlineContributio
@Inject
private IImageDescriptorHelper imageHelper;
- /** Replies if the given type is for a SARL operation.
- *
- * @param type the type to test.
- * @return true
if the given type is for a SARL operation; false
otherwise.
- */
- protected static boolean isOperation(EClass type) {
- return type == SARL_ACTION
- || type == XTEND_FUNCTION
- || type == XTEND_CONSTRUCTOR;
- }
-
@Override
protected boolean apply(IOutlineNode node) {
if (node instanceof EObjectNode) {
- return !isOperation(((EObjectNode) node).getEClass());
+ return !isAction(((EObjectNode) node).getEClass());
}
if (node instanceof EStructuralFeatureNode) {
- return !isOperation(((EStructuralFeatureNode) node).getEStructuralFeature().eClass());
+ return !isAction(((EStructuralFeatureNode) node).getEStructuralFeature().eClass());
}
return true;
}
diff --git a/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineNodeComparator.java b/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineNodeComparator.java
index f8dc69c671..cb9dbf42a2 100644
--- a/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineNodeComparator.java
+++ b/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineNodeComparator.java
@@ -28,6 +28,9 @@
import static org.eclipse.xtend.core.xtend.XtendPackage.Literals.XTEND_FIELD;
import static org.eclipse.xtend.core.xtend.XtendPackage.Literals.XTEND_FILE__PACKAGE;
import static org.eclipse.xtend.core.xtend.XtendPackage.Literals.XTEND_FUNCTION;
+import static org.eclipse.xtext.common.types.TypesPackage.Literals.JVM_CONSTRUCTOR;
+import static org.eclipse.xtext.common.types.TypesPackage.Literals.JVM_FIELD;
+import static org.eclipse.xtext.common.types.TypesPackage.Literals.JVM_OPERATION;
import static org.eclipse.xtext.xtype.XtypePackage.Literals.XIMPORT_SECTION;
import org.eclipse.emf.ecore.EClass;
@@ -83,6 +86,56 @@ public SARLOutlineNodeComparator() {
//
}
+ /** Replies if the given type corresponds to a field.
+ *
+ * @param type the type.
+ * @return {@code true} if the type corresponds to a SARL, Xtend or JVM field.
+ * @since 0.9
+ */
+ public static boolean isField(EClass type) {
+ return XTEND_FIELD.isSuperTypeOf(type) || JVM_FIELD.isSuperTypeOf(type);
+ }
+
+ /** Replies if the given type corresponds to an action.
+ *
+ * @param type the type.
+ * @return {@code true} if the type corresponds to a SARL, Xtend or JVM action/method/operation.
+ * @since 0.9
+ */
+ public static boolean isAction(EClass type) {
+ return XTEND_FUNCTION.isSuperTypeOf(type) || JVM_OPERATION.isSuperTypeOf(type);
+ }
+
+ /** Replies if the given type corresponds to a constructor.
+ *
+ * @param type the type.
+ * @return {@code true} if the type corresponds to a SARL, Xtend or JVM constructor.
+ * @since 0.9
+ */
+ public static boolean isConstructor(EClass type) {
+ return XTEND_CONSTRUCTOR.isSuperTypeOf(type) || JVM_CONSTRUCTOR.isSuperTypeOf(type);
+ }
+
+ /** Replies if the given type corresponds to a behavior unit.
+ *
+ * @param type the type.
+ * @return {@code true} if the type corresponds to a SARL behavior unit.
+ * @since 0.9
+ */
+ public static boolean isBehaviorUnit(EClass type) {
+ return SARL_BEHAVIOR_UNIT.isSuperTypeOf(type);
+ }
+
+ /** Replies if the given type corresponds to a capacity use.
+ *
+ * @param type the type.
+ * @return {@code true} if the type corresponds to a SARL capacity use.
+ * @since 0.9
+ */
+ public static boolean isCapacityUses(EClass type) {
+ return SARL_CAPACITY_USES.isSuperTypeOf(type);
+ }
+
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:returncount",
"checkstyle:cyclomaticcomplexity"})
@Override
@@ -108,34 +161,31 @@ public int getCategory(IOutlineNode node) {
}
return INNER_TYPE_PRIORITY;
}
- if (SARL_CAPACITY_USES.isSuperTypeOf(objectNodeType)) {
+ if (isCapacityUses(objectNodeType)) {
return CAPACITY_USE_PRIORITY;
}
if (SARL_REQUIRED_CAPACITY.isSuperTypeOf(objectNodeType)) {
return CAPACITY_REQUIREMENT_PRIORITY;
}
- if (XTEND_FIELD.isSuperTypeOf(objectNodeType)) {
+ if (isField(objectNodeType)) {
if (isStatic(objectNode)) {
return STATIC_FIELD_PRIORITY;
}
return FIELD_PRIORITY;
}
- if (XTEND_FUNCTION.isSuperTypeOf(objectNodeType)) {
+ if (isAction(objectNodeType)) {
if (isStatic(objectNode)) {
return STATIC_METHOD_PRIORITY;
}
return METHOD_PRIORITY;
}
- if (XTEND_CONSTRUCTOR.isSuperTypeOf(objectNodeType)) {
+ if (isConstructor(objectNodeType)) {
if (isStatic(objectNode)) {
return STATIC_CONSTRUCTOR;
}
return CONSTRUCTOR_PRIORITY;
}
- if (TypesPackage.Literals.JVM_CONSTRUCTOR.isSuperTypeOf(objectNodeType)) {
- return CONSTRUCTOR_PRIORITY;
- }
- if (SARL_BEHAVIOR_UNIT.isSuperTypeOf(objectNodeType)) {
+ if (isBehaviorUnit(objectNodeType)) {
return BEHAVIOR_UNIT_PRIORITY;
}
}