本文整理汇总了Java中org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.getTokenListForLine方法的典型用法代码示例。如果您正苦于以下问题:Java RSyntaxTextArea.getTokenListForLine方法的具体用法?Java RSyntaxTextArea.getTokenListForLine怎么用?Java RSyntaxTextArea.getTokenListForLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
的用法示例。
在下文中一共展示了RSyntaxTextArea.getTokenListForLine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTagCloseInfo
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //导入方法依赖的package包/类
/**
* Grabs the token representing the closing of a tag (i.e.
* "<code>></code>" or "<code>/></code>"). This should only be
* called after a tag name has been parsed, to ensure the "closing" of
* other tags is not identified.
*
* @param tagNameToken The token denoting the name of the tag.
* @param textArea The text area whose contents are being parsed.
* @param line The line we're currently on.
* @param info On return, information about the closing of the tag is
* returned in this object.
* @return The line number of the closing tag token.
*/
private int getTagCloseInfo(Token tagNameToken, RSyntaxTextArea textArea,
int line, TagCloseInfo info) {
info.reset();
Token t = tagNameToken.getNextToken();
do {
while (t!=null && t.getType()!=Token.MARKUP_TAG_DELIMITER) {
t = t.getNextToken();
}
if (t!=null) {
info.closeToken = t;
info.line = line;
break;
}
} while (++line<textArea.getLineCount() &&
(t=textArea.getTokenListForLine(line))!=null);
return line;
}
示例2: checkStringLiteralMember
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //导入方法依赖的package包/类
/**
* Checks whether the user is typing a completion for a String member after
* a String literal.
*
* @param comp The text component.
* @param alreadyEntered The text already entered.
* @param cu The compilation unit being parsed.
* @param set The set to add possible completions to.
* @return Whether the user is indeed typing a completion for a String
* literal member.
*/
private boolean checkStringLiteralMember(JTextComponent comp,
String alreadyEntered,
CompilationUnit cu, Set set) {
boolean stringLiteralMember = false;
int offs = comp.getCaretPosition() - alreadyEntered.length() - 1;
if (offs>1) {
RSyntaxTextArea textArea = (RSyntaxTextArea)comp;
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
try {
//System.out.println(doc.charAt(offs) + ", " + doc.charAt(offs+1));
if (doc.charAt(offs)=='"' && doc.charAt(offs+1)=='.') {
int curLine = textArea.getLineOfOffset(offs);
Token list = textArea.getTokenListForLine(curLine);
Token prevToken = RSyntaxUtilities.getTokenAtOffset(list, offs);
if (prevToken!=null &&
prevToken.getType()==Token.LITERAL_STRING_DOUBLE_QUOTE) {
ClassFile cf = getClassFileFor(cu, "java.lang.String");
addCompletionsForExtendedClass(set, cu, cf,
cu.getPackageName(), null);
stringLiteralMember = true;
}
else {
System.out.println(prevToken);
}
}
} catch (BadLocationException ble) { // Never happens
ble.printStackTrace();
}
}
return stringLiteralMember;
}
示例3: getToolTipText
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //导入方法依赖的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;
}
示例4: checkForLinkableToken
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //导入方法依赖的package包/类
/**
* Checks if the token at the specified offset is possibly a "click-able"
* region.
*
* @param textArea The text area.
* @param offs The offset, presumably at the mouse position.
* @return A result object.
*/
private IsLinkableCheckResult checkForLinkableToken(
RSyntaxTextArea textArea, int offs) {
IsLinkableCheckResult result = null;
if (offs>=0) {
try {
int line = textArea.getLineOfOffset(offs);
Token first = textArea.getTokenListForLine(line);
Token prev = null;
for (Token t=first; t!=null && t.isPaintable(); t=t.getNextToken()) {
if (t.containsPosition(offs)) {
// RSTA's tokens are pooled and re-used, so we must
// defensively make a copy of the one we want to keep!
Token token = new TokenImpl(t);
boolean isMethod = false;
if (prev==null) {
prev = RSyntaxUtilities.getPreviousImportantToken(textArea, line-1);
}
if (prev!=null && prev.isSingleChar('.')) {
// Not a field or method defined in this class.
break;
}
Token next = RSyntaxUtilities.getNextImportantToken(
t.getNextToken(), textArea, line);
if (next!=null && next.isSingleChar(Token.SEPARATOR, '(')) {
isMethod = true;
}
result = new IsLinkableCheckResult(token, isMethod);
break;
}
else if (!t.isCommentOrWhitespace()) {
prev = t;
}
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Never happens
}
}
return result;
}
示例5: checkForVarDereference
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //导入方法依赖的package包/类
/**
* Checks if the token at the specified offset is possibly a "click-able"
* region.
*
* @param textArea The text area.
* @param offs The offset, presumably at the mouse position.
* @return A result object.
*/
private Token checkForVarDereference(RSyntaxTextArea textArea, int offs) {
if (offs>=0) {
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
try {
int line = textArea.getLineOfOffset(offs);
Token first = textArea.getTokenListForLine(line);
Token prev = null;
Token prev2 = null;
for (Token t=first; t!=null && t.isPaintable(); t=t.getNextToken()) {
if (t.containsPosition(offs)) {
if (prev==null) {
prev = RSyntaxUtilities.getPreviousImportantToken(
doc, line-1);
}
break;
}
else if (!t.isCommentOrWhitespace()) {
prev2 = prev;
prev = t;
}
}
// Sigh, if only Tokens could be a doubly-linked list...
// Scan back again to get what variable is dereferenced.
if (prev!=null && prev.is(Token.OPERATOR, ARROW)) {
// Common case - user had it all on one line, e.g.
// "Link->PressA"
if (prev2!=null) {
//System.out.println("Common case!");
return prev2;
}
// Uncommon case - user had the "->" on one line and e.g.
// "PressA" on another line.
int arrowOffs = prev.getOffset();
line = textArea.getLineOfOffset(arrowOffs);
first = textArea.getTokenListForLine(line);
prev = null;
for (Token t=first; t!=null && t.isPaintable(); t=t.getNextToken()) {
if (t.getOffset()==arrowOffs) {
if (prev==null) {
prev = RSyntaxUtilities.getPreviousImportantToken(
doc, line-1);
}
if (prev!=null) {
return prev;
}
}
else if (!t.isCommentOrWhitespace()) {
prev = t;
}
}
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Never happens
}
}
return null;
}