org.openide.text.Line.createPart()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.openide.text.Line.createPart()方法的一些代码示例,展示了Line.createPart()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Line.createPart()方法的具体详情如下:
包路径:org.openide.text.Line
类名称:Line
方法名:createPart

Line.createPart介绍

[英]Create object which represent part of the text on the line. This part of the line can be used for attaching of annotations.
[中]创建表示行上部分文本的对象。线条的这一部分可用于附加注释。

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-insync

/**
 *  Only underline the part of the line that has text on it.
 */
public void attachToLineSet(Set lines) {
  docline = lines.getCurrent(line-1);
  char[] string = docline.getText().toCharArray();
  int start = 0;
  int end = string.length-1;
  while (start <= end && string[start] <= ' ')
    start++;
  while (start <= end && string[end] <= ' ')
    end--;
  // XXX shouldn't we use the column??? But if so, chaining
  // gets trickier...
  Line.Part part;
  if (start <= end)
    part = docline.createPart(start, end-start+1);
  else
    part = docline.createPart(0, string.length);
  attach(part);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui

setupContext(editorPane, null);
Line line = EditorContextDispatcher.getDefault().getMostRecentLine();
line.createPart(0, 0);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui

private static Pair<Line.Part, FileObject> getContext(EditorContextProvider ecp) {
  Line.Part lp = ecp.getContext();
  if (lp == null) {
    Line line = EditorContextDispatcher.getDefault().getMostRecentLine();
    if (line != null) {
      lp = line.createPart(0, 0);
    }
  }
  FileObject file;
  if (lp != null) {
    file = lp.getLine().getLookup().lookup(FileObject.class);
  } else {
    file = null;
  }
  return Pair.of(lp, file);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans

private void addAnnotation( CdiAnalysisResult result, Element element , 
    CDIAnnotaitonType type ) 
{
  if ( element == null ){
    return;
  }
  Tree var = result.getInfo().getTrees().getTree( element );
  if ( var == null ){
    return;
  }
  List<Integer> position = CdiEditorAnalysisFactory.getElementPosition( 
      result.getInfo(),  var );
  Document document;
  try {
    document = result.getInfo().getDocument();
    if ( !( document instanceof StyledDocument) ){
      return;
    }
  }
  catch (IOException e) {
    return;
  }
  int start = position.get(0);
  Line line = NbEditorUtilities.getLine( document , start, false);
  Part part = line.createPart( NbDocument.findLineColumn((StyledDocument) document,
      start),  position.get( 1 ) -start);
  result.addAnnotation( new CDIAnnotation( type, part));
}

相关文章