1 19 20 package org.netbeans.lib.lexer.batch; 21 22 import java.io.Reader ; 23 import java.util.Set ; 24 import org.netbeans.api.lexer.Language; 25 import org.netbeans.lib.lexer.LexerInputOperation; 26 import org.netbeans.api.lexer.InputAttributes; 27 import org.netbeans.api.lexer.TokenId; 28 import org.netbeans.lib.lexer.TokenHierarchyOperation; 29 30 31 39 40 public final class CopyTextTokenList<T extends TokenId> extends BatchTokenList<T> { 41 42 43 private final Object input; 44 45 public CopyTextTokenList(TokenHierarchyOperation<?,T> tokenHierarchyOperation, Reader inputReader, 46 Language<T> language, Set <T> skipTokenIds, InputAttributes inputAttributes) { 47 super(tokenHierarchyOperation, language, skipTokenIds, inputAttributes); 48 this.input = inputReader; 49 } 50 51 public CopyTextTokenList(TokenHierarchyOperation<?,T> tokenHierarchyOperation, CharSequence inputText, 52 Language<T> language, Set <T> skipTokenIds, InputAttributes inputAttributes) { 53 super(tokenHierarchyOperation, language, skipTokenIds, inputAttributes); 54 this.input = inputText; 55 } 56 57 public int childTokenOffset(int rawOffset) { 58 throwShouldNeverBeCalled(); 60 return 0; } 62 63 public char childTokenCharAt(int rawOffset, int index) { 64 throwShouldNeverBeCalled(); 66 return ' '; } 68 69 private void throwShouldNeverBeCalled() { 70 throw new IllegalStateException ("Should never be called"); } 72 73 protected LexerInputOperation<T> createLexerInputOperation() { 74 return (input instanceof Reader ) 75 ? new SkimLexerInputOperation<T>(this, (Reader )input) 76 : new SkimLexerInputOperation<T>(this, (CharSequence )input); 77 } 78 79 } 80 | Popular Tags |