فهرست منبع

fixed confusing error msgs, added semantic highlighting (#1998)

Andreas Mülder 7 سال پیش
والد
کامیت
12b16ed610

+ 77 - 77
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/impl/CoreLibraryDefaultFeatureValueProvider.java

@@ -1,77 +1,77 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU 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:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.generator.core.library.impl;
-
-import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.DEBUG_FEATURE_DUMP_SEXEC;
-import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.LIBRARY_NAME;
-import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.LICENSE_TEXT;
-import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.OUTLET_FEATURE_API_TARGET_FOLDER;
-import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER;
-import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.OUTLET_FEATURE_TARGET_FOLDER;
-import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.OUTLET_FEATURE_TARGET_PROJECT;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.ecore.EObject;
-import org.yakindu.sct.generator.core.library.AbstractDefaultFeatureValueProvider;
-import org.yakindu.sct.model.sgen.FeatureParameterValue;
-import org.yakindu.sct.model.sgen.FeatureType;
-import org.yakindu.sct.model.sgen.FeatureTypeLibrary;
-
-/**
- * 
- * @author Holger Willebrandt - Initial contribution and API
- * @author Alexander Nyßen - Additions for issue #191.
- */
-public class CoreLibraryDefaultFeatureValueProvider extends AbstractDefaultFeatureValueProvider {
- 
-	public boolean isProviderFor(FeatureTypeLibrary library) {
-		return LIBRARY_NAME.equals(library.getName());
-	}
-
-	@Override
-	protected void setDefaultValue(FeatureType featureType, FeatureParameterValue parameterValue,
-			EObject contextElement) {
-		String parameterName = parameterValue.getParameter().getName();
-		if (OUTLET_FEATURE_TARGET_FOLDER.equals(parameterName)) {
-			parameterValue.setValue("src-gen");
-		} else if (OUTLET_FEATURE_LIBRARY_TARGET_FOLDER.equals(parameterName)) {
-			parameterValue.setValue("src");
-		} else if (OUTLET_FEATURE_TARGET_PROJECT.equals(parameterName)) {
-			parameterValue.setValue(getProjectName(contextElement));
-		} else if (LICENSE_TEXT.equals(parameterName)) {
-			parameterValue.setValue("Enter license text here");
-		} else if (DEBUG_FEATURE_DUMP_SEXEC.equals(parameterName)) {
-			parameterValue.setValue(false);
-		}
-	}
-
-	public IStatus validateParameterValue(FeatureParameterValue parameterValue) {
-		String parameterName = parameterValue.getParameter().getName();
-		if (OUTLET_FEATURE_TARGET_PROJECT.equals(parameterName) && !access.projectExists(parameterValue.getStringValue()))
-			return error(String.format("The Project %s does not exist.", parameterValue.getStringValue()));
-		if (OUTLET_FEATURE_TARGET_PROJECT.equals(parameterName) && access.projectExists(parameterValue.getStringValue())
-				&& !access.projectOpened(parameterValue.getStringValue()))
-			return error(String.format("The Project %s is not open.", parameterValue.getExpression()));
-		if (OUTLET_FEATURE_TARGET_FOLDER.equals(parameterName)
-				|| OUTLET_FEATURE_LIBRARY_TARGET_FOLDER.equals(parameterName)
-				|| OUTLET_FEATURE_API_TARGET_FOLDER.equals(parameterName)) {
-			FeatureParameterValue targetProjectParam = parameterValue.getFeatureConfiguration()
-					.getParameterValue(OUTLET_FEATURE_TARGET_PROJECT);
-			String targetProjectName = targetProjectParam != null ? targetProjectParam.getStringValue() : null;
-			if (targetProjectName != null && !access.folderExists(targetProjectName, parameterValue.getStringValue())) {
-				return warning(String.format("The Folder %s does not exist in Project %s",
-						parameterValue.getStringValue(), targetProjectName));
-			}
-		}
-		return Status.OK_STATUS;
-	}
-}
+/**
+ * Copyright (c) 2011 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.core.library.impl;
+
+import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.DEBUG_FEATURE_DUMP_SEXEC;
+import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.LIBRARY_NAME;
+import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.LICENSE_TEXT;
+import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.OUTLET_FEATURE_API_TARGET_FOLDER;
+import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER;
+import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.OUTLET_FEATURE_TARGET_FOLDER;
+import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.OUTLET_FEATURE_TARGET_PROJECT;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.yakindu.sct.generator.core.library.AbstractDefaultFeatureValueProvider;
+import org.yakindu.sct.model.sgen.FeatureParameterValue;
+import org.yakindu.sct.model.sgen.FeatureType;
+import org.yakindu.sct.model.sgen.FeatureTypeLibrary;
+
+/**
+ * 
+ * @author Holger Willebrandt - Initial contribution and API
+ * @author Alexander Nyßen - Additions for issue #191.
+ */
+public class CoreLibraryDefaultFeatureValueProvider extends AbstractDefaultFeatureValueProvider {
+ 
+	public boolean isProviderFor(FeatureTypeLibrary library) {
+		return LIBRARY_NAME.equals(library.getName());
+	}
+
+	@Override
+	protected void setDefaultValue(FeatureType featureType, FeatureParameterValue parameterValue,
+			EObject contextElement) {
+		String parameterName = parameterValue.getParameter().getName();
+		if (OUTLET_FEATURE_TARGET_FOLDER.equals(parameterName)) {
+			parameterValue.setValue("src-gen");
+		} else if (OUTLET_FEATURE_LIBRARY_TARGET_FOLDER.equals(parameterName)) {
+			parameterValue.setValue("src");
+		} else if (OUTLET_FEATURE_TARGET_PROJECT.equals(parameterName)) {
+			parameterValue.setValue(getProjectName(contextElement));
+		} else if (LICENSE_TEXT.equals(parameterName)) {
+			parameterValue.setValue("Enter license text here");
+		} else if (DEBUG_FEATURE_DUMP_SEXEC.equals(parameterName)) {
+			parameterValue.setValue(false);
+		}
+	}
+
+	public IStatus validateParameterValue(FeatureParameterValue parameterValue) {
+		String parameterName = parameterValue.getParameter().getName();
+		if (OUTLET_FEATURE_TARGET_PROJECT.equals(parameterName) && !access.projectExists(parameterValue.getStringValue()))
+			return error(String.format("The Project %s does not exist.", parameterValue.getStringValue()));
+		if (OUTLET_FEATURE_TARGET_PROJECT.equals(parameterName) && access.projectExists(parameterValue.getStringValue())
+				&& !access.projectOpened(parameterValue.getStringValue()))
+			return error(String.format("The Project %s is not open.", parameterValue.getStringValue()));
+		if (OUTLET_FEATURE_TARGET_FOLDER.equals(parameterName)
+				|| OUTLET_FEATURE_LIBRARY_TARGET_FOLDER.equals(parameterName)
+				|| OUTLET_FEATURE_API_TARGET_FOLDER.equals(parameterName)) {
+			FeatureParameterValue targetProjectParam = parameterValue.getFeatureConfiguration()
+					.getParameterValue(OUTLET_FEATURE_TARGET_PROJECT);
+			String targetProjectName = targetProjectParam != null ? targetProjectParam.getStringValue() : null;
+			if (targetProjectName != null && !access.folderExists(targetProjectName, parameterValue.getStringValue())) {
+				return warning(String.format("The Folder %s does not exist in Project %s",
+						parameterValue.getStringValue(), targetProjectName));
+			}
+		}
+		return Status.OK_STATUS;
+	}
+}

+ 90 - 88
plugins/org.yakindu.sct.generator.genmodel.ui/src/org/yakindu/sct/generator/genmodel/ui/highlighting/SGenSemanticHighlightingCalculator.java

@@ -1,88 +1,90 @@
-/**
- * Copyright (c) 2013 committers of YAKINDU 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:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.generator.genmodel.ui.highlighting;
-
-import java.util.List;
-
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.common.types.TypesPackage;
-import org.eclipse.xtext.nodemodel.INode;
-import org.eclipse.xtext.nodemodel.impl.LeafNode;
-import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
-import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultHighlightingConfiguration;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
-import org.yakindu.base.expressions.expressions.ElementReferenceExpression;
-import org.yakindu.base.expressions.expressions.ExpressionsPackage;
-import org.yakindu.base.types.Property;
-import org.yakindu.sct.model.sgen.DeprecatableElement;
-import org.yakindu.sct.model.sgen.GeneratorEntry;
-import org.yakindu.sct.model.sgen.SGenPackage;
-import org.yakindu.sct.model.sgen.impl.FeatureConfigurationImpl;
-import org.yakindu.sct.model.sgen.util.BuiltinDeclarationNames;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class SGenSemanticHighlightingCalculator implements ISemanticHighlightingCalculator, BuiltinDeclarationNames {
-
-	public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
-		if (resource == null || resource.getParseResult() == null)
-			return;
-		TreeIterator<EObject> allContents = resource.getAllContents();
-		while (allContents.hasNext()) {
-			final EObject object = allContents.next();
-			if (object instanceof GeneratorEntry) {
-				GeneratorEntry entry = (GeneratorEntry) object;
-
-				List<INode> nodes = NodeModelUtils.findNodesForFeature(entry,
-						SGenPackage.Literals.GENERATOR_ENTRY__CONTENT_TYPE);
-				List<INode> features = NodeModelUtils.findNodesForFeature(entry,
-						SGenPackage.Literals.GENERATOR_ENTRY__FEATURES);
-				for (INode node : nodes) {
-					if (node instanceof LeafNode && !((LeafNode) node).isHidden()) {
-						acceptor.addPosition(node.getTotalOffset(), node.getTotalLength(),
-								DefaultHighlightingConfiguration.KEYWORD_ID);
-					}
-				}
-				for (INode node : features) {
-					if (node.getSemanticElement() instanceof FeatureConfigurationImpl) {
-						FeatureConfigurationImpl feature = (FeatureConfigurationImpl) node.getSemanticElement();
-						DeprecatableElement deprecatableElement = feature.getType();
-						if (deprecatableElement != null && deprecatableElement.isDeprecated()) {
-							acceptor.addPosition(node.getTotalOffset(), node.getTotalLength(),
-									SGenHighlightingConfiguration.DEPRECATION);
-						}
-					}
-				}
-				// allContents.prune();
-			} else if (object instanceof ElementReferenceExpression) {
-				List<INode> nodes = NodeModelUtils.findNodesForFeature(object,
-						ExpressionsPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE);
-				for (INode node : nodes) {
-					String name = ((Property) ((ElementReferenceExpression) object).getReference()).getName();
-					switch (name) {
-						case HOSTNAME_VAR :
-						case USER_VAR :
-						case SCT_VERSION_VAR :
-						case TIMESTAMP_VAR :
-							acceptor.addPosition(node.getTotalOffset(), node.getTotalLength(),
-									DefaultHighlightingConfiguration.KEYWORD_ID);
-					}
-				}
-			}
-		}
-	}
-}
+/**
+ * Copyright (c) 2013 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.genmodel.ui.highlighting;
+
+import java.util.List;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.common.types.TypesPackage;
+import org.eclipse.xtext.nodemodel.INode;
+import org.eclipse.xtext.nodemodel.impl.LeafNode;
+import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultHighlightingConfiguration;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
+import org.yakindu.base.expressions.expressions.ElementReferenceExpression;
+import org.yakindu.base.expressions.expressions.ExpressionsPackage;
+import org.yakindu.base.types.Property;
+import org.yakindu.sct.model.sgen.DeprecatableElement;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgen.SGenPackage;
+import org.yakindu.sct.model.sgen.impl.FeatureConfigurationImpl;
+import org.yakindu.sct.model.sgen.util.BuiltinDeclarationNames;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class SGenSemanticHighlightingCalculator implements ISemanticHighlightingCalculator, BuiltinDeclarationNames {
+
+	public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
+		if (resource == null || resource.getParseResult() == null)
+			return;
+		TreeIterator<EObject> allContents = resource.getAllContents();
+		while (allContents.hasNext()) {
+			final EObject object = allContents.next();
+			if (object instanceof GeneratorEntry) {
+				GeneratorEntry entry = (GeneratorEntry) object;
+
+				List<INode> nodes = NodeModelUtils.findNodesForFeature(entry,
+						SGenPackage.Literals.GENERATOR_ENTRY__CONTENT_TYPE);
+				List<INode> features = NodeModelUtils.findNodesForFeature(entry,
+						SGenPackage.Literals.GENERATOR_ENTRY__FEATURES);
+				for (INode node : nodes) {
+					if (node instanceof LeafNode && !((LeafNode) node).isHidden()) {
+						acceptor.addPosition(node.getTotalOffset(), node.getTotalLength(),
+								DefaultHighlightingConfiguration.KEYWORD_ID);
+					}
+				}
+				for (INode node : features) {
+					if (node.getSemanticElement() instanceof FeatureConfigurationImpl) {
+						FeatureConfigurationImpl feature = (FeatureConfigurationImpl) node.getSemanticElement();
+						DeprecatableElement deprecatableElement = feature.getType();
+						if (deprecatableElement != null && deprecatableElement.isDeprecated()) {
+							acceptor.addPosition(node.getTotalOffset(), node.getTotalLength(),
+									SGenHighlightingConfiguration.DEPRECATION);
+						}
+					}
+				}
+				// allContents.prune();
+			} else if (object instanceof ElementReferenceExpression && !((ElementReferenceExpression) object).getReference().eIsProxy()) {
+				List<INode> nodes = NodeModelUtils.findNodesForFeature(object,
+						ExpressionsPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE);
+				for (INode node : nodes) {
+					String name = ((Property) ((ElementReferenceExpression) object).getReference()).getName();
+					switch (name) {
+						case SCT_VERSION_VAR :
+						case SHA256 :
+						case SCTFILE:
+						case TIMESTAMP_VAR :
+						case USER_VAR :
+						case HOSTNAME_VAR :
+							acceptor.addPosition(node.getTotalOffset(), node.getTotalLength(),
+									DefaultHighlightingConfiguration.KEYWORD_ID);
+					}
+				}
+			}
+		}
+	}
+}