Package org.netbeans.modules.php.nette.lexer.syntax

Examples of org.netbeans.modules.php.nette.lexer.syntax.Syntax


      return tokenCache.get(t);
    }

    InputAttributes attrs = new InputAttributes();

    Syntax syntax = (Syntax) t.getProperty("syntax");

    Language<LatteTokenId> language = LatteTokenId.language(syntax);

    TokenHierarchy<CharSequence> th2 = TokenHierarchy.create(t.text(), true, language, null, attrs);
    TokenSequence<LatteTokenId> sequence = th2.tokenSequence(language);
View Full Code Here


    }

    if(string.equals("n")) {
      autoShowText = string;
    } else {
      Syntax syntax = getSyntax(jtc);
      if(string.length() == 1 && Syntax.CHARS.indexOf(string) != -1) {
        autoShowText = (autoShowText == null ? "" : autoShowText);

        if(syntax.startsWith(autoShowText + string)) {
          if(syntax.isOpening(autoShowText + string)) {
            return COMPLETION_QUERY_TYPE;
          } else {
            autoShowText += string;
          }
        } else {
View Full Code Here

  private Syntax getSyntax(JTextComponent jtc) {
    TokenSequence<LatteTopTokenId> sequence = LexUtils.getTopSequence(jtc.getDocument());
    sequence.move(jtc.getCaretPosition());

    Syntax syntax = LatteSyntax.getInstance();

    if(sequence.moveNext() || sequence.movePrevious()) {
      Token<LatteTopTokenId> token = sequence.token();
      if(token != null) {
        Syntax s = (Syntax) token.getProperty("syntax");
        if(s != null) {
          syntax = s;
        }
      }
View Full Code Here

public class OutsideMacroResolver {

  public static void resolve(CompletionResultSet completionResultSet, TokenSequence<LatteTopTokenId> sequence,
      Document document, int caretOffset, List<LatteMacro> endMacros) {

    Syntax syntax = getSyntax(sequence);

    String filter = getFilter(document, caretOffset, syntax);
    int startOffset = caretOffset - filter.length();

    if(filter.equals("")) {
View Full Code Here

    return filter;
  }

  private static Syntax getSyntax(TokenSequence<LatteTopTokenId> sequence) {
    Syntax syntax = LatteSyntax.getInstance();

    Token<LatteTopTokenId> token = sequence.token();
    if(token != null) {
      Syntax s = (Syntax) token.getProperty("syntax");
      if(s != null) {
        syntax = s;
      }
    }
    return syntax;
View Full Code Here

                //check whether the searched position doesn't overlap the token boundaries
                return null;
            }
            Token<LatteTopTokenId> t = ts.token();
            if(t.id() == LatteTopTokenId.LATTE) {              // process only latte
        Syntax syntax = (Syntax) t.getProperty("syntax");

        TokenSequence<LatteTokenId> ts2 = LexUtils.getSequence(t);

        /*ts2.move(searchOffset-ts.offset());
        matches.addAll(findBrackets(ts2));*/

                if(!syntax.isOpening(t.text().toString())) {        // process only macros
                    return null;
                }

        int LDlength = 1;
        ts2.moveStart();
                int i = 0;                        // used to check end macro slash position
                while(ts2.moveNext() && i < 3) {
                    Token<LatteTokenId> t2 = ts2.token();
                    // macro has name
          if(t2.id() == LatteTokenId.LD) {
            LDlength = t2.toString().trim().length();
          }
                    if(t2.id() == LatteTokenId.MACRO) {                // it has macro name
                        macroName = t2.toString();
                        mStart = ts.offset();
                        mLength = t.length();

                        /*Collections.addAll(matches,*/ return new int[] {
                            ts.offset(), ts.offset() + t.length(),                  //whole area
                            ts.offset(), ts.offset() + ts2.offset() + t2.length()//left delimiter + macro
                            ts.offset() + t.length() - syntax.closing().length(), ts.offset() + t.length()  //right delimiter
                        }/*)*/;
            //return matches.toArray();
                    }
                    if(t2.id() == LatteTokenId.END_SLASH && i == 1) {          // it is end macro
                        isEndMacro = true;                      // set bool to true!
                    }
                    i++;
                }
                // macro doesn't have name, hi-light just delimiters
                return new int[] {
                    ts.offset(), ts.offset() + t.length(),                          //whole area
                    ts.offset(), ts.offset() + LDlength, //left delimiter
                    ts.offset() + t.length() - syntax.closing().length(), ts.offset() + t.length()          //right delimiter
                };
            }
        }

        return null;
View Full Code Here

      // finds start/friend/end macro
            while(isEndMacro ? ts.movePrevious() : ts.moveNext()) {
                Token<LatteTopTokenId> t = ts.token();
                if(t.id() == LatteTopTokenId.LATTE) {    // process only latte
          Syntax syntax = (Syntax) t.getProperty("syntax");

          if(!syntax.isOpening(t.text().toString())) {    // process only macros
                        continue;
                    }
          // go through inside macro tokens
                    TokenSequence<LatteTokenId> ts2 = LexUtils.getSequence(t);
                    ts2.moveStart();

                    boolean isEndMacro2 = false;          // is parsed macro end macro?
                    int i = 0;                    // used for checking end macro slash position
                    while(ts2.moveNext() && i < 3) {
                        Token<LatteTokenId> t2 = ts2.token();
                        if(t2.id() == LatteTokenId.MACRO) {            // macro name token reached
              String macroName2 = t2.text().toString();
                            if(embeddedMacros == 0) {              // only if we are at the same nesting level
                                if((pairMacroNames.contains(macroName2) && isEndMacro != isEndMacro2)
                                        || friends.contains(macroName2)) {      // it is start/friend/end macro
                                    return new int[] {
                      ts.offset(), ts.offset() + ts2.offset() + t2.length(), // hi-light {macro
                      ts.offset() + t.length() - syntax.closing().length(), ts.offset() + t.length() // hi-light }
                    };
                                }
                            }
              // it is not a macro we want
                            LatteMacro m = MacroDefinitions.getMacro(macroName2);
View Full Code Here

TOP

Related Classes of org.netbeans.modules.php.nette.lexer.syntax.Syntax

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.