コード例 #1
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  private IScope getStateScopes(EObject obj) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    // first state in container hierarchy
    StateGraph parent = getStateGraph(obj);

    // collect states of my parent
    if (parent != null) {
      for (State s : parent.getStates()) {
        BaseState bs = getBaseState(s);
        scopes.add(EObjectDescription.create(bs.getName(), bs));
      }

      // if my parent is a refined state we also add its base state contents
      if (parent.eContainer() instanceof RefinedState) {
        parent = ((RefinedState) parent.eContainer()).getBase().getSubgraph();
        if (parent != null)
          for (State s : parent.getStates()) {
            BaseState bs = getBaseState(s);
            scopes.add(EObjectDescription.create(bs.getName(), bs));
          }
      } else if (parent.eContainer() instanceof ActorClass) {
        ActorClass ac = (ActorClass) parent.eContainer();
        if (ac.getBase() != null) {
          for (State s : ac.getBase().getStateMachine().getStates()) {
            BaseState bs = getBaseState(s);
            scopes.add(EObjectDescription.create(bs.getName(), bs));
          }
        }
      }
    }
    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #2
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of Choicepoint scopes for a {@link SubStateTrPointTerminal}
   *
   * @param ct - the transition endpoint or terminal
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_ChoicepointTerminal_cp(ChoicepointTerminal ct, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    // first state in container hierarchy
    StateGraph parent = getStateGraph(ct);

    // collect choicepoints of my parent
    if (parent != null)
      for (ChoicePoint cp : parent.getChPoints()) {
        scopes.add(EObjectDescription.create(cp.getName(), cp));
      }

    // if my parent is a refined state we also add its base state contents
    if (parent.eContainer() instanceof RefinedState) {
      parent = ((RefinedState) parent.eContainer()).getBase().getSubgraph();
      if (parent != null)
        for (ChoicePoint cp : parent.getChPoints()) {
          scopes.add(EObjectDescription.create(cp.getName(), cp));
        }
    } else if (parent.eContainer() instanceof ActorClass) {
      ActorClass ac = (ActorClass) parent.eContainer();
      if (ac.getBase() != null) {
        for (ChoicePoint cp : ac.getBase().getStateMachine().getChPoints()) {
          scopes.add(EObjectDescription.create(cp.getName(), cp));
        }
      }
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #3
0
 protected IScope doGetTypeScope(XMemberFeatureCall call, JvmType type) {
   if (call.isPackageFragment()) {
     if (type instanceof JvmDeclaredType) {
       int segmentIndex = countSegments(call);
       String packageName = ((JvmDeclaredType) type).getPackageName();
       List<String> splitted = Strings.split(packageName, '.');
       String segment = splitted.get(segmentIndex);
       return new SingletonScope(EObjectDescription.create(segment, type), IScope.NULLSCOPE);
     }
     return IScope.NULLSCOPE;
   } else {
     if (type instanceof JvmDeclaredType && ((JvmDeclaredType) type).getDeclaringType() == null) {
       return new SingletonScope(
           EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE);
     } else {
       XAbstractFeatureCall target = (XAbstractFeatureCall) call.getMemberCallTarget();
       if (target.isPackageFragment()) {
         String qualifiedName = type.getQualifiedName();
         int dot = qualifiedName.lastIndexOf('.');
         String simpleName = qualifiedName.substring(dot + 1);
         return new SingletonScope(EObjectDescription.create(simpleName, type), IScope.NULLSCOPE);
       } else {
         return new SingletonScope(
             EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE);
       }
     }
   }
 }
コード例 #4
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of Port scopes for a {@link MessageFromIf}
   *
   * @param mfi - the message from interface
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_MessageFromIf_port(MessageFromIf mfi, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorClass ac = getActorClass(mfi);
    for (Port p : ac.getIntPorts()) {
      scopes.add(EObjectDescription.create(p.getName(), p));
    }
    for (ExternalPort p : ac.getExtPorts()) {
      scopes.add(EObjectDescription.create(p.getIfport().getName(), p.getIfport()));
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #5
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  public IScope scope_MessageHandler_msg(MessageHandler handler, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ProtocolClass pc = RoomHelpers.getProtocolClass(handler);
    if (pc != null) {
      for (Message m : pc.getIncomingMessages()) {
        scopes.add(EObjectDescription.create(m.getName(), m));
      }
      for (Message m : pc.getOutgoingMessages()) {
        scopes.add(EObjectDescription.create(m.getName(), m));
      }
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #6
0
  @Test
  public void testHasChanges_6() throws Exception {
    TestResDesc resourceDesc = new TestResDesc();
    resourceDesc.exported.add(
        EObjectDescription.create(BAR, EcorePackage.Literals.EANNOTATION, null));

    TestResDesc resourceDesc2 = new TestResDesc();
    resourceDesc2.imported.add(FOP);
    resourceDesc2.exported.add(
        EObjectDescription.create(BAR, EcorePackage.Literals.EANNOTATION, null));

    assertFalse(
        new DefaultResourceDescriptionDelta(resourceDesc, resourceDesc2)
            .haveEObjectDescriptionsChanged());
  }
コード例 #7
0
 // TODO split this into smaller methods, investigate override / overload semantics
 // This assumes that the model was linked properly and not changed in an incompatible way
 // which is quite hard anyway ...
 public IScope createFeatureCallSerializationScope(EObject context) {
   if (!(context instanceof XAbstractFeatureCall)) {
     return IScope.NULLSCOPE;
   }
   XAbstractFeatureCall call = (XAbstractFeatureCall) context;
   JvmIdentifiableElement feature = call.getFeature();
   // this and super - logical container aware FeatureScopes
   if (feature instanceof JvmType) {
     return getTypeScope(call, (JvmType) feature);
   }
   if (feature instanceof JvmConstructor) {
     return getThisOrSuperScope(call, (JvmConstructor) feature);
   }
   if (feature instanceof JvmExecutable) {
     return getExecutableScope(call, feature);
   }
   if (feature instanceof JvmFormalParameter
       || feature instanceof JvmField
       || feature instanceof XVariableDeclaration
       || feature instanceof XSwitchExpression) {
     return new SingletonScope(
         EObjectDescription.create(feature.getSimpleName(), feature), IScope.NULLSCOPE);
   }
   return IScope.NULLSCOPE;
 }
コード例 #8
0
  @Test
  public void testHasChanges_DifferentTypes() throws Exception {
    TestResDesc resourceDesc = new TestResDesc();
    resourceDesc.imported.add(FOO);
    resourceDesc.exported.add(
        EObjectDescription.create(
            BAR, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar")));

    TestResDesc resourceDesc2 = new TestResDesc();
    resourceDesc2.imported.add(FOO);
    resourceDesc2.exported.add(
        new EObjectDescription(
            BAR,
            EcorePackage.Literals.EANNOTATION__CONTENTS,
            Collections.singletonMap("foo", "bar")) {
          @Override
          public URI getEObjectURI() {
            return EcoreUtil.getURI(EcorePackage.Literals.EANNOTATION);
          }
        });

    assertTrue(
        new DefaultResourceDescriptionDelta(resourceDesc, resourceDesc2)
            .haveEObjectDescriptionsChanged());
  }
コード例 #9
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  private void getTrPointScopes(final List<IEObjectDescription> scopes, StateGraph sg) {

    // collect transition points of this state
    for (TrPoint tp : sg.getTrPoints()) {
      scopes.add(EObjectDescription.create(tp.getName(), tp));
    }

    // if this state is a refined state we also add its base state transition points
    if (sg.eContainer() instanceof RefinedState) {
      sg = ((RefinedState) sg.eContainer()).getBase().getSubgraph();
      if (sg != null)
        for (TrPoint tp : sg.getTrPoints()) {
          scopes.add(EObjectDescription.create(tp.getName(), tp));
        }
    }
  }
 protected Boolean createContentDescription(EObject object) {
   QualifiedName name = nameOf(object);
   if (name != null) {
     acceptor.accept(EObjectDescription.create(name, object));
   }
   return Boolean.TRUE;
 }
コード例 #11
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of Message scopes for a {@link SemanticsInRule}
   *
   * @param sr - the semantics rule for incoming messages
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_SemanticsRule_msg(SemanticsRule sr, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ProtocolClass pc = RoomHelpers.getProtocolClass(sr);
    LinkedList<ProtocolClass> classes = getBaseClasses(pc);
    for (ProtocolClass bpc : classes) {
      for (Message m : bpc.getIncomingMessages()) {
        scopes.add(EObjectDescription.create(m.getName(), m));
      }
      for (Message m : bpc.getOutgoingMessages()) {
        scopes.add(EObjectDescription.create(m.getName(), m));
      }
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #12
0
  @Test
  public void testHasChanges_7() throws Exception {
    TestResDesc resourceDesc = new TestResDesc();
    resourceDesc.imported.add(FOO);
    resourceDesc.exported.add(
        EObjectDescription.create(
            BAR, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar")));

    TestResDesc resourceDesc2 = new TestResDesc();
    resourceDesc2.imported.add(FOO);
    resourceDesc2.exported.add(
        EObjectDescription.create(BAR, EcorePackage.Literals.EANNOTATION, null));

    assertTrue(
        new DefaultResourceDescriptionDelta(resourceDesc, resourceDesc2)
            .haveEObjectDescriptionsChanged());
  }
コード例 #13
0
 protected IScope getExecutableScope(XAbstractFeatureCall call, JvmIdentifiableElement feature) {
   QualifiedName name = QualifiedName.create(feature.getSimpleName());
   if (call.isOperation()) {
     QualifiedName operator = getOperator(call, name);
     if (operator == null) {
       return IScope.NULLSCOPE;
     }
     return new SingletonScope(EObjectDescription.create(operator, feature), IScope.NULLSCOPE);
   }
   if (call instanceof XAssignment) {
     String propertyName = Strings.toFirstLower(feature.getSimpleName().substring(3));
     return new SingletonScope(EObjectDescription.create(propertyName, feature), IScope.NULLSCOPE);
   }
   if (call.isExplicitOperationCallOrBuilderSyntax()
       || ((JvmExecutable) feature).getParameters().size() > 1
       || (!call.isExtension() && ((JvmExecutable) feature).getParameters().size() == 1)) {
     return new SingletonScope(EObjectDescription.create(name, feature), IScope.NULLSCOPE);
   }
   if (feature.getSimpleName().startsWith("get") || feature.getSimpleName().startsWith("is")) {
     List<IEObjectDescription> result = Lists.newArrayListWithCapacity(2);
     result.add(EObjectDescription.create(name, feature));
     if (feature.getSimpleName().startsWith("get")) {
       String propertyName = Strings.toFirstLower(feature.getSimpleName().substring(3));
       result.add(EObjectDescription.create(propertyName, feature));
     } else {
       String propertyName = Strings.toFirstLower(feature.getSimpleName().substring(2));
       result.add(EObjectDescription.create(propertyName, feature));
     }
     return new SimpleScope(result);
   }
   return new SingletonScope(EObjectDescription.create(name, feature), IScope.NULLSCOPE);
 }
コード例 #14
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  public IScope scope_PortOperation_sendsMsg(PortOperation op, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    PortClass pcls = (PortClass) op.eContainer();
    ProtocolClass pc = RoomHelpers.getProtocolClass(op);
    if (pc != null) {
      if (pcls == pc.getConjugate())
        for (Message m : pc.getIncomingMessages()) {
          scopes.add(EObjectDescription.create(m.getName(), m));
        }
      else
        for (Message m : pc.getOutgoingMessages()) {
          scopes.add(EObjectDescription.create(m.getName(), m));
        }
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #15
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of Port scopes for a {@link BindingEndPoint}
   *
   * @param ep - the endpoint
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_BindingEndPoint_port(BindingEndPoint ep, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorContainerClass acc = getActorContainerClass(ep);

    if (ep.getActorRef() == null) {
      if (acc instanceof ActorClass) {
        ActorClass ac = (ActorClass) acc;
        // for all super classes (including this class)
        LinkedList<ActorClass> classes = getBaseClasses(ac);
        for (ActorClass a : classes) {
          // collect internal and relay ports, i.e.
          // structure ports not in interface (internal)
          for (Port p : a.getIntPorts()) {
            scopes.add(EObjectDescription.create(p.getName(), p));
          }
          // interface ports not in structure (relay)
          for (Port p : a.getIfPorts()) {
            if (!isContained(p, a.getExtPorts()))
              scopes.add(EObjectDescription.create(p.getName(), p));
          }
        }
      } else {
        // SubSystemClass has no internal end ports
      }
    } else {
      // all ports in the sub actor's interface
      if (ep.getActorRef() instanceof ActorRef) {
        ActorClass ac = ((ActorRef) ep.getActorRef()).getType();
        LinkedList<ActorClass> classes = getBaseClasses(ac);
        for (ActorClass a : classes) {
          for (Port p : a.getIfPorts()) {
            scopes.add(EObjectDescription.create(p.getName(), p));
          }
        }
      } else {
        SubSystemClass ssc = ((SubSystemRef) ep.getActorRef()).getType();
        for (Port p : ssc.getRelayPorts()) {
          scopes.add(EObjectDescription.create(p.getName(), p));
        }
      }
    }
    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #16
0
 @Override
 protected Iterable<IEObjectDescription> getAllLocalElements() {
   Map<String, IEObjectDescription> result = new HashMap<String, IEObjectDescription>();
   for (IEObjectDescription ePkgDesc : parentScope.getAllElements()) {
     EPackage ePkg = (EPackage) ePkgDesc.getEObjectOrProxy();
     ePkg = (EPackage) EcoreUtil.resolve(ePkg, context);
     result.put(ePkg.getNsURI(), EObjectDescription.create(ePkg.getNsURI(), ePkg));
   }
   return result.values();
 }
コード例 #17
0
 @Override
 protected void doGetDescriptions(
     JvmType type, JvmType knownType, int i, List<IEObjectDescription> result) {
   super.doGetDescriptions(type, knownType, i, result);
   QualifiedName importName = importNames.get(i);
   if (type == knownType && importName != null) {
     result.add(
         EObjectDescription.create(QualifiedName.create(importName.getLastSegment()), type));
   }
 }
コード例 #18
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of ActorRef scopes for a {@link SPPoint}
   *
   * @param pt
   * @param ref
   * @return a list of scopes
   */
  public IScope scope_SPPoint_actorRef(SPPoint pt, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorContainerClass acc = getActorContainerClass(pt);
    if (acc instanceof ActorClass) {
      LinkedList<ActorClass> classes = getBaseClasses((ActorClass) acc);
      for (ActorClass a : classes) {
        for (ActorRef ar : a.getActorRefs()) {
          scopes.add(EObjectDescription.create(ar.getName(), ar));
        }
      }
    } else {
      for (ActorRef ar : acc.getActorRefs()) {
        scopes.add(EObjectDescription.create(ar.getName(), ar));
      }
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #19
0
 public void testErrorMessage_02() {
   EClass eClass = createEClass();
   eClass.setName("EClassName");
   IEObjectDescription description =
       EObjectDescription.create(QualifiedName.create(eClass.getName()), eClass);
   String errorMessage =
       helper.getDuplicateNameErrorMessage(
           description, EcorePackage.Literals.ECLASS, EcorePackage.Literals.ENAMED_ELEMENT__NAME);
   assertEquals("Duplicate EClass 'EClassName'", errorMessage);
 }
コード例 #20
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of Port scopes for a {@link ExternalPort}
   *
   * @param ar - the external port
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_ExternalPort_ifport(ExternalPort ep, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorClass ac = getActorClass(ep);
    for (Port ip : ac.getIfPorts()) {
      scopes.add(EObjectDescription.create(ip.getName(), ip));
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #21
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of BaseState scopes for a {@link RefinedState}
   *
   * @param rs - the refined state
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_RefinedState_base(RefinedState rs, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorClass ac = getActorClass(rs);
    LinkedList<BaseState> states = new LinkedList<BaseState>();
    collectAllStates(ac.getBase(), states);
    for (BaseState bs : states) {
      scopes.add(EObjectDescription.create(getStatePath(bs), bs));
    }
    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #22
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of InterfaceItem scopes for a {@link MessageFromIf}
   *
   * @param mfi - the message from interface
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_MessageFromIf_from(MessageFromIf mfi, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorClass ac = getActorClass(mfi);
    List<InterfaceItem> items = RoomHelpers.getAllInterfaceItems(ac);

    for (InterfaceItem item : items) {
      scopes.add(EObjectDescription.create(item.getName(), item));
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #23
0
 protected IScope getThisOrSuperScope(XAbstractFeatureCall call, JvmType thisOrSuper) {
   QualifiedName name = THIS;
   JvmIdentifiableElement logicalContainer =
       logicalContainerProvider.getNearestLogicalContainer(call);
   if (logicalContainer instanceof JvmMember) {
     JvmDeclaredType thisType = ((JvmMember) logicalContainer).getDeclaringType();
     if (thisType != thisOrSuper) {
       name = SUPER;
     }
   }
   return new SingletonScope(EObjectDescription.create(name, thisOrSuper), IScope.NULLSCOPE);
 }
コード例 #24
0
ファイル: XcssScopeProvider.java プロジェクト: nyao/xtext
 @Override
 protected IScope createLocalVarScope(EObject context, EReference reference, IScope parentScope) {
   if (context instanceof StyleRule) {
     List<Selector> selectors = ((StyleRule) context).getSelectors();
     if (!selectors.isEmpty()) {
       Selector selector = selectors.get(0);
       return new SingletonScope(EObjectDescription.create(THIS, selector), parentScope);
     }
     return IScope.NULLSCOPE;
   }
   return super.createLocalVarScope(context, reference, parentScope);
 }
コード例 #25
0
 public IEObjectDescription spec(final String value) {
   IEObjectDescription _xblockexpression = null;
   {
     final ExampleGroup spec = Specs.exampleGroup("name");
     Pair<String, String> _mappedTo =
         Pair.<String, String>of(SpecResourceDescriptionStrategy.ROOT_SPEC, value);
     Map<String, String> _map = JnarioCollectionLiterals.<String, String>map(_mappedTo);
     IEObjectDescription _create = EObjectDescription.create("name", spec, _map);
     _xblockexpression = (_create);
   }
   return _xblockexpression;
 }
コード例 #26
0
 protected IScope doGetTypeScope(XFeatureCall call, JvmType type) {
   if (call.isPackageFragment()) {
     if (type instanceof JvmDeclaredType) {
       String packageName = ((JvmDeclaredType) type).getPackageName();
       int dot = packageName.indexOf('.');
       if (dot == -1) {
         return new SingletonScope(EObjectDescription.create(packageName, type), IScope.NULLSCOPE);
       } else {
         String firstSegment = packageName.substring(0, dot);
         return new SingletonScope(
             EObjectDescription.create(firstSegment, type), IScope.NULLSCOPE);
       }
     }
     return IScope.NULLSCOPE;
   } else {
     if (type instanceof JvmDeclaredType && ((JvmDeclaredType) type).getDeclaringType() != null) {
       Resource resource = call.eResource();
       if (resource instanceof XtextResource) {
         XImportSection importSection =
             importsConfiguration.getImportSection((XtextResource) resource);
         if (importSection != null) {
           List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations();
           List<IEObjectDescription> descriptions = Lists.newArrayList();
           for (XImportDeclaration importDeclaration : importDeclarations) {
             if (!importDeclaration.isStatic()
                 && !importDeclaration.isWildcard()
                 && !importDeclaration.isExtension()) {
               JvmDeclaredType importedType = importDeclaration.getImportedType();
               if (importedType == type) {
                 String syntax = importsConfiguration.getLegacyImportSyntax(importDeclaration);
                 if (syntax != null /* no node model attached */
                     && syntax.equals(type.getQualifiedName())) {
                   String packageName = importedType.getPackageName();
                   descriptions.add(
                       EObjectDescription.create(
                           syntax.substring(packageName.length() + 1), type));
                 }
               }
               if (EcoreUtil.isAncestor(importedType, type)) {
                 String name = type.getSimpleName();
                 JvmType worker = type;
                 while (worker != importedType) {
                   worker = (JvmType) worker.eContainer();
                   name = worker.getSimpleName() + "$" + name;
                 }
                 descriptions.add(EObjectDescription.create(name, type));
               }
             }
           }
           return new SimpleScope(descriptions);
         }
       }
       return new SingletonScope(
           EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE);
     } else {
       return new SingletonScope(
           EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE);
     }
   }
 }
コード例 #27
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of SPPRef scopes for a {@link SPPoint}
   *
   * @param pt
   * @param ref
   * @return a list of scopes
   */
  public IScope scope_SPPoint_service(SPPoint pt, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    if (pt.getRef() != null) {
      if (pt.getRef() instanceof ActorRef) {
        ActorClass ac = ((ActorRef) pt.getRef()).getType();
        LinkedList<ActorClass> classes = getBaseClasses(ac);
        for (ActorClass a : classes) {
          for (SPPRef spp : a.getIfSPPs()) {
            scopes.add(EObjectDescription.create(spp.getName(), spp));
          }
        }
      } else if (pt.getRef() instanceof SubSystemRef) {
        SubSystemClass ssc = ((SubSystemRef) pt.getRef()).getType();
        for (SPPRef spp : ssc.getIfSPPs()) {
          scopes.add(EObjectDescription.create(spp.getName(), spp));
        }
      }
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #28
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * returns a flat list of SPPRef scopes for a {@link RelaySAPoint}
   *
   * @param pt
   * @param ref
   * @return a list of scopes
   */
  public IScope scope_RelaySAPoint_relay(RelaySAPoint pt, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorClass ac = getActorClass(pt);
    LinkedList<ActorClass> classes = getBaseClasses(ac);
    for (ActorClass a : classes) {
      for (SPPRef spp : a.getIfSPPs()) {
        scopes.add(EObjectDescription.create(spp.getName(), spp));
      }
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
コード例 #29
0
 protected IScope createTypeScope(
     JvmIdentifiableElement context, EReference reference, IScope parentScope) {
   if (context == null) return parentScope;
   if (context.eContainer() instanceof JvmIdentifiableElement) {
     parentScope =
         createTypeScope((JvmIdentifiableElement) context.eContainer(), reference, parentScope);
   }
   if (context instanceof JvmGenericType) {
     JvmGenericType genericType = (JvmGenericType) context;
     List<IEObjectDescription> descriptions = Lists.newArrayList();
     if (genericType.getSimpleName() != null) {
       QualifiedName inferredDeclaringTypeName = QualifiedName.create(genericType.getSimpleName());
       descriptions.add(EObjectDescription.create(inferredDeclaringTypeName, genericType));
     }
     for (JvmTypeParameter param : genericType.getTypeParameters()) {
       if (param.getSimpleName() != null) {
         QualifiedName paramName = QualifiedName.create(param.getSimpleName());
         descriptions.add(EObjectDescription.create(paramName, param));
       }
     }
     if (!descriptions.isEmpty()) return MapBasedScope.createScope(parentScope, descriptions);
   } else if (context instanceof JvmOperation) {
     JvmOperation operation = (JvmOperation) context;
     List<IEObjectDescription> descriptions = null;
     for (JvmTypeParameter param : operation.getTypeParameters()) {
       if (param.getSimpleName() != null) {
         if (descriptions == null) descriptions = Lists.newArrayList();
         QualifiedName paramName = QualifiedName.create(param.getSimpleName());
         descriptions.add(EObjectDescription.create(paramName, param));
       }
     }
     if (descriptions != null && !descriptions.isEmpty())
       return MapBasedScope.createScope(parentScope, descriptions);
   }
   return parentScope;
 }
コード例 #30
0
 public void testErrorMessage_04() {
   EClass eClass = createEClass();
   eClass.setName("EClassName");
   EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
   attribute.setName("Attribute");
   eClass.getEStructuralFeatures().add(attribute);
   IEObjectDescription description =
       EObjectDescription.create(QualifiedName.create(attribute.getName()), attribute);
   String errorMessage =
       helper.getDuplicateNameErrorMessage(
           description,
           EcorePackage.Literals.EATTRIBUTE,
           EcorePackage.Literals.ENAMED_ELEMENT__NAME);
   assertEquals("Duplicate EAttribute 'Attribute' in EClass 'EClassName'", errorMessage);
 }