微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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(),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(),sqlHighlightingConfiguration.ParaM_TOKEN);
        } else if (semanticElement instanceof XExpr) {
            acceptor.addPosition(nextLeaf.getoffset(),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,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(),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(),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,COMMENT_SINGLE);

            if (ge.getName().equalsIgnoreCase("ML_COMMENT"))
                setStyle(acceptor,COMMENT_MULTI);
        } else if (node.getGrammarElement() != null && node.getGrammarElement() instanceof Keyword) {
            Keyword k = (Keyword) node.getGrammarElement();
            if (ALL_KEYWORDS.contains(k.getValue())) {
                setStyle( acceptor,KEYWORD);
            } else if (ALL_SYMBOLS.contains(k.getValue())) {
                setStyle( acceptor,SYMBOL);
            } else if (ALL_RESERVED_WORDS.contains(k.getValue())) {
                setStyle( acceptor,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,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,STRING);
                    } else if (rc.getRule().getName().equals("INT_LIteraL")) {
                        setStyle( acceptor,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(),style );
    }
}
项目:jason-eclipse-plugin    文件AslHighlightingCalculator.java   
private void setStyle(IHighlightedPositionAcceptor acceptor,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(),JavaJRExpressionHighlightingConfiguration.STRING_ID);
            }
            else if(semanticElement instanceof JRParameterObj){
                acceptor.addPosition(nextLeaf.getoffset(),JavaJRExpressionHighlightingConfiguration.ParaM_TOKEN);
            }
            else if(semanticElement instanceof JRVariableObj){
                System.out.println(nextLeaf.getGrammarElement());
                acceptor.addPosition(nextLeaf.getoffset(),JavaJRExpressionHighlightingConfiguration.VARIABLE_TOKEN);
            }
            else if(semanticElement instanceof JRFieldobj){
                acceptor.addPosition(nextLeaf.getoffset(),JavaJRExpressionHighlightingConfiguration.FIELD_TOKEN);
            }
            else if(semanticElement instanceof JRResourceBundleKeyObj) {
                acceptor.addPosition(nextLeaf.getoffset(),JavaJRExpressionHighlightingConfiguration.RESOURCE_BUNDLE_KEY);
            }
            else if(semanticElement instanceof FullMethodName){
                if(JRExpressionsModelUtil.isFunctionLibrary((FullMethodName)semanticElement)){
                    acceptor.addPosition(nextLeaf.getoffset(),JavaJRExpressionHighlightingConfiguration.FUNCTION_METHOD);
                }
            }
            else if(isNumberElement(semanticElement)){
                acceptor.addPosition(nextLeaf.getoffset(),DefaultHighlightingConfiguration.NUMBER_ID);
            }
        }
    }
}
项目:EASyProducer    文件VilHighlightingCalculator.java   
@Override
public void provideHighlightingFor(XtextResource resource,IHighlightedPositionAcceptor acceptor) {
    if (hasRootNode(resource)) {
        provideStringPatternHighlight(resource.getParseResult().getRootNode(),acceptor);
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。