1 19 20 package org.netbeans.lib.lexer.inc; 21 22 import java.util.Set ; 23 import org.netbeans.api.lexer.InputAttributes; 24 import org.netbeans.api.lexer.LanguagePath; 25 import org.netbeans.api.lexer.TokenId; 26 import org.netbeans.lib.lexer.EmbeddingContainer; 27 import org.netbeans.lib.lexer.TokenHierarchyOperation; 28 import org.netbeans.lib.lexer.TokenList; 29 import org.netbeans.lib.lexer.token.AbstractToken; 30 31 32 38 39 public final class StandaloneTokenList<T extends TokenId> implements TokenList<T> { 40 41 private char[] tokenText; 42 43 private LanguagePath languagePath; 44 45 public StandaloneTokenList(LanguagePath languagePath, char[] tokenText) { 46 this.languagePath = languagePath; 47 this.tokenText = tokenText; 48 } 49 50 public LanguagePath languagePath() { 51 return languagePath; 52 } 53 54 public Object tokenOrEmbeddingContainer(int index) { 55 throw new IllegalStateException ("Not expected to be called"); } 57 58 public AbstractToken<T> replaceFlyToken( 59 int index, AbstractToken<T> flyToken, int offset) { 60 throw new IllegalStateException ("Not expected to be called"); } 62 63 public int lookahead(int index) { 64 return -1; 65 } 66 67 public Object state(int index) { 68 return null; 69 } 70 71 public int tokenOffset(int index) { 72 throw new IllegalStateException ("Not expected to be called"); } 74 75 public int tokenCount() { 76 return 1; 77 } 78 79 public int tokenCountCurrent() { 80 return 1; 81 } 82 83 public int modCount() { 84 return -1; 85 } 86 87 public int childTokenOffset(int rawOffset) { 88 return rawOffset; 90 } 91 92 public char childTokenCharAt(int rawOffset, int index) { 93 return tokenText[index]; 94 } 95 96 public void wrapToken(int index, EmbeddingContainer embeddingContainer) { 97 throw new IllegalStateException ("Branching of standalone tokens not supported"); } 99 100 public TokenList<? extends TokenId> root() { 101 return this; 102 } 103 104 public TokenHierarchyOperation<?,? extends TokenId> tokenHierarchyOperation() { 105 return null; 106 } 107 108 public InputAttributes inputAttributes() { 109 throw new IllegalStateException ("Not expected to be called"); } 111 112 public boolean isContinuous() { 113 return true; 114 } 115 116 public Set <T> skipTokenIds() { 117 return null; 118 } 119 120 } 121 | Popular Tags |