Пример #1
0
 @Override
 protected List<INode> getLocationNodes(EObject obj) {
   if (obj instanceof XMemberFeatureCall
       || obj instanceof XAssignment
       || obj instanceof XFeatureCall) {
     List<INode> resultNodes = Lists.newArrayList();
     final ICompositeNode startNode = findNodeFor(obj);
     boolean crossRefConsumed = false;
     for (INode child : startNode.getChildren()) {
       if (crossRefConsumed) {
         resultNodes.add(child);
       } else {
         EObject grammarElement = child.getGrammarElement();
         if (grammarElement instanceof CrossReference) {
           // We don't use the grammar access to be more robust against
           // overwriting grammars
           Assignment assignment = GrammarUtil.containingAssignment(grammarElement);
           if (XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE
               .getName()
               .equals(assignment.getFeature())) {
             crossRefConsumed = true;
             resultNodes.add(child);
           }
         }
       }
     }
     if (!resultNodes.isEmpty()) return resultNodes;
   }
   return super.getLocationNodes(obj);
 }
Пример #2
0
 /**
  * @return true, if the parent node could contain cross references to the same semantic element as
  *     the given node.
  */
 protected boolean shouldCheckParentNode(INode node) {
   EObject grammarElement = node.getGrammarElement();
   if (grammarElement instanceof AbstractElement) {
     ICompositeNode parent = node.getParent();
     if (parent != null && !parent.hasDirectSemanticElement()) {
       Assignment assignment = GrammarUtil.containingAssignment(grammarElement);
       return assignment == null;
     }
   }
   return false;
 }
Пример #3
0
 protected EStructuralFeatureAndEObject find(XtextResource resource, int offset) {
   INode leaf =
       NodeModelUtils.findLeafNodeAtOffset(resource.getParseResult().getRootNode(), offset);
   NodeIterator ni = null;
   while (ni == null || ni.hasNext()) {
     INode next = ni == null ? leaf : ni.next();
     if (ni == null) ni = new NodeIterator(leaf);
     EObject object = NodeModelUtils.findActualSemanticObjectFor(next);
     INode current = next;
     do {
       Assignment ass = GrammarUtil.containingAssignment(current.getGrammarElement());
       if (ass != null) {
         EStructuralFeature feat = object.eClass().getEStructuralFeature(ass.getFeature());
         if (feat != null && matches(object, feat)) return create(object, feat);
       }
       current = current.getParent();
     } while (current != null && object == NodeModelUtils.findActualSemanticObjectFor(current));
   }
   throw new RuntimeException("No EStructuralFeature found at offset " + offset);
 }
 public boolean isUnassignedRuleCall(final RuleCall c) {
   boolean _xblockexpression = false;
   {
     boolean _isEObjectRuleCall = GrammarUtil.isEObjectRuleCall(c);
     if (_isEObjectRuleCall) {
       return false;
     }
     final Assignment ass = GrammarUtil.containingAssignment(c);
     boolean _or = false;
     boolean _equals = Objects.equal(ass, null);
     if (_equals) {
       _or = true;
     } else {
       boolean _isBooleanAssignment = GrammarUtil.isBooleanAssignment(ass);
       _or = _isBooleanAssignment;
     }
     _xblockexpression = _or;
   }
   return _xblockexpression;
 }