本文整理汇总了Java中org.openide.text.Line.getLineNumber方法的典型用法代码示例。如果您正苦于以下问题:Java Line.getLineNumber方法的具体用法?Java Line.getLineNumber怎么用?Java Line.getLineNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.text.Line
的用法示例。
在下文中一共展示了Line.getLineNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.openide.text.Line; //导入方法依赖的package包/类
private void update(Line l) {
try {
int ln;
synchronized (this) {
updatingLine = true;
ln = l.getLineNumber() + 1;
}
lb.setLineNumber(ln);
} finally {
synchronized (this) {
updatingLine = false;
}
}
}
示例2: Bookmark
import org.openide.text.Line; //导入方法依赖的package包/类
/**
* Construct new instance of bookmark.
*
* <p>
* The constructor is not public intentionally.
* Please see <code>BookmarksApiPackageAccessor</code> for details.
*/
Bookmark (BookmarkList bookmarkList, BookmarkInfo info, int offset) {
if (info == null) {
throw new IllegalArgumentException("info cannot be null"); // NOI18N
}
this.bookmarkList = bookmarkList;
this.info = info;
Document document = bookmarkList.getDocument ();
int lineIndex = BookmarkUtils.offset2LineIndex(document, offset);
DataObject dataObject = NbEditorUtilities.getDataObject (document);
for (Line _line : lineToAnnotation.keySet ()) {
if (_line.getLineNumber () == lineIndex &&
_line.getLookup().lookup (DataObject.class).equals (dataObject)
) {
this.line = _line;
Reference<Annotation> annoRef = lineToAnnotation.get (_line);
Annotation a = annoRef.get();
if (a != null) {
info.setAnnotationRef(annoRef);
}
}
}
line = NbEditorUtilities.getLine (bookmarkList.getDocument (), offset, false);
if (line != null) { // In tests it may be null
if (info.getAnnotation() == null) {
AAnnotation annotation = new AAnnotation ();
info.setAnnotationRef(new WeakReference<Annotation>(annotation));
annotation.attach (line);
}
}
}
示例3: getMIMETypesOnLine
import org.openide.text.Line; //导入方法依赖的package包/类
/**
* Get a list of MIME types of languages found on a line.
* @param line The line to search for the MIME types.
* @return A set of MIME types.
* @since 2.50
*/
public Set<String> getMIMETypesOnLine(Line line) {
EditorCookie editorCookie = line.getLookup().lookup(EditorCookie.class);
if (editorCookie == null) {
DataObject dobj = line.getLookup().lookup(DataObject.class);
if (dobj != null) {
editorCookie = dobj.getLookup().lookup(EditorCookie.class);
}
if (editorCookie == null) {
return Collections.emptySet();
}
}
StyledDocument document = editorCookie.getDocument();
if (document == null) {
return Collections.emptySet();
}
Set<String> mimeTypes = null;
((AbstractDocument) document).readLock();
try {
TokenHierarchy<Document> th = TokenHierarchy.get((Document) document);
int ln = line.getLineNumber();
int offset = NbDocument.findLineOffset(document, ln);
int maxOffset = document.getLength() - 1;
int maxLine = NbDocument.findLineNumber(document, maxOffset);
int offset2;
if (ln + 1 > maxLine) {
offset2 = maxOffset;
} else {
offset2 = NbDocument.findLineOffset(document, ln+1) - 1;
}
// The line has offsets <offset, offset2>
Set<LanguagePath> languagePaths = th.languagePaths();
for (LanguagePath lp : languagePaths) {
List<TokenSequence<?>> tsl = th.tokenSequenceList(lp, offset, offset2);
for (TokenSequence ts : tsl) {
if (ts.moveNext()) {
//int to = ts.offset();
//if (!(offset <= to && to < offset2)) {
// continue;
//}
String mimeType = ts.language().mimeType();
if (mimeType != null) {
if (mimeTypes == null) {
mimeTypes = Collections.singleton(mimeType);
} else {
if (mimeTypes.size() == 1) {
mimeTypes = new HashSet<String>(mimeTypes);
}
mimeTypes.add(mimeType);
}
}
}
}
}
} finally {
((AbstractDocument) document).readUnlock();
}
return (mimeTypes != null) ? mimeTypes : Collections.<String>emptySet();
}