Ejemplo n.º 1
0
 private IScope scope_EdgeBehaviorSectionCreateableIn(EObject context, EReference reference) {
   final Diagram diagram = EcoreUtil2.getContainerOfType(context, Diagram.class);
   final EdgeElement edgeElement = EcoreUtil2.getContainerOfType(context, EdgeElement.class);
   if (diagram == null || edgeElement == null) {
     return IScope.NULLSCOPE;
   }
   final EClass diagramModelType = diagram.getModelType();
   Predicate<EReference> filter =
       new Predicate<EReference>() {
         @Override
         public boolean apply(EReference input) {
           boolean superType = false;
           if (edgeElement != null && edgeElement.getType() != null) {
             superType = input.getEReferenceType().isSuperTypeOf(edgeElement.getType());
           }
           return superType;
         }
       };
   // get all containments of EClass contained in this package
   List<EReference> containmentReferences = new ArrayList<EReference>();
   containmentReferences.addAll(diagramModelType.getEAllContainments());
   //        // if the MetaClass is a connection take also the containment dependencies of the
   // source type
   //        EClass sourceType = (EClass) ((EdgeBehaviorSection)
   // edgeElement.getBehavior()).getSource().getEType();
   //        if (sourceType != null) {
   //            containmentReferences.addAll(sourceType.getEAllContainments());
   //        }
   return Scopes.scopeFor(Iterables.filter(containmentReferences, filter));
 }
Ejemplo n.º 2
0
 private IScope scope_TextPropertyAssignment_Attribute(EObject context) {
   NodeElement nodeElement = EcoreUtil2.getContainerOfType(context, NodeElement.class);
   EdgeElement edgeElement = EcoreUtil2.getContainerOfType(context, EdgeElement.class);
   if (nodeElement != null || edgeElement != null) {
     Predicate<EObject> filterPredicate =
         new Predicate<EObject>() {
           @Override
           public boolean apply(EObject input) {
             if (input instanceof EAttribute) {
               if (((EAttribute) input).getEType().getName().equals("EString")) {
                 return true;
               }
             }
             return false;
           }
         };
     if (nodeElement != null) {
       return MapBasedScope.createScope(
           IScope.NULLSCOPE,
           Scopes.scopedElementsFor(
               Iterables.filter(nodeElement.getType().getEAllAttributes(), filterPredicate)));
     } else {
       return MapBasedScope.createScope(
           IScope.NULLSCOPE,
           Scopes.scopedElementsFor(
               Iterables.filter(edgeElement.getType().getEAllAttributes(), filterPredicate)));
     }
   } else {
     return IScope.NULLSCOPE;
   }
 }
Ejemplo n.º 3
0
 public boolean definesUnorderedGroups(final ParserRule it, final AntlrOptions options) {
   boolean _and = false;
   boolean _isBacktrack = options.isBacktrack();
   if (!_isBacktrack) {
     _and = false;
   } else {
     List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(it);
     List<UnorderedGroup> _typeSelect =
         EcoreUtil2.<UnorderedGroup>typeSelect(_eAllContentsAsList, UnorderedGroup.class);
     boolean _isEmpty = _typeSelect.isEmpty();
     boolean _not = (!_isEmpty);
     _and = _not;
   }
   return _and;
 }
Ejemplo n.º 4
0
 private IScope scope_JvmParametrizedTypeReference_type(EObject context, EReference reference) {
   SprayStyleRef styleRef = EcoreUtil2.getContainerOfType(context, SprayStyleRef.class);
   if (styleRef != null) {
     return scope_ShapeStyleRefScope(styleRef, context, reference);
   }
   NodeFigureSection nodeFigSec = EcoreUtil2.getContainerOfType(context, NodeFigureSection.class);
   if (nodeFigSec != null) {
     return scope_NodeFigureSectionRefScope(nodeFigSec, context, reference);
   }
   EdgeFigureSection edgeFigSec = EcoreUtil2.getContainerOfType(context, EdgeFigureSection.class);
   if (edgeFigSec != null) {
     return scope_EdgeFigureSectionRefScope(edgeFigSec, context, reference);
   }
   return IScope.NULLSCOPE;
 }
 protected void computeReferencedJvmTypeHighlighting(
     IHighlightedPositionAcceptor acceptor, EObject referencer, CancelIndicator cancelIndicator) {
   for (EReference reference : referencer.eClass().getEAllReferences()) {
     EClass referencedType = reference.getEReferenceType();
     if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referencedType)) {
       List<EObject> referencedObjects = EcoreUtil2.getAllReferencedObjects(referencer, reference);
       if (referencedObjects.size() > 0) operationCanceledManager.checkCanceled(cancelIndicator);
       for (EObject referencedObject : referencedObjects) {
         EObject resolvedReferencedObject = EcoreUtil.resolve(referencedObject, referencer);
         if (resolvedReferencedObject != null && !resolvedReferencedObject.eIsProxy()) {
           highlightReferenceJvmType(acceptor, referencer, reference, resolvedReferencedObject);
         }
       }
     }
   }
 }
Ejemplo n.º 6
0
 public JvmParameterizedTypeReference createTypeRef(JvmType type, JvmTypeReference... typeArgs) {
   List<JvmTypeReference> typeReferences = Collections.emptyList();
   if (typeArgs != null && typeArgs.length > 0) {
     typeReferences = newArrayListWithCapacity(typeArgs.length);
     for (int i = 0; i < typeArgs.length; i++) {
       JvmTypeReference jvmTypeReference = typeArgs[i];
       typeReferences.add(EcoreUtil2.clone(jvmTypeReference));
     }
   }
   if (type instanceof JvmGenericType) {
     List<JvmTypeParameter> list = ((JvmGenericType) type).getTypeParameters();
     if (!typeReferences.isEmpty() && list.size() != typeReferences.size()) {
       throw new IllegalArgumentException(
           "The type "
               + type.getIdentifier()
               + " expects "
               + list.size()
               + " type arguments, but was "
               + typeReferences.size()
               + ". Either pass zero arguments (raw type) or the correct number.");
     }
     // Raw type -> create type references to type param
     if (typeReferences.isEmpty() && !list.isEmpty()) {
       typeReferences = newArrayListWithCapacity(list.size());
       for (JvmTypeParameter typeParameter : list) {
         typeReferences.add(createTypeRef(typeParameter));
       }
     }
   }
   JvmParameterizedTypeReference reference = factory.createJvmParameterizedTypeReference();
   reference.setType(type);
   if (!typeReferences.isEmpty()) reference.getArguments().addAll(typeReferences);
   return reference;
 }
Ejemplo n.º 7
0
 private IScope scope_MetaClass_Type(EObject context, EReference reference) {
   Diagram diagram = EcoreUtil2.getContainerOfType(context, Diagram.class);
   // all eClasses that are direct containments of context's diagram model type
   final EClass diagramModelType = diagram.getModelType();
   if (diagramModelType == null || diagramModelType.getEPackage() == null) {
     return IScope.NULLSCOPE;
   }
   final Predicate<EClassifier> filter =
       new Predicate<EClassifier>() {
         @Override
         public boolean apply(EClassifier input) {
           return input instanceof EClass
               && input != diagramModelType
               && !((EClass) input).isAbstract();
         }
       };
   final Function<EClassifier, IEObjectDescription> toObjDesc =
       new Function<EClassifier, IEObjectDescription>() {
         @Override
         public IEObjectDescription apply(EClassifier input) {
           return EObjectDescription.create(qnProvider.apply(input), input);
         }
       };
   // Implicit import of the EPackage of the Diagram Model type
   final List<ImportNormalizer> normalizer =
       Collections.singletonList(
           new ImportNormalizer(qnProvider.apply(diagramModelType.getEPackage()), true, false));
   final ImportScope importDiagramTypePackage =
       new ImportScope(normalizer, delegateGetScope(context, reference), null, null, false);
   final Iterable<IEObjectDescription> descriptions =
       Iterables.transform(
           Iterables.filter(diagramModelType.getEPackage().getEClassifiers(), filter), toObjDesc);
   // the delegate scope will provide import scopes
   return MapBasedScope.createScope(importDiagramTypePackage, descriptions);
 }
Ejemplo n.º 8
0
 @Override
 public String toString() {
   List<ITextSegment> list = toTokenAndGapList();
   if (list.isEmpty()) return "(empty)";
   Multimap<IHiddenRegion, IEObjectRegion> hiddens = LinkedListMultimap.create();
   List<String> errors = Lists.newArrayList();
   ITextRegionAccess access = list.get(0).getTextRegionAccess();
   TreeIterator<EObject> all = EcoreUtil2.eAll(access.regionForRootEObject().getSemanticElement());
   while (all.hasNext()) {
     EObject element = all.next();
     IEObjectRegion obj = access.regionForEObject(element);
     if (obj == null) continue;
     IHiddenRegion previous = obj.getPreviousHiddenRegion();
     IHiddenRegion next = obj.getNextHiddenRegion();
     if (previous == null)
       errors.add("ERROR: " + EmfFormatter.objPath(element) + " has no leading HiddenRegion.");
     else hiddens.put(previous, obj);
     if (previous != next) {
       if (next == null)
         errors.add("ERROR: " + EmfFormatter.objPath(element) + " has no trailing HiddenRegion.");
       else hiddens.put(next, obj);
     }
   }
   TextRegionListToString result = new TextRegionListToString();
   if (!hideColumnExplanation) {
     result.add("Columns: 1:offset 2:length 3:kind 4: text 5:grammarElement", false);
     result.add("Kind: H=IHiddenRegion S=ISemanticRegion B/E=IEObjectRegion", false);
     result.add("", false);
   }
   for (String error : errors) result.add(error, false);
   int indentation = 0;
   for (ITextSegment region : list) {
     List<IEObjectRegion> previous = Lists.newArrayList();
     List<IEObjectRegion> next = Lists.newArrayList();
     List<String> middle = Lists.newArrayList(toString(region));
     if (region instanceof IHiddenRegion) {
       Collection<IEObjectRegion> found = hiddens.get((IHiddenRegion) region);
       for (IEObjectRegion obj : found) {
         boolean p = obj.getNextHiddenRegion().equals(region);
         boolean n = obj.getPreviousHiddenRegion().equals(region);
         if (p && n) middle.add(EMPTY_TITLE + "Semantic " + toString(obj));
         else if (p) previous.add(obj);
         else if (n) next.add(obj);
       }
       Collections.sort(previous, AstRegionComparator.CHILDREN_FIRST);
       Collections.sort(next, AstRegionComparator.CONTAINER_FIRST);
     }
     for (IEObjectRegion obj : previous) {
       indentation--;
       result.add(indent(indentation) + EOBJECT_END_PADDED + toString(obj));
     }
     String indent = indent(indentation);
     result.add(region, indent + Joiner.on("\n").join(middle).replace("\n", "\n" + indent));
     for (IEObjectRegion obj : next) {
       result.add(indent(indentation) + EOBJECT_BEGIN_PADDED + toString(obj));
       indentation++;
     }
   }
   return result.toString();
 }
Ejemplo n.º 9
0
  @Check(CheckType.NORMAL)
  public void checkUnusedVariablesInInternalScope(InternalScope internalScope) {
    EList<Declaration> internalScopeDeclarations = internalScope.getDeclarations();

    EObject rootContainer = EcoreUtil.getRootContainer(internalScope);
    Resource rootRes = getResource(rootContainer);
    EList<EObject> contents = rootRes.getContents();
    Statechart sct = null;
    for (EObject eObject : contents) {
      if (eObject instanceof Statechart) {
        sct = (Statechart) eObject;
        break;
      }
    }
    List<ElementReferenceExpression> allUsedElementReferences =
        EcoreUtil2.getAllContentsOfType(sct, ElementReferenceExpression.class);

    if (sct.getSpecification() != null) {
      for (Declaration internalDeclaration : internalScopeDeclarations) {
        boolean internalDeclarationUsed = false;
        for (ElementReferenceExpression elementReference : allUsedElementReferences) {
          if (elementReference.getReference().eContainer() instanceof InternalScope) {
            if (elementReference.getReference() instanceof VariableDefinition) {
              if (((VariableDefinition) elementReference.getReference())
                      .getName()
                      .equals(internalDeclaration.getName())
                  && internalDeclaration instanceof VariableDefinition) {
                internalDeclarationUsed = true;
                break;
              }
            } else if (elementReference.getReference() instanceof EventDefinition) {
              if (((EventDefinition) elementReference.getReference())
                      .getName()
                      .equals(internalDeclaration.getName())
                  && internalDeclaration instanceof EventDefinition) {
                internalDeclarationUsed = true;
                break;
              }
            } else if (elementReference.getReference() instanceof OperationDefinition) {
              if (((OperationDefinition) elementReference.getReference())
                      .getName()
                      .equals(internalDeclaration.getName())
                  && internalDeclaration instanceof OperationDefinition) {
                internalDeclarationUsed = true;
                break;
              }
            }
          }
        }
        if (!internalDeclarationUsed) {

          if (internalDeclaration instanceof VariableDefinition
              || internalDeclaration instanceof EventDefinition
              || internalDeclaration instanceof OperationDefinition)
            warning(INTERNAL_DECLARATION_UNUSED, internalDeclaration, null, -1);
        }
      }
    }
  }
  private IScope getTypeIdScope(Program program) {
    // never return null, rather NULLSCOPE
    if (program == null) return IScope.NULLSCOPE;

    // build some scope to include all TypeID elements, simple names
    List<TypeId> allIds = EcoreUtil2.getAllContentsOfType(program, TypeId.class);
    return Scopes.scopeFor(allIds);
  }
 @Override
 public Set<Expression> getDependingExpressions() {
   final List<Variable> usedVariables =
       CorePatternLanguageHelper.getUsedVariables(
           xExpression,
           EcoreUtil2.getContainerOfType(expression, PatternBody.class).getVariables());
   return Sets.<Expression>newHashSet(usedVariables);
 }
Ejemplo n.º 12
0
 public JvmType findDeclaredType(String typeName, Notifier context) {
   if (context == null) throw new NullPointerException("context");
   ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
   if (resourceSet == null) return null;
   //			throw new NullPointerException("context must be contained in a resource");
   // make sure a type provider is configured in the resource set.
   IJvmTypeProvider typeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
   return typeProvider.findTypeByName(typeName);
 }
Ejemplo n.º 13
0
 private IScope scope_TextPropertyAssignment_Key(EObject context, EReference reference) {
   JvmType jvmType = null;
   final String className = "TextIds";
   final NodeFigureSection nodeFigSec =
       EcoreUtil2.getContainerOfType(context, NodeFigureSection.class);
   final EdgeFigureSection edgeFigSec =
       EcoreUtil2.getContainerOfType(context, EdgeFigureSection.class);
   if (nodeFigSec != null) {
     jvmType = nodeFigSec.getShapeRef().getType();
   } else if (edgeFigSec != null) {
     jvmType = edgeFigSec.getShapeRef().getType();
   }
   if (jvmType != null && jvmType instanceof JvmGenericType) {
     return getEnumerationLiteralsScopeForShape((JvmGenericType) jvmType, className);
   } else {
     return IScope.NULLSCOPE;
   }
 }
Ejemplo n.º 14
0
 private IScope scope_EdgeBehaviorSection_target(EObject context, EReference reference) {
   final EdgeElement edgeElement = EcoreUtil2.getContainerOfType(context, EdgeElement.class);
   final EdgeBehaviorSection edgeBehaviorSection =
       EcoreUtil2.getContainerOfType(context, EdgeBehaviorSection.class);
   // filter derived references
   Iterable<EReference> targetReferences =
       Iterables.filter(
           edgeElement.getType().getEAllReferences(),
           new Predicate<EReference>() {
             @Override
             public boolean apply(EReference input) {
               return input != edgeBehaviorSection.getSource() && !input.isDerived();
             }
           });
   final IScope result =
       MapBasedScope.createScope(IScope.NULLSCOPE, Scopes.scopedElementsFor(targetReferences));
   return result;
 }
Ejemplo n.º 15
0
  public List<Class> getCopyOfAddedClasses(DeltaModule delta) {

    List<Class> addedClasses = DeltaJUtils.getAddedClasses(delta);
    List<Class> copy = new LinkedList<Class>();
    for (Class class1 : addedClasses) {
      copy.add(EcoreUtil2.clone(class1));
    }
    return copy;
  }
Ejemplo n.º 16
0
  @Check(CheckType.FAST)
  public void vertexNotReachable(final Vertex vertex) {
    if (!(vertex instanceof Entry)) {

      final Set<Object> stateScopeSet = new HashSet<Object>();
      for (EObject obj : EcoreUtil2.eAllContents(vertex)) {
        stateScopeSet.add(obj);
      }
      stateScopeSet.add(vertex);

      final List<Object> externalPredecessors = new ArrayList<Object>();

      DFS dfs =
          new DFS() {

            @Override
            public Iterator<Object> getElementLinks(Object element) {
              List<Object> elements = new ArrayList<Object>();

              if (element instanceof org.yakindu.sct.model.sgraph.State) {
                if (!stateScopeSet.contains(element)) {
                  externalPredecessors.add(element);
                } else {
                  elements.addAll(((org.yakindu.sct.model.sgraph.State) element).getRegions());
                  elements.addAll(
                      ((org.yakindu.sct.model.sgraph.State) element).getIncomingTransitions());
                }

              } else if (element instanceof Region) {
                elements.addAll(((Region) element).getVertices());
              } else if (element instanceof Entry) {
                if (!stateScopeSet.contains(element)) {
                  externalPredecessors.add(element);
                } else {
                  elements.addAll(((Entry) element).getIncomingTransitions());
                }

              } else if (element instanceof Vertex) {
                elements.addAll(((Vertex) element).getIncomingTransitions());

              } else if (element instanceof Transition) {
                elements.add(((Transition) element).getSource());
              }

              return elements.iterator();
            }
          };

      dfs.perform(vertex);

      if (externalPredecessors.size() == 0) {
        error(ISSUE_NODE_NOT_REACHABLE, vertex, null, -1);
      }
    }
  }
 private Diagram getDiagramForSemanticElement(EObject state) {
   Collection<Diagram> diagrams =
       EcoreUtil2.getObjectsByType(
           state.eResource().getContents(), NotationPackage.Literals.DIAGRAM);
   for (Diagram diagram : diagrams) {
     if (EcoreUtil.equals(diagram.getElement(), state)) {
       return diagram;
     }
   }
   return null;
 }
 private EObject resolveProxy(EObject ref) {
   ResourceSet rSet = null;
   if (ref.eIsProxy() && EcoreUtil.getURI(ref).lastSegment().endsWith(".proc")) {
     rSet = studioExpression.eResource().getResourceSet();
   }
   EObject dep = EcoreUtil2.resolve(ref, rSet);
   if (rSet != null) {
     rSet.getResources().remove(ref.eResource());
   }
   return dep;
 }
 public Iterable<XtendMember> allVisibleMembers(final Step step) {
   final Scenario scenario = EcoreUtil2.<Scenario>getContainerOfType(step, Scenario.class);
   boolean _equals = Objects.equal(scenario, null);
   if (_equals) {
     return CollectionLiterals.<XtendMember>emptyList();
   }
   EList<XtendMember> members = scenario.getMembers();
   if ((scenario instanceof Background)) {
     return members;
   }
   final Feature feature = EcoreUtil2.<Feature>getContainerOfType(scenario, Feature.class);
   Background _background = feature.getBackground();
   boolean _equals_1 = Objects.equal(_background, null);
   if (_equals_1) {
     return members;
   }
   Background _background_1 = feature.getBackground();
   EList<XtendMember> _members = _background_1.getMembers();
   return Iterables.<XtendMember>concat(members, _members);
 }
Ejemplo n.º 20
0
 protected <T extends EObject> void remove(
     EObject element, Class<T> type, IModificationContext context) throws BadLocationException {
   T container = EcoreUtil2.getContainerOfType(element, type);
   if (container == null) {
     return;
   }
   ICompositeNode node = NodeModelUtils.findActualNodeFor(container);
   if (node == null) {
     return;
   }
   remove(context.getXtextDocument(), node);
 }
 void checkFile(IResource resource) {
   if (resource instanceof IFile) {
     IFile file = (IFile) resource;
     if (file.getName().endsWith("xfm.xmi")) {
       String thisUri = resource.getFullPath().toString();
       featureModelUri = getFeatureModelUri(file.getProject());
       if (thisUri.equals(featureModelUri)) refreshFeatureModel(file.getProject());
     }
     if (file.getName().endsWith(".v")) {
       builder.deleteMarkers(file);
       checkFilenameDepenency(file);
       checkFileContents(file);
     }
     if (file.getName().endsWith(".java")) {
       try {
         builder.deleteMarkers(file);
         List<CommentStructure> comments = buildCommentsStructure(loadFile(file));
         if (comments.size() > 0) {
           for (CommentStructure c : comments) {
             IParseResult result =
                 injector
                     .getInstance(FeaturesParser.class)
                     .parse("FeatureClause", new ByteArrayInputStream(c.clause.getBytes()));
             if (result.getParseErrors().size() > 0) {
               String message = "";
               for (SyntaxError err : result.getParseErrors()) message += err.getMessage() + "\n";
               Exception e = new RuntimeException("parse error: " + message);
               log.error("error while parsing feature clause", e);
             }
             EObject clause = result.getRootASTElement();
             if (clause instanceof Feature) {
               String feature =
                   clause.eGet(clause.eClass().getEStructuralFeature("feature")).toString();
               if (!isFeatureDefined(file, feature)) addMarkerIfNotDefined(feature, file, c.line);
             } else
               for (EObject e : EcoreUtil2.eAllContentsAsList(clause)) {
                 if (e instanceof Feature || e instanceof Atom) {
                   String feature = e.eGet(e.eClass().getEStructuralFeature("feature")).toString();
                   if (!isFeatureDefined(file, feature))
                     addMarkerIfNotDefined(feature, file, c.line);
                 }
               }
           }
         }
       } catch (ResourceException e) {
         log.error("error loading file", e);
       } catch (Throwable e) {
         log.error("error loading file", e);
       }
     }
   }
 }
Ejemplo n.º 22
0
 public String localVar(final Assignment it, final AbstractElement terminal) {
   String _feature = it.getFeature();
   String _plus = ("lv_" + _feature);
   String _plus_1 = (_plus + "_");
   ParserRule _containingParserRule = GrammarUtil.containingParserRule(it);
   List<AbstractElement> _contentsAsList = this.contentsAsList(_containingParserRule);
   int _indexOf = _contentsAsList.indexOf(it);
   String _plus_2 = (_plus_1 + Integer.valueOf(_indexOf));
   String _plus_3 = (_plus_2 + "_");
   List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(it);
   int _indexOf_1 = _eAllContentsAsList.indexOf(terminal);
   return (_plus_3 + Integer.valueOf(_indexOf_1));
 }
Ejemplo n.º 23
0
 private IScope scope_NodeBehaviorSectionCreateableIn(EObject context, EReference reference) {
   Diagram diagram = EcoreUtil2.getContainerOfType(context, Diagram.class);
   NodeElement nodeElement = EcoreUtil2.getContainerOfType(context, NodeElement.class);
   if (diagram == null || nodeElement == null) {
     return IScope.NULLSCOPE;
   }
   // all eClasses that are direct containments of context's diagram model type
   final EClass diagramModelType = diagram.getModelType();
   if (diagramModelType == null || diagramModelType.getEPackage() == null) {
     return IScope.NULLSCOPE;
   }
   List<EReference> containmentReferences = new ArrayList<EReference>();
   for (EClassifier eClassifiers : diagramModelType.getEPackage().getEClassifiers()) {
     if (eClassifiers instanceof EClass) {
       for (EReference ref : ((EClass) eClassifiers).getEAllContainments()) {
         if (ref.getEType() instanceof EClass
             && ((EClass) ref.getEType()).isSuperTypeOf(nodeElement.getType())) {
           containmentReferences.add(ref);
         }
       }
     }
   }
   return Scopes.scopeFor(containmentReferences);
 }
Ejemplo n.º 24
0
 protected Map<EObject, URI> createExportedElementsMap(Resource resource) {
   IResourceDescription resourceDescription =
       index.getResourceDescription(EcoreUtil2.getNormalizedURI(resource));
   Map<EObject, URI> exportedElementMap = newHashMap();
   if (resourceDescription != null) {
     for (IEObjectDescription exportedEObjectDescription :
         resourceDescription.getExportedObjects()) {
       EObject eObject =
           resource.getEObject(exportedEObjectDescription.getEObjectURI().fragment());
       if (eObject != null)
         exportedElementMap.put(eObject, exportedEObjectDescription.getEObjectURI());
     }
   }
   return exportedElementMap;
 }
 @Override
 public IGamlDescription getGamlDocumentation(final EObject object) {
   if (object == null) {
     return null;
   }
   // int index = getGamlDocIndex(object);
   // if ( index == -1 ) { return null; }
   URI key = getKey(object);
   if (key == null) {
     return null;
   }
   if (!CACHE2.containsKey(key)) {
     return null;
   }
   return CACHE2.get(key).get(EcoreUtil2.getURIFragment(object));
 }
Ejemplo n.º 26
0
 @Check
 public void checkPortRefEco(final PortRef pr) {
   final AbstractComponent comp =
       EcoreUtil2.<AbstractComponent>getContainerOfType(pr, AbstractComponent.class);
   boolean _and = false;
   boolean _isEcosystem = pr.isEcosystem();
   if (!_isEcosystem) {
     _and = false;
   } else {
     _and = (!(comp instanceof Species));
   }
   if (_and) {
     this.warning(
         "The keyword \'eco\' is meant to be used in a Species",
         SpeadlPackage.Literals.PORT_REF__ECOSYSTEM);
   }
 }
Ejemplo n.º 27
0
 @Override
 public JvmDeclaredType createType(Class<?> clazz) {
   try {
     JvmDeclaredType cachedResult = typeCache.get(clazz);
     // the cached result contains proxies and is not
     // contained in a resource set. clone it since the
     // client of #createClass will usually put the result
     // into a resource and perform proxy resolution afterwards
     // in the context of a single resource set.
     return EcoreUtil2.cloneWithProxies(cachedResult);
   } catch (Exception e) {
     if (log.isDebugEnabled()) {
       log.debug(e.getMessage(), e);
     }
     return delegate.createType(clazz);
   }
 }
Ejemplo n.º 28
0
        public Type getStringType(EObject object) {
          EObject model = EcoreUtil.getRootContainer(object);
          List<SimpleType> allSimpleTypes =
              EcoreUtil2.getAllContentsOfType(model, SimpleType.class);
          Predicate<SimpleType> stringTypePredicate =
              new Predicate<SimpleType>() {
                @Override
                public boolean apply(SimpleType input) {
                  return "String".equals(input.getName());
                }
              };

          try {
            return Iterables.getOnlyElement(Iterables.filter(allSimpleTypes, stringTypePredicate));
          } catch (NoSuchElementException ex) {
            return null;
          }
        }
 @Override
 public void setGamlDocumentation(final EObject object, final IGamlDescription description) {
   if (description == null || object == null) {
     return;
   }
   // int i = getIndex();
   // i = setGamlDocIndex(object, i);
   // if ( i == -1 ) { return; }
   URI key = getKey(object);
   if (key == null) {
     return;
   }
   // if ( CACHE.contains(key) ) {
   // CACHE.get(key).put(i, getGamlDocumentation(description));
   // }
   if (CACHE2.contains(key)) {
     CACHE2.get(key).put(EcoreUtil2.getURIFragment(object), getGamlDocumentation(description));
   }
 }
Ejemplo n.º 30
0
 protected String root(final EObject xtendClass) {
   final XtendFile specFile =
       EcoreUtil2.<XtendFile>getContainerOfType(xtendClass, XtendFile.class);
   final String packageName = specFile.getPackage();
   boolean _equals = Objects.equal(packageName, null);
   if (_equals) {
     return "";
   }
   final String[] fragments = packageName.split("\\.");
   final Function1<String, String> _function =
       new Function1<String, String>() {
         public String apply(final String s) {
           return "../";
         }
       };
   final List<String> path =
       ListExtensions.<String, String>map(
           ((List<String>) Conversions.doWrapArray(fragments)), _function);
   return IterableExtensions.join(path, "");
 }