/** * {@inheritDoc} */ @Override public boolean getShouldIndentNextLineAfter(Token t) { if (t!=null && t.length()==1) { char ch = t.charAt(0); return ch=='{' || ch=='('; } return false; }
@Override public boolean getShouldIndentNextLineAfter(Token t) { if (t!=null && t.length()==1) { char ch = t.charAt(0); return ch=='{' || ch=='['; } return false; }
@Override public boolean getShouldIndentNextLineAfter(Token t) { if (t!=null && t.length()==1) { char ch = t.charAt(0); return ch=='{' || ch=='('; } return false; }
/** * Returns whether the specified token is a single non-word char (e.g. not * in <code>[A-Za-z]</code>. This is a HACK to work around the fact that * many standard token makers return things like semicolons and periods as * {@link Token#IDENTIFIER}s just to make the syntax highlighting coloring * look a little better. * * @param t The token to check. This cannot be <code>null</code>. * @return Whether the token is a single non-word char. */ public static boolean isNonWordChar(Token t) { return t.length()==1 && !RSyntaxUtilities.isLetter(t.charAt(0)); }
/** * Returns whether a regular expression token can follow the specified * token. * * @param t The token to check, which may be <code>null</code>. * @return Whether a regular expression token may follow this one. */ private static final boolean regexCanFollow(Token t) { char ch; return t==null || //t.isOperator() || (t.length()==1 && ( (ch=t.charAt(0))=='=' || ch=='(' || ch==',' || ch=='?' || ch==':' || ch=='[' )) || /* Operators "==", "===", "!=", "!==", etc. */ (t.getType()==Token.OPERATOR && ((ch=t.charAt(t.length()-1))=='=' || ch=='~')); }
/** * Returns whether a regular expression token can follow the specified * token. * * @param t The token to check, which may be <code>null</code>. * @return Whether a regular expression token may follow this one. */ private static final boolean regexCanFollow(Token t) { char ch; // We basically try to mimic Eclipse's JS editor's behavior here. return t==null || //t.isOperator() || (t.length()==1 && ( (ch=t.charAt(0))=='=' || ch=='(' || ch==',' || ch=='?' || ch==':' || ch=='[' || ch=='!' || ch=='&' )) || /* Operators "==", "===", "!=", "!==", etc. */ (t.getType()==Token.OPERATOR && ((ch=t.charAt(t.length()-1))=='=' || ch=='~')); }
/** * Overridden to handle newlines in JS and CSS differently than those in * markup. */ @Override public boolean getShouldIndentNextLineAfter(Token token) { int languageIndex = token==null ? 0 : token.getLanguageIndex(); if (getCurlyBracesDenoteCodeBlocks(languageIndex)) { if (token!=null && token.length()==1) { char ch = token.charAt(0); return ch=='{' || ch=='('; } } return false; }
/** * Overridden to handle newlines in JS and CSS differently than those in * markup. */ @Override public boolean getShouldIndentNextLineAfter(Token token) { int languageIndex = token==null ? 0 : token.getLanguageIndex(); if (getCurlyBracesDenoteCodeBlocks(languageIndex)) { if (token!=null && token.length()==1) { char ch = token.charAt(0); return ch=='{' || ch=='('; } } return false; }
/** * Overridden to handle newlines in JS and CSS differently than those in * markup. */ @Override public boolean getShouldIndentNextLineAfter(Token token) { int languageIndex = token==null ? 0 : token.getLanguageIndex(); if (getCurlyBracesDenoteCodeBlocks(languageIndex)) { if (token!=null && token.length()==1) { char ch = token.charAt(0); return ch=='{' || ch=='('; } } return false; }
private static int getOpenBraceCount(RSyntaxDocument doc, int languageIndex) { int openCount = 0; for (Token t : doc) { if (t.getType()==Token.SEPARATOR && t.length()==1 && t.getLanguageIndex()==languageIndex) { char ch = t.charAt(0); if (ch=='{') { openCount++; } else if (ch=='}') { openCount--; } } } return openCount; }
/** * Returns whether a regular expression token can follow the specified * token in JavaScript. * * @param t The token to check, which may be <code>null</code>. * @return Whether a regular expression token may follow this one in * JavaScript. */ public static boolean regexCanFollowInJavaScript(Token t) { char ch; // We basically try to mimic Eclipse's JS editor's behavior here. return t==null || //t.isOperator() || (t.length()==1 && ( (ch=t.charAt(0))=='=' || ch=='(' || ch==',' || ch=='?' || ch==':' || ch=='[' || ch=='!' || ch=='&' )) || /* Operators "==", "===", "!=", "!==", "&&", "||" */ (t.getType()==Token.OPERATOR && (t.charAt(t.length()-1)=='=' || t.is(JS_AND) || t.is(JS_OR))) || t.is(Token.RESERVED_WORD_2, JS_KEYWORD_RETURN); }
int offs = 0; for (; offs<token.length(); offs++) { if (!RSyntaxUtilities.isWhitespace(token.charAt(offs))) { break; // MLC text, etc.
private byte[] getTextAsRtf(int start, int end) { // Create the RTF selection. RtfGenerator gen = new RtfGenerator(getBackground()); Token tokenList = getTokenListFor(start, end); for (Token t = tokenList; t != null; t = t.getNextToken()) { if (t.isPaintable()) { if (t.length() == 1 && t.charAt(0) == '\n') { gen.appendNewline(); } else { Font font = getFontForTokenType(t.getType()); Color bg = getBackgroundForToken(t); boolean underline = getUnderlineForToken(t); // Small optimization - don't print fg color if this // is a whitespace color. Saves on RTF size. if (t.isWhitespace()) { gen.appendToDocNoFG(t.getLexeme(), font, bg, underline); } else { Color fg = getForegroundForToken(t); gen.appendToDoc(t.getLexeme(), font, fg, bg, underline); } } } } // RTF text is 7-bit ASCII so this should cover us return gen.getRtf().getBytes(StandardCharsets.UTF_8); }
@Override public boolean getShouldIndentNextLineAfter(Token t) { if (t!=null && t.length()==1) { char ch = t.charAt(0); return ch=='{' || ch=='('; } return false; }
/** * Returns whether this token's text is "<" or "</". It is assumed that * whether this is a markup delimiter token is checked elsewhere. * * @param t The token to check. * @return Whether it is a tag opening token. */ private static boolean isTagOpeningToken(Token t) { return t.isSingleChar('<') || (t.length()==2 && t.charAt(0)=='<' && t.charAt(1)=='/'); }
@Override public boolean getShouldIndentNextLineAfter(Token t) { if (t!=null && t.length()==1) { char ch = t.charAt(0); return ch=='{' || ch=='['; } return false; }
/** * {@inheritDoc} */ @Override public boolean getShouldIndentNextLineAfter(Token t) { if (t!=null && t.length()==1) { char ch = t.charAt(0); return ch=='{' || ch=='('; } return false; }
/** * Returns whether the specified token is a single non-word char (e.g. not * in <code>[A-Za-z]</code>. This is a HACK to work around the fact that * many standard token makers return things like semicolons and periods as * {@link Token#IDENTIFIER}s just to make the syntax highlighting coloring * look a little better. * * @param t The token to check. This cannot be <code>null</code>. * @return Whether the token is a single non-word char. */ public static boolean isNonWordChar(Token t) { return t.length()==1 && !RSyntaxUtilities.isLetter(t.charAt(0)); }