Java 类org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor 实例源码

项目:dsl-devkit    文件:CheckHighlightingCalculator.java   
@Override
protected void highlightSpecialIdentifiers(final IHighlightedPositionAcceptor acceptor, final ICompositeNode root) {
  TerminalRule idRule = grammarAccess.getIDRule();

  for (ILeafNode leaf : root.getLeafNodes()) {
    if (commentProvider.isJavaDocComment(leaf)) {
      // not really a special identifier, but we don't want to iterate over the leaf nodes twice, do we?
      acceptor.addPosition(leaf.getOffset(), leaf.getLength(), CheckHighlightingConfiguration.JAVADOC_ID);
    } else if (!leaf.isHidden()) {
      if (leaf.getGrammarElement() instanceof Keyword) {
        // Check if it is a keyword used as an identifier.
        ParserRule rule = GrammarUtil.containingParserRule(leaf.getGrammarElement());
        if (FEATURE_CALL_ID_RULE_NAME.equals(rule.getName())) {
          acceptor.addPosition(leaf.getOffset(), leaf.getLength(), DefaultHighlightingConfiguration.DEFAULT_ID);
        }
      } else {
        highlightSpecialIdentifiers(leaf, acceptor, idRule);
      }
    }
  }
}
项目:PDFReporter-Studio    文件:SqlHighlightingCalculator.java   
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
    if (resource == null)
        return;
    IParseResult parseResult = resource.getParseResult();
    if (parseResult == null)
        return;
    INode root = parseResult.getRootNode();
    Iterator<ILeafNode> leafNodesIt = root.getLeafNodes().iterator();

    while (leafNodesIt.hasNext()) {
        ILeafNode nextLeaf = leafNodesIt.next();
        EObject semanticElement = nextLeaf.getSemanticElement();
        if (semanticElement instanceof POperand) {
            acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), SqlHighlightingConfiguration.PARAM_TOKEN);
        } else if (semanticElement instanceof ExpOperand) {
            acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), SqlHighlightingConfiguration.PARAM_TOKEN);
        } else if (semanticElement instanceof XExpr) {
            acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), SqlHighlightingConfiguration.XEXPRESSION_TOKEN);
        }
    }
}
项目:jason-eclipse-plugin    文件:AslHighlightingCalculator.java   
private void setStyles( IHighlightedPositionAcceptor acceptor, BidiIterator<INode> it, String...styles )
{
    for( String s : styles )
    {
        if( !it.hasNext() ) return;
        INode n = skipWhiteSpace( acceptor, it );
        if( n != null && s != null ) acceptor.addPosition( n.getOffset(), n.getLength(), s );
    }
}
项目:jason-eclipse-plugin    文件:AslHighlightingCalculator.java   
private INode skipWhiteSpace( IHighlightedPositionAcceptor acceptor, BidiIterator<INode> it )
{
    INode n = null;

    while ( it.hasNext() && ( n = it.next() ).getClass() == HiddenLeafNode.class )
        processHiddenNode( acceptor, (HiddenLeafNode)n );
    return n;
}
项目:jason-eclipse-plugin    文件:AslHighlightingCalculator.java   
private void processHiddenNode( IHighlightedPositionAcceptor acceptor, HiddenLeafNode node )
{
    if( node.getGrammarElement() instanceof TerminalRule )
    {
        TerminalRule ge = (TerminalRule) node.getGrammarElement();

        if (ge.getName().equalsIgnoreCase("SL_COMMENT"))
            setStyle(acceptor, node, COMMENT_SINGLE);

        if (ge.getName().equalsIgnoreCase("ML_COMMENT"))
            setStyle(acceptor, node, COMMENT_MULTI);
    }
}
项目:dsl-devkit    文件:SemanticHighlightingCalculator.java   
/** {@inheritDoc} */
public void provideHighlightingFor(final XtextResource resource, final IHighlightedPositionAcceptor acceptor) {
  if (resource == null) {
    return;
  }
  Iterator<EObject> iter = EcoreUtil.getAllContents(resource, true);
  while (iter.hasNext()) {
    EObject current = iter.next();

    if (current instanceof ConfiguredCheck && ((ConfiguredCheck) current).getSeverity().equals(SeverityKind.IGNORE)) {
      INode node = getFirstParseTreeNode(current, CheckcfgPackage.Literals.CONFIGURED_CHECK__CHECK);
      highlightNode(node, SemanticHighlightingConfiguration.DISABLED_VALUE_ID, acceptor);
    }
  }
}
项目:dsl-devkit    文件:SemanticHighlightingCalculator.java   
/**
 * Highlights a given parse tree node.
 * 
 * @param node
 *          the node from the parse tree
 * @param id
 *          the id of the configuration
 * @param acceptor
 *          the acceptor
 */
private void highlightNode(final INode node, final String id, final IHighlightedPositionAcceptor acceptor) {
  if (node == null) {
    return;
  }
  if (node instanceof ILeafNode) {
    acceptor.addPosition(node.getOffset(), node.getLength(), id);
  } else {
    for (ILeafNode leaf : node.getLeafNodes()) {
      if (!leaf.isHidden()) {
        acceptor.addPosition(leaf.getOffset(), leaf.getLength(), id);
      }
    }
  }
}
项目:Gauge-Eclipse    文件:SpecHighlightingCalculator.java   
@Override
public void provideHighlightingFor(XtextResource resource,
        IHighlightedPositionAcceptor acceptor) {

    INode root = resource.getParseResult().getRootNode();
       BidiTreeIterator<INode> it = root.getAsTreeIterable().iterator();
       while( it.hasNext() )
       {
        INode node = it.next();
        String nodeType="";
        EObject semanticElement = node.getSemanticElement();
        if( node instanceof CompositeNodeWithSemanticElement)
        {
            if(semanticElement instanceof Spec )
                nodeType=SpecHighlightingConfiguration.SPEC;
            else if( semanticElement instanceof Scenario )
                nodeType=SpecHighlightingConfiguration.SCENARIO;
            else if( semanticElement instanceof Tags)
                nodeType=SpecHighlightingConfiguration.TAGS;
            else if( semanticElement instanceof StaticParam )
                nodeType=SpecHighlightingConfiguration.STATIC_PARAM;
            else if( semanticElement instanceof DynamicParam)
                nodeType=SpecHighlightingConfiguration.DYNAMIC_PARAM;
            else if( semanticElement instanceof Step )
                nodeType=SpecHighlightingConfiguration.STEP;
            else
                nodeType=SpecHighlightingConfiguration.DEFAULT;
        }
        acceptor.addPosition(node.getOffset(), node.getLength(), nodeType);
       }
}
项目:EASyProducer    文件:VilHighlightingCalculator.java   
/**
 * Provide the highlighting of the referred variables. This includes the determination of all
 * strings that match the regular expressions "\\$\\s*\\{\\s*.*?\\s*\\}" or "\\$\\s*.*?/".
 * By default, referred variables will be highlighted in bold. This highlighting may be customized
 * by the user using the VIL/VTL preference page in Eclipse
 *  
 * @param rootNode the root node of the parse tree which holds the text of the entire VIL-file.
 * @param acceptor the acceptor for adding the positions that should be highlighted individually.
 */
private void provideStringPatternHighlight(INode rootNode, IHighlightedPositionAcceptor acceptor) {
    String fullText = rootNode.getText();
    Matcher matcher = Pattern.compile(COMPLEX_HIGHLIGHT_REGEX).matcher(fullText);
    while (matcher.find()) {
        acceptor.addPosition(matcher.start(),  matcher.end() - matcher.start(), VilHighlightingConfiguration.REFERRED_VARIABLES);
    }
    matcher = Pattern.compile(SIMPLE_HIGHLIGHT_REGEX).matcher(fullText);
    while (matcher.find()) {
        acceptor.addPosition(matcher.start(),  matcher.end() - matcher.start() - 1, VilHighlightingConfiguration.REFERRED_VARIABLES);
    }
}
项目:k3    文件:ExpHighlightingCalculator.java   
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor ) {
        if(resource == null || resource.getParseResult()==null) return;

//      INode root = resource.getParseResult().getRootNode();
//      BidiTreeIterator<INode> it = root.getAsTreeIterable().iterator();

//      while(it.hasNext()) {
//          INode node = it.next();
//          if(node instanceof CompositeNodeWithSemanticElement && node.getSemanticElement() instanceof OperateurBinaire) {
//              OperateurBinaire bin = (OperateurBinaire) node.getSemanticElement();
//              acceptor.addPosition(0, 1, ExpHighlightingConfiguration.EXP_ELT);
//              provideHighlightingFor()
//          }
//      }
    }
项目:jason-eclipse-plugin    文件:Mas2jHighlightingCalculator.java   
public void provideHighlightingFor( XtextResource resource, IHighlightedPositionAcceptor acceptor )
{
    if ( resource == null || resource.getParseResult() == null ) return;

    INode root = resource.getParseResult().getRootNode();
    BidiTreeIterator<INode> it = root.getAsTreeIterable().iterator();
    while (it.hasNext()) {
        INode node = it.next();
        if (node == null) continue;

        if (node instanceof HiddenLeafNode && node.getGrammarElement() instanceof TerminalRuleImpl) {
            TerminalRuleImpl ge = (TerminalRuleImpl) node.getGrammarElement();

            if (ge.getName().equalsIgnoreCase("SL_COMMENT"))
                setStyle(acceptor, node, COMMENT_SINGLE);

            if (ge.getName().equalsIgnoreCase("ML_COMMENT"))
                setStyle(acceptor, node, COMMENT_MULTI);
        } else if (node.getGrammarElement() != null && node.getGrammarElement() instanceof Keyword) {
            Keyword k = (Keyword) node.getGrammarElement();
            if (ALL_KEYWORDS.contains(k.getValue())) {
                setStyle( acceptor, node, KEYWORD);
            } else if (ALL_SYMBOLS.contains(k.getValue())) {
                setStyle( acceptor, node, SYMBOL);
            } else if (ALL_RESERVED_WORDS.contains(k.getValue())) {
                setStyle( acceptor, node, RESERVED_WORD);
            }
        } else if (node instanceof LeafNode && node.getSemanticElement() != null) {
            if (node.getSemanticElement() instanceof ClsDef) {
                ClsDef cls = (ClsDef) node.getSemanticElement();
                if (cls.getInfrastructure() != null && ALL_PREDEFINED_PARAMS.contains(cls.getInfrastructure())) {
                    setStyle( acceptor, node, PREDEFINED_PARAM);
                }
            } else if (node.getGrammarElement() != null) {
                if (node.getGrammarElement() instanceof RuleCall) {
                    RuleCall rc = (RuleCall) node.getGrammarElement();

                    if (rc.getRule().getName().equals("STRING")) {
                        setStyle( acceptor, node, STRING);
                    } else if (rc.getRule().getName().equals("INT_LITERAL")) {
                        setStyle( acceptor, node, NUMBER);
                    } else {
                        //System.out.println("" + node.getOffset() + " " + node.getLength() + node.toString() + " ## " + node.getGrammarElement().toString() + " ## " + node.getSemanticElement().toString() + " // " + rc.getRule().getName());
                    }
                }
            }
        } else if (node.getGrammarElement() != null && node.getSemanticElement() != null) {
            //System.out.println("" + node.getOffset() + " " + node.getLength() + node.toString() + " ## " + node.getGrammarElement().toString() + " ## " + node.getSemanticElement().toString());
        }
    }
}
项目:jason-eclipse-plugin    文件:Mas2jHighlightingCalculator.java   
private void setStyle(IHighlightedPositionAcceptor acceptor, INode n, String style) {
    if (n != null) {
        acceptor.addPosition( n.getOffset(), n.getLength(), style );
    }
}
项目:jason-eclipse-plugin    文件:AslHighlightingCalculator.java   
private void setStyle(IHighlightedPositionAcceptor acceptor, INode n, String style) {
    if (n != null) {
        acceptor.addPosition( n.getOffset(), n.getLength(), style );
    }
}
项目:bts    文件:BTSSemanticHighlightingCalculator.java   
public void provideHighlightingFor(XtextResource resource,
            IHighlightedPositionAcceptor acceptor) {
        for (Iterator<EObject> contents = resource.getAllContents(); contents
                .hasNext();) {
            EObject element = contents.next();
            if (element instanceof Word) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.WORD__WCHAR, acceptor);
            } else if (element instanceof Sentence) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.SENTENCE__ITEMS, acceptor);
//          } else if (element instanceof Marker) {
//              highlightAsDataType(element,
//                      EgyDslPackage.Literals.MARKER__NAME, acceptor);
            } else if (element instanceof Case) {
                highlightAsDataType(element, EgyDslPackage.Literals.CASE__NAME,
                        acceptor);
            } else if (element instanceof Ambivalence) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.AMBIVALENCE__CASES, acceptor);
            }
            //
            else if (element instanceof Expanded) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.EXPANDED__WCHAR, acceptor);
            } else if (element instanceof Emendation) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.EMENDATION__WCHAR, acceptor);
            } else if (element instanceof DisputableReading) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.DISPUTABLE_READING__WCHAR,
                        acceptor);
            } else if (element instanceof Lacuna) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.LACUNA__WCHAR, acceptor);
            } else if (element instanceof Deletion) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.DELETION__WCHAR, acceptor);
            } else if (element instanceof ExpandedColumn) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.EXPANDED_COLUMN__WCHAR, acceptor);
            } else if (element instanceof Rasur) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.RASUR__WCHAR, acceptor);
            } else if (element instanceof AncientExpanded) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.ANCIENT_EXPANDED__WCHAR,
                        acceptor);
            } else if (element instanceof RestorationOverRasur) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.RESTORATION_OVER_RASUR__WCHAR,
                        acceptor);
            } else if (element instanceof PartialDestruction) {
                highlightAsDataType(element,
                        EgyDslPackage.Literals.PARTIAL_DESTRUCTION__WCHAR,
                        acceptor);
            } 
//          else if (element instanceof Destruction) {
//              highlightAsDataType(element,
//                      EgyDslPackage.Literals.DESTRUCTION__COMMENT, acceptor);
//          }
        }
    }
项目:PDFReporter-Studio    文件:JavaJRExpressionHighlightingCalculator.java   
public void provideHighlightingFor(XtextResource resource,
        IHighlightedPositionAcceptor acceptor) {
    if (resource == null)
        return;
    IParseResult parseResult = resource.getParseResult();
    if(parseResult==null)
        return;
    INode root = parseResult.getRootNode();
    Iterator<ILeafNode> leafNodesIt = root.getLeafNodes().iterator();

    while (leafNodesIt.hasNext()){
        ILeafNode nextLeaf = leafNodesIt.next();
        EObject semanticElement = nextLeaf.getSemanticElement();
        EObject grammarElement = nextLeaf.getGrammarElement();
        if(!isHiddenToken(grammarElement)) {
            if(semanticElement instanceof StringLiteral){
                acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), JavaJRExpressionHighlightingConfiguration.STRING_ID);
            }
            else if(semanticElement instanceof JRParameterObj){
                acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), JavaJRExpressionHighlightingConfiguration.PARAM_TOKEN);
            }
            else if(semanticElement instanceof JRVariableObj){
                System.out.println(nextLeaf.getGrammarElement());
                acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), JavaJRExpressionHighlightingConfiguration.VARIABLE_TOKEN);
            }
            else if(semanticElement instanceof JRFieldObj){
                acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), JavaJRExpressionHighlightingConfiguration.FIELD_TOKEN);
            }
            else if(semanticElement instanceof JRResourceBundleKeyObj) {
                acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), JavaJRExpressionHighlightingConfiguration.RESOURCE_BUNDLE_KEY);
            }
            else if(semanticElement instanceof FullMethodName){
                if(JRExpressionsModelUtil.isFunctionLibrary((FullMethodName)semanticElement)){
                    acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), JavaJRExpressionHighlightingConfiguration.FUNCTION_METHOD);
                }
            }
            else if(isNumberElement(semanticElement)){
                acceptor.addPosition(nextLeaf.getOffset(), nextLeaf.getLength(), DefaultHighlightingConfiguration.NUMBER_ID);
            }
        }
    }
}
项目:EASyProducer    文件:VilHighlightingCalculator.java   
@Override
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
    if (hasRootNode(resource)) {
        provideStringPatternHighlight(resource.getParseResult().getRootNode(), acceptor);
    }
}