本文整理汇总了Java中org.fife.ui.rsyntaxtextarea.Token.isPaintable方法的典型用法代码示例。如果您正苦于以下问题:Java Token.isPaintable方法的具体用法?Java Token.isPaintable怎么用?Java Token.isPaintable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fife.ui.rsyntaxtextarea.Token
的用法示例。
在下文中一共展示了Token.isPaintable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIdentifiers
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testIdentifiers() {
String code = " foo bar\t\tbas\t \tbaz ";
PlainTextTokenMaker tm = new PlainTextTokenMaker();
Segment segment = createSegment(code);
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
Assert.assertTrue(token.isWhitespace());
token = token.getNextToken();
while (token != null && token.isPaintable()) {
Assert.assertEquals("Not an identifier: " + token, TokenTypes.IDENTIFIER, token.getType());
token = token.getNextToken();
Assert.assertTrue(token.isWhitespace());
token = token.getNextToken();
}
}
示例2: testWhitespace
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testWhitespace() {
String code = " foo bar\t\tbas\t \tbaz ";
PlainTextTokenMaker tm = new PlainTextTokenMaker();
Segment segment = createSegment(code);
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
Assert.assertTrue(token.isWhitespace());
token = token.getNextToken();
while (token != null && token.isPaintable()) {
Assert.assertEquals("Not an identifier: " + token, TokenTypes.IDENTIFIER, token.getType());
token = token.getNextToken();
Assert.assertTrue(token.isWhitespace());
token = token.getNextToken();
}
}
示例3: parse
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
public ParseResult parse(RSyntaxDocument doc, String style) {
Element root = doc.getDefaultRootElement();
int lineCount = root.getElementCount();
if (taskPattern==null ||
style==null || SyntaxConstants.SYNTAX_STYLE_NONE.equals(style)){
result.clearNotices();
result.setParsedLines(0, lineCount-1);
return result;
}
// TODO: Pass in parsed line range and just do that
result.clearNotices();
result.setParsedLines(0, lineCount-1);
for (int line=0; line<lineCount; line++) {
Token t = doc.getTokenListForLine(line);
int offs = -1;
int start = -1;
String text = null;
while (t!=null && t.isPaintable()) {
if (t.isComment()) {
offs = t.getOffset();
text = t.getLexeme();
Matcher m = taskPattern.matcher(text);
if (m.find()) {
start = m.start();
offs += start;
break;
}
}
t = t.getNextToken();
}
if (start>-1) {
text = text.substring(start);
// TODO: Strip off end of MLC's if they're there.
int len = text.length();
TaskNotice pn = new TaskNotice(this, text, line+1, offs, len);
pn.setLevel(ParserNotice.Level.INFO);
pn.setShowInEditor(false);
pn.setColor(COLOR);
result.addNotice(pn);
}
}
return result;
}
示例4: testJS_EolComments_URL
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testJS_EolComments_URL() {
String[] eolCommentLiterals = {
// Note: The 0-length token at the end of the first example is a
// minor bug/performance thing
"// Hello world http://www.sas.com",
"// Hello world http://www.sas.com extra",
};
for (String code : eolCommentLiterals) {
Segment segment = createSegment(code);
JavaScriptTokenMaker tm = new JavaScriptTokenMaker();
Token token = tm.getTokenList(segment, JS_PREV_TOKEN_TYPE, 0);
Assert.assertEquals(TokenTypes.COMMENT_EOL, token.getType());
token = token.getNextToken();
Assert.assertTrue(token.isHyperlink());
Assert.assertEquals(TokenTypes.COMMENT_EOL, token.getType());
Assert.assertEquals("http://www.sas.com", token.getLexeme());
token = token.getNextToken();
// Note: The 0-length token at the end of the first example is a
// minor bug/performance thing
if (token != null && token.isPaintable() && token.length() > 0) {
Assert.assertFalse(token.isHyperlink());
Assert.assertTrue(token.is(TokenTypes.COMMENT_EOL, " extra"));
}
}
}
示例5: testJS_EolComments_URL
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testJS_EolComments_URL() {
String[] eolCommentLiterals = {
// Note: The 0-length token at the end of the first example is a
// minor bug/performance thing
"// Hello world http://www.sas.com",
"// Hello world http://www.sas.com extra",
};
for (String code : eolCommentLiterals) {
Segment segment = createSegment(code);
TokenMaker tm = createTokenMaker();
Token token = tm.getTokenList(segment, HTMLTokenMaker.INTERNAL_IN_JS, 0);
Assert.assertEquals("nope - " + token, TokenTypes.COMMENT_EOL, token.getType());
token = token.getNextToken();
Assert.assertTrue(token.isHyperlink());
Assert.assertEquals(TokenTypes.COMMENT_EOL, token.getType());
Assert.assertEquals("http://www.sas.com", token.getLexeme());
token = token.getNextToken();
// Note: The 0-length token at the end of the first example is a
// minor bug/performance thing
if (token != null && token.isPaintable() && token.length() > 0) {
Assert.assertFalse(token.isHyperlink());
Assert.assertTrue(token.is(TokenTypes.COMMENT_EOL, " extra"));
}
}
}
示例6: testTS_EolComments_URL
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testTS_EolComments_URL() {
String[] eolCommentLiterals = {
// Note: The 0-length token at the end of the first example is a
// minor bug/performance thing
"// Hello world http://www.sas.com",
"// Hello world http://www.sas.com extra",
};
for (String code : eolCommentLiterals) {
Segment segment = createSegment(code);
TokenMaker tm = createTokenMaker();
Token token = tm.getTokenList(segment, TS_PREV_TOKEN_TYPE, 0);
Assert.assertEquals(TokenTypes.COMMENT_EOL, token.getType());
token = token.getNextToken();
Assert.assertTrue(token.isHyperlink());
Assert.assertEquals(TokenTypes.COMMENT_EOL, token.getType());
Assert.assertEquals("http://www.sas.com", token.getLexeme());
token = token.getNextToken();
// Note: The 0-length token at the end of the first example is a
// minor bug/performance thing
if (token != null && token.isPaintable() && token.length() > 0) {
Assert.assertFalse(token.isHyperlink());
Assert.assertTrue(token.is(TokenTypes.COMMENT_EOL, " extra"));
}
}
}
示例7: testJS_EolComments_URL
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testJS_EolComments_URL() {
String[] eolCommentLiterals = {
// Note: The 0-length token at the end of the first example is a
// minor bug/performance thing
"// Hello world http://www.sas.com",
"// Hello world http://www.sas.com extra",
};
for (String code : eolCommentLiterals) {
Segment segment = createSegment(code);
TokenMaker tm = createTokenMaker();
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
Assert.assertEquals(TokenTypes.COMMENT_EOL, token.getType());
token = token.getNextToken();
Assert.assertTrue(token.isHyperlink());
Assert.assertEquals(TokenTypes.COMMENT_EOL, token.getType());
Assert.assertEquals("http://www.sas.com", token.getLexeme());
token = token.getNextToken();
// Note: The 0-length token at the end of the first example is a
// minor bug/performance thing
if (token != null && token.isPaintable() && token.length() > 0) {
Assert.assertFalse(token.isHyperlink());
Assert.assertTrue(token.is(TokenTypes.COMMENT_EOL, " extra"));
}
}
}
示例8: getToolTipText
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
/**
* Overridden to show the content of a collapsed fold on mouse-overs.
*
* @param e The mouse location.
*/
@Override
public String getToolTipText(MouseEvent e) {
String text = null;
RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
if (rsta.isCodeFoldingEnabled()) {
FoldManager fm = rsta.getFoldManager();
int pos = rsta.viewToModel(new Point(0, e.getY()));
if (pos>=0) { // Not -1
int line = 0;
try {
line = rsta.getLineOfOffset(pos);
} catch (BadLocationException ble) {
ble.printStackTrace(); // Never happens
return null;
}
Fold fold = fm.getFoldForLine(line);
if (fold!=null && fold.isCollapsed()) {
int endLine = fold.getEndLine();
if (fold.getLineCount()>25) { // Not too big
endLine = fold.getStartLine() + 25;
}
StringBuilder sb = new StringBuilder("<html><nobr>");
while (line<=endLine && line<rsta.getLineCount()) { // Sanity
Token t = rsta.getTokenListForLine(line);
while (t!=null && t.isPaintable()) {
t.appendHTMLRepresentation(sb, rsta, true, true);
t = t.getNextToken();
}
sb.append("<br>");
line++;
}
text = sb.toString();
}
}
}
return text;
}