private boolean isIgnored(JvmType type, ITextRegion refRegion) {
   IParseResult parseResult = getResource().getParseResult();
   if (parseResult == null) {
     return false;
   }
   String completeText = parseResult.getRootNode().getText();
   CharSequence refText =
       completeText.subSequence(
           refRegion.getOffset(), refRegion.getOffset() + refRegion.getLength());
   return type.getQualifiedName().equals(refText);
 }
 protected void highlightSpecialIdentifiers(
     ILeafNode leafNode, IHighlightedPositionAcceptor acceptor, TerminalRule idRule) {
   ITextRegion leafRegion = leafNode.getTextRegion();
   if (idLengthsToHighlight.get(leafRegion.getLength())) {
     EObject element = leafNode.getGrammarElement();
     if (element == idRule
         || (element instanceof RuleCall && ((RuleCall) element).getRule() == idRule)) {
       String text = leafNode.getText();
       String highlightingID = highlightedIdentifiers.get(text);
       if (highlightingID != null) {
         acceptor.addPosition(leafRegion.getOffset(), leafRegion.getLength(), highlightingID);
       }
     }
   }
 }
Exemplo n.º 3
0
 protected void addSectionToAppend(IAcceptor<ReplaceRegion> acceptor) {
   StringBuilder importDeclarationsToAppend = getImportDeclarationsToAppend();
   if (importDeclarationsToAppend.length() == 0) return;
   importRegion = regionUtil.addLeadingWhitespace(importRegion, resource);
   importRegion = regionUtil.addTrailingSingleWhitespace(importRegion, lineSeparator, resource);
   int insertOffset = importRegion.getOffset() + importRegion.getLength();
   if (insertOffset != 0 && originalImportDeclarations.isEmpty())
     importDeclarationsToAppend.insert(0, lineSeparator);
   importDeclarationsToAppend.append(lineSeparator);
   int insertLength = -importRegion.getLength();
   insertLength += regionUtil.addTrailingWhitespace(importRegion, resource).getLength();
   ReplaceRegion appendDeclarations =
       new ReplaceRegion(
           new TextRegion(insertOffset, insertLength), importDeclarationsToAppend.toString());
   acceptor.accept(appendDeclarations);
 }
Exemplo n.º 4
0
 @Override
 protected ITextRegion getLocationOfCrossReference(
     EObject owner, EReference reference, int indexInList, boolean isSignificant) {
   if (owner instanceof XMemberFeatureCall
       && reference == XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE
       && ((XMemberFeatureCall) owner).isTypeLiteral()) {
     List<INode> featureNodes = NodeModelUtils.findNodesForFeature(owner, reference);
     ITextRegion result = ITextRegion.EMPTY_REGION;
     if (!featureNodes.isEmpty()) {
       INode featureNode = featureNodes.get(0);
       result = result.merge(toZeroBasedRegion(featureNode.getTextRegionWithLineInformation()));
       List<INode> targetNodes =
           NodeModelUtils.findNodesForFeature(
               owner, XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET);
       if (!targetNodes.isEmpty()) {
         INode targetNode = targetNodes.get(0);
         result = result.merge(toZeroBasedRegion(targetNode.getTextRegionWithLineInformation()));
       }
       return result;
     }
   }
   return super.getLocationOfCrossReference(owner, reference, indexInList, isSignificant);
 }
Exemplo n.º 5
0
 @Override
 public TextRange getRangeToHighlightInElement() {
   final ArrayList<?> _cacheKey = CollectionLiterals.newArrayList();
   final TextRange _result;
   synchronized (_createCache_getRangeToHighlightInElement) {
     if (_createCache_getRangeToHighlightInElement.containsKey(_cacheKey)) {
       return _createCache_getRangeToHighlightInElement.get(_cacheKey);
     }
     TextRange _xblockexpression = null;
     {
       ICrossReferenceDescription _crossReferenceDescription = this.getCrossReferenceDescription();
       final ITextRegion textRegion = _crossReferenceDescription.getTextRegion();
       int _offset = textRegion.getOffset();
       TextRange _textRange = this.myElement.getTextRange();
       int _startOffset = _textRange.getStartOffset();
       int startOffset = (_offset - _startOffset);
       TextRange _xifexpression = null;
       if ((startOffset < 0)) {
         _xifexpression = this.getRangeInElement();
       } else {
         TextRange _xblockexpression_1 = null;
         {
           int _length = textRegion.getLength();
           final int endOffset = (startOffset + _length);
           _xblockexpression_1 = new TextRange(startOffset, endOffset);
         }
         _xifexpression = _xblockexpression_1;
       }
       _xblockexpression = _xifexpression;
     }
     _result = _xblockexpression;
     _createCache_getRangeToHighlightInElement.put(_cacheKey, _result);
   }
   _init_getRangeToHighlightInElement(_result);
   return _result;
 }
 protected void highlightNumberLiterals(
     XNumberLiteral literal, IHighlightedPositionAcceptor acceptor) {
   ICompositeNode node = NodeModelUtils.findActualNodeFor(literal);
   ITextRegion textRegion = node.getTextRegion();
   acceptor.addPosition(textRegion.getOffset(), textRegion.getLength(), NUMBER_ID);
 }