Search in sources :

Example 6 with GeneratorEntry

use of org.yakindu.sct.model.sgen.GeneratorEntry in project statecharts by Yakindu.

the class GeneratorExecutorLookup method execute.

public void execute(GeneratorModel model) {
    EList<GeneratorEntry> entries = model.getEntries();
    for (GeneratorEntry generatorEntry : entries) {
        final IGeneratorEntryExecutor executor = createExecutor(generatorEntry, model.getGeneratorId());
        executor.execute(generatorEntry);
    }
}
Also used : GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry)

Example 7 with GeneratorEntry

use of org.yakindu.sct.model.sgen.GeneratorEntry in project statecharts by Yakindu.

the class SGenSemanticHighlightingCalculator method provideHighlightingFor.

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);
                }
            }
        }
    }
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) EObject(org.eclipse.emf.ecore.EObject) LeafNode(org.eclipse.xtext.nodemodel.impl.LeafNode) DeprecatableElement(org.yakindu.sct.model.sgen.DeprecatableElement) FeatureConfigurationImpl(org.yakindu.sct.model.sgen.impl.FeatureConfigurationImpl) List(java.util.List) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression)

Example 8 with GeneratorEntry

use of org.yakindu.sct.model.sgen.GeneratorEntry in project statecharts by Yakindu.

the class CDefaultFeatureValueProvider method setDefaultValue.

@Override
protected void setDefaultValue(FeatureType featureType, FeatureParameterValue parameterValue, EObject contextElement) {
    GeneratorEntry entry = (GeneratorEntry) contextElement;
    Statechart statechart = (Statechart) entry.getElementRef();
    String parameterName = parameterValue.getParameter().getName();
    if (ICFeatureConstants.PARAMETER_NAMING_MODULE_NAME.equals(parameterName)) {
        parameterValue.setValue(asIdentifier(statechart.getName(), "_"));
    } else if (ICFeatureConstants.PARAMETER_NAMING_STATEMACHINE_PREFIX.equals(parameterName)) {
        parameterValue.setValue(StringExtensions.toFirstLower(asIdentifier(statechart.getName(), "_")));
    } else if (ICFeatureConstants.PARAMETER_NAMING_MAX_IDENTIFIER_LENGTH.equals(parameterName)) {
        parameterValue.setValue(31);
    } else if (ICFeatureConstants.PARAMETER_NAMING_SEPARATOR.equals(parameterName)) {
        parameterValue.setValue("_");
    } else if (ICFeatureConstants.PARAMETER_TRACING_ENTER_STATE.equals(parameterName)) {
        parameterValue.setValue(true);
    } else if (ICFeatureConstants.PARAMETER_TRACING_EXIT_STATE.equals(parameterName)) {
        parameterValue.setValue(true);
    } else if (ICFeatureConstants.PARAMETER_INCLUDES_USE_RELATIVE_PATHS.equals(parameterName)) {
        parameterValue.setValue(true);
    } else {
        throw new IllegalArgumentException("Unsupported parameter '" + parameterName + "'.");
    }
}
Also used : GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) Statechart(org.yakindu.sct.model.sgraph.Statechart)

Aggregations

GeneratorEntry (org.yakindu.sct.model.sgen.GeneratorEntry)8 FeatureConfiguration (org.yakindu.sct.model.sgen.FeatureConfiguration)3 FeatureType (org.yakindu.sct.model.sgen.FeatureType)2 Statechart (org.yakindu.sct.model.sgraph.Statechart)2 Binder (com.google.inject.Binder)1 Module (com.google.inject.Module)1 List (java.util.List)1 IMarker (org.eclipse.core.resources.IMarker)1 IProject (org.eclipse.core.resources.IProject)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 EObject (org.eclipse.emf.ecore.EObject)1 INode (org.eclipse.xtext.nodemodel.INode)1 LeafNode (org.eclipse.xtext.nodemodel.impl.LeafNode)1 Check (org.eclipse.xtext.validation.Check)1 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)1 EclipseContextGeneratorExecutorLookup (org.yakindu.sct.generator.builder.EclipseContextGeneratorExecutorLookup)1 IConsoleLogger (org.yakindu.sct.generator.core.console.IConsoleLogger)1 IGeneratorEntryExecutor (org.yakindu.sct.generator.core.execution.IGeneratorEntryExecutor)1 DeprecatableElement (org.yakindu.sct.model.sgen.DeprecatableElement)1 FeatureParameter (org.yakindu.sct.model.sgen.FeatureParameter)1