boolean eof = zzRefill(); { start = zzMarkedPos-1; yybegin(E4X_INATTR_SINGLE); { start = zzMarkedPos-1; yybegin(E4X_INATTR_DOUBLE); { addToken(Token.ERROR_NUMBER_FORMAT); { addToken(Token.RESERVED_WORD_2); { addToken(start,zzStartRead-1, Token.MARKUP_DTD); addEndToken(e4x_inInternalDtd ? INTERNAL_E4X_DTD_INTERNAL : INTERNAL_E4X_DTD); return firstToken; { int type = validJSString ? Token.LITERAL_BACKQUOTE : Token.ERROR_STRING_DOUBLE; addToken(start,zzStartRead, type); yybegin(YYINITIAL); addToken(start,zzStartRead, Token.LITERAL_CHAR); addEndToken(INTERNAL_IN_JS_CHAR_VALID); addToken(start,zzStartRead, Token.ERROR_CHAR); addEndToken(INTERNAL_IN_JS_CHAR_INVALID); { addToken(Token.WHITESPACE); { addToken(start,zzStartRead-1, Token.COMMENT_MULTILINE); addEndToken(INTERNAL_IN_JS_MLC); return firstToken; int operatorLen = yycharat(0)=='+' ? 2 : 1; int yylen = yylength(); // Cache before first addToken() invalidates it addToken(zzStartRead,zzStartRead+operatorLen-1, Token.OPERATOR); if (yylen>operatorLen+1) {
public Token getTokenList(Segment text, int initialTokenType, int startOffset) { resetTokenList(); this.offsetShift = -text.offset + startOffset; validJSString = true; setLanguageIndex(languageIndex); start = text.offset; s = text; try { yyreset(zzReader); yybegin(state); return yylex(); } catch (IOException ioe) { ioe.printStackTrace();
@Test public void testJS_api_isE4XSupported() { Assert.assertFalse(JavaScriptTokenMaker.isE4xSupported()); JavaScriptTokenMaker.setE4xSupported(true); Assert.assertTrue(JavaScriptTokenMaker.isE4xSupported()); }
@After public void tearDown() { JavaScriptTokenMaker.setE4xSupported(false); JavaScriptTokenMaker.setJavaScriptVersion("1.7"); }
resetTokenList(); addToken(text, currentTokenStart,i, Token.IDENTIFIER, newStartOffset+currentTokenStart); backslash = false; addToken(text, currentTokenStart,i, Token.IDENTIFIER, newStartOffset+currentTokenStart); backslash = false; addToken(text, currentTokenStart,i, Token.IDENTIFIER, newStartOffset+currentTokenStart); currentTokenType = Token.NULL; backslash = !backslash; addToken(text, currentTokenStart,i, Token.SEPARATOR, newStartOffset+currentTokenStart); currentTokenType = Token.NULL; break; addToken(text, currentTokenStart,i, Token.IDENTIFIER, newStartOffset+currentTokenStart); currentTokenType = Token.NULL; break; addToken(text, currentTokenStart,i-1, Token.WHITESPACE, newStartOffset+currentTokenStart); addToken(text, i,i, Token.IDENTIFIER, newStartOffset+i); currentTokenType = Token.NULL; backslash = true; // Previous char whitespace => this must be first backslash. addToken(text, currentTokenStart,i-1, Token.WHITESPACE, newStartOffset+currentTokenStart); currentTokenStart = i; currentTokenType = Token.ERROR_STRING_DOUBLE;
/** * Adds the token specified to the current linked list of tokens. * * @param tokenType The token's type. * @see #addToken(int, int, int) */ private void addHyperlinkToken(int start, int end, int tokenType) { int so = start + offsetShift; addToken(zzBuffer, start,end, tokenType, so, true); }
{ if(JavaScriptTokenMaker.isJavaScriptCompatible("1.6")){ addToken(Token.RESERVED_WORD);} else {addToken(Token.IDENTIFIER);} { if(JavaScriptTokenMaker.isJavaScriptCompatible("1.7")){ addToken(Token.RESERVED_WORD);} else {addToken(Token.IDENTIFIER);}
JavaScriptTokenMaker.setE4xSupported(true); tm = new JavaScriptTokenMaker(); token = tm.getTokenList(seg, JS_PREV_TOKEN_TYPE, 0); Assert.assertTrue(token.is(TokenTypes.RESERVED_WORD, "var")); tm = new JavaScriptTokenMaker(); token = tm.getTokenList(seg, JS_PREV_TOKEN_TYPE, 0); Assert.assertTrue(token.is(TokenTypes.RESERVED_WORD, "var")); tm = new JavaScriptTokenMaker(); token = tm.getTokenList(seg, JS_PREV_TOKEN_TYPE, 0); Assert.assertTrue(token.is(TokenTypes.RESERVED_WORD, "var")); tm = new JavaScriptTokenMaker(); token = tm.getTokenList(seg, JS_PREV_TOKEN_TYPE, 0); Assert.assertTrue(token.is(TokenTypes.RESERVED_WORD, "var")); tm = new JavaScriptTokenMaker(); token = tm.getTokenList(seg, JS_PREV_TOKEN_TYPE, 0); Assert.assertTrue(token.is(TokenTypes.RESERVED_WORD, "var")); tm = new JavaScriptTokenMaker(); token = tm.getTokenList(seg, JS_PREV_TOKEN_TYPE, 0); Assert.assertTrue(token.is(TokenTypes.RESERVED_WORD, "var")); tm = new JavaScriptTokenMaker(); token = tm.getTokenList(seg, JS_PREV_TOKEN_TYPE, 0); Assert.assertTrue(token.is(TokenTypes.RESERVED_WORD, "each"));
@Override public void install(RSyntaxTextArea textArea) { // We use a custom auto-completion. // AutoCompletion ac = createAutoCompletion(p); AutoCompletion ac = new JavaScriptAutoCompletion(provider, textArea); ac.setListCellRenderer(getDefaultCompletionCellRenderer()); ac.setAutoCompleteEnabled(isAutoCompleteEnabled()); ac.setAutoActivationEnabled(isAutoActivationEnabled()); ac.setAutoActivationDelay(getAutoActivationDelay()); ac.setParameterAssistanceEnabled(isParameterAssistanceEnabled()); ac.setExternalURLHandler(new JavaScriptDocUrlhandler(this)); ac.setShowDescWindow(getShowDescWindow()); ac.install(textArea); installImpl(textArea, ac); Listener listener = new Listener(textArea); textArea.putClientProperty(PROPERTY_LISTENER, listener); parser = new JavaScriptParser(this, textArea); textArea.putClientProperty(PROPERTY_LANGUAGE_PARSER, parser); textArea.addParser(parser); //textArea.setToolTipSupplier(provider); Info info = new Info(provider, parser); parserToInfoMap.put(parser, info); installKeyboardShortcuts(textArea); // Set XML on JavascriptTokenMaker JavaScriptTokenMaker.setE4xSupported(isXmlAvailable()); textArea.setLinkGenerator(new JavaScriptLinkGenerator(this)); }
resetTokenList(); addToken(text, currentTokenStart,i, Token.IDENTIFIER, newStartOffset+currentTokenStart); backslash = false; addToken(text, currentTokenStart,i, Token.IDENTIFIER, newStartOffset+currentTokenStart); backslash = false; addToken(text, currentTokenStart,i, Token.IDENTIFIER, newStartOffset+currentTokenStart); currentTokenType = Token.NULL; backslash = !backslash; addToken(text, currentTokenStart,i, Token.SEPARATOR, newStartOffset+currentTokenStart); currentTokenType = Token.NULL; break; addToken(text, currentTokenStart,i, Token.IDENTIFIER, newStartOffset+currentTokenStart); currentTokenType = Token.NULL; break; addToken(text, currentTokenStart,i-1, Token.WHITESPACE, newStartOffset+currentTokenStart); addToken(text, i,i, Token.IDENTIFIER, newStartOffset+i); currentTokenType = Token.NULL; backslash = true; // Previous char whitespace => this must be first backslash. addToken(text, currentTokenStart,i-1, Token.WHITESPACE, newStartOffset+currentTokenStart); currentTokenStart = i; currentTokenType = Token.ERROR_STRING_DOUBLE;
/** * Adds the token specified to the current linked list of tokens. * * @param tokenType The token's type. */ private void addToken(int tokenType) { addToken(zzStartRead, zzMarkedPos-1, tokenType); }
{ if(JavaScriptTokenMaker.isJavaScriptCompatible("1.6")){ addToken(Token.RESERVED_WORD);} else {addToken(Token.IDENTIFIER);} { if(JavaScriptTokenMaker.isJavaScriptCompatible("1.7")){ addToken(Token.RESERVED_WORD);} else {addToken(Token.IDENTIFIER);}
@Before public void setUp() { JavaScriptTokenMaker.setE4xSupported(false); JavaScriptTokenMaker.setJavaScriptVersion("1.7"); }
boolean eof = zzRefill(); { start = zzMarkedPos-1; yybegin(E4X_INATTR_SINGLE); { start = zzMarkedPos-1; yybegin(E4X_INATTR_DOUBLE); { addToken(Token.ERROR_NUMBER_FORMAT); { addToken(Token.RESERVED_WORD_2); { addToken(start,zzStartRead-1, Token.MARKUP_DTD); addEndToken(e4x_inInternalDtd ? INTERNAL_E4X_DTD_INTERNAL : INTERNAL_E4X_DTD); return firstToken; { int type = validJSString ? Token.LITERAL_BACKQUOTE : Token.ERROR_STRING_DOUBLE; addToken(start,zzStartRead, type); yybegin(YYINITIAL); addToken(start,zzStartRead, Token.LITERAL_CHAR); addEndToken(INTERNAL_IN_JS_CHAR_VALID); addToken(start,zzStartRead, Token.ERROR_CHAR); addEndToken(INTERNAL_IN_JS_CHAR_INVALID); { addToken(Token.WHITESPACE); { addToken(start,zzStartRead-1, Token.COMMENT_MULTILINE); addEndToken(INTERNAL_IN_JS_MLC); return firstToken; int operatorLen = yycharat(0)=='+' ? 2 : 1; int yylen = yylength(); // Cache before first addToken() invalidates it addToken(zzStartRead,zzStartRead+operatorLen-1, Token.OPERATOR); if (yylen>operatorLen+1) {
public Token getTokenList(Segment text, int initialTokenType, int startOffset) { resetTokenList(); this.offsetShift = -text.offset + startOffset; validJSString = true; setLanguageIndex(languageIndex); start = text.offset; s = text; try { yyreset(zzReader); yybegin(state); return yylex(); } catch (IOException ioe) { ioe.printStackTrace();
/** * Adds the token specified to the current linked list of tokens. * * @param tokenType The token's type. */ private void addToken(int start, int end, int tokenType) { int so = start + offsetShift; addToken(zzBuffer, start,end, tokenType, so); }
@Test public void testJS_api_setE4XSupported() { Assert.assertFalse(JavaScriptTokenMaker.isE4xSupported()); JavaScriptTokenMaker.setE4xSupported(true); Assert.assertTrue(JavaScriptTokenMaker.isE4xSupported()); }
{ if(JavaScriptTokenMaker.isJavaScriptCompatible("1.6")){ addToken(Token.RESERVED_WORD);} else {addToken(Token.IDENTIFIER);} { if(JavaScriptTokenMaker.isJavaScriptCompatible("1.7")){ addToken(Token.RESERVED_WORD);} else {addToken(Token.IDENTIFIER);}
/** * Adds the token specified to the current linked list of tokens as an * "end token;" that is, at <code>zzMarkedPos</code>. * * @param tokenType The token's type. */ private void addEndToken(int tokenType) { addToken(zzMarkedPos,zzMarkedPos, tokenType); }
{ if(JavaScriptTokenMaker.isJavaScriptCompatible("1.6")){ addToken(Token.RESERVED_WORD);} else {addToken(Token.IDENTIFIER);} { if(JavaScriptTokenMaker.isJavaScriptCompatible("1.7")){ addToken(Token.RESERVED_WORD);} else {addToken(Token.IDENTIFIER);}