Codota Logo
NbDocument.findLineRootElement
Code IndexAdd Codota to your IDE (free)

How to use
findLineRootElement
method
in
org.openide.text.NbDocument

Best Java code snippets using org.openide.text.NbDocument.findLineRootElement (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: org.netbeans.modules/org-netbeans-modules-cnd-completion

@Override
public List<CsmReference> getFunctionCalls(StyledDocument document, int line) {
  if (line < 0 || document == null) {
    return Collections.emptyList();
  }
  CsmFile csmFile = CsmUtilities.getCsmFile(document, false, false);
  if (csmFile == null || !csmFile.isParsed()) {
    return Collections.emptyList();
  }
  final Element lineRootElement = NbDocument.findLineRootElement(document);
  return getFunctionCalls(csmFile, lineRootElement, line);
}
origin: org.netbeans.api/org-openide-text

  public void run() {
    switch (opCode) {
    case FIND_LINE_NUMBER: {
      Element paragraphsParent = findLineRootElement(doc);
      retInt = paragraphsParent.getElementIndex(argInt); // argInt is offset
      break;
    }
    case FIND_LINE_COLUMN: {
      Element paragraphsParent = findLineRootElement(doc);
      int indx = paragraphsParent.getElementIndex(argInt); // argInt is offset
      retInt = argInt - paragraphsParent.getElement(indx).getStartOffset();
      break;
    }
    case FIND_LINE_OFFSET: {
      Element paragraphsParent = findLineRootElement(doc);
      Element line = paragraphsParent.getElement(argInt); // argInt is lineNumber
      if (line == null) {
        throw new IndexOutOfBoundsException("Index=" + argInt + " is out of bounds."); // NOI18N
      }
      retInt = line.getStartOffset();
      break;
    }
    default:
      throw new IllegalStateException();
    }
  }
}
origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

  public void run() {
    switch (opCode) {
      case FIND_LINE_NUMBER: {
        Element paragraphsParent = findLineRootElement (doc);
        retInt = paragraphsParent.getElementIndex (argInt); // argInt is offset
        break; }
      case FIND_LINE_COLUMN: {
        Element paragraphsParent = findLineRootElement (doc);
        int indx = paragraphsParent.getElementIndex (argInt); // argInt is offset
        retInt = argInt - paragraphsParent.getElement (indx).getStartOffset ();
        break; }
      case FIND_LINE_OFFSET: {
        Element paragraphsParent = findLineRootElement (doc);
        Element line = paragraphsParent.getElement (argInt); // argInt is lineNumber
        if(line == null) {
          throw new IndexOutOfBoundsException(
            "Index=" + argInt + " is out of bounds."); // NOI18N
        }
        retInt = line.getStartOffset ();
        break; }
      
      default:
        throw new IllegalStateException();
    }
  }
}
origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

  public void run() {
    switch (opCode) {
      case FIND_LINE_NUMBER: {
        Element paragraphsParent = findLineRootElement (doc);
        retInt = paragraphsParent.getElementIndex (argInt); // argInt is offset
        break; }
      case FIND_LINE_COLUMN: {
        Element paragraphsParent = findLineRootElement (doc);
        int indx = paragraphsParent.getElementIndex (argInt); // argInt is offset
        retInt = argInt - paragraphsParent.getElement (indx).getStartOffset ();
        break; }
      case FIND_LINE_OFFSET: {
        Element paragraphsParent = findLineRootElement (doc);
        Element line = paragraphsParent.getElement (argInt); // argInt is lineNumber
        if(line == null) {
          throw new IndexOutOfBoundsException(
            "Index=" + argInt + " is out of bounds."); // NOI18N
        }
        retInt = line.getStartOffset ();
        break; }
      
      default:
        throw new IllegalStateException();
    }
  }
}
origin: org.netbeans.api/org-openide-text

  public void run() {
    // Part of #33165 - the following code is wrapped by doc.render()
    int lineNumber = getLineNumber();
    int lineStart = NbDocument.findLineOffset(doc, lineNumber);
    // #24434: Check whether the next line exists
    // (the current one could be the last one).
    int lineEnd;
    if ((lineNumber + 1) >= NbDocument.findLineRootElement(doc).getElementCount()) {
      lineEnd = doc.getLength();
    } else {
      lineEnd = NbDocument.findLineOffset(doc, lineNumber + 1);
    }
    try {
      retStringArray[0] = doc.getText(lineStart, lineEnd - lineStart);
    } catch (BadLocationException ex) {
      Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex);
      retStringArray[0] = null;
    }
    // End of the code wrapped by doc.render()
  }
}
origin: org.netbeans.api/org-openide-text

/** Creates new LineListener */
public LineListener(StyledDocument doc, CloneableEditorSupport support) {
  this.struct = new LineStruct();
  root = NbDocument.findLineRootElement(doc);
  orig = lines = root.getElementCount();
  this.support = support;
  doc.addDocumentListener(WeakListeners.document(this, doc));
}
origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Creates new LineListener */
public LineListener (StyledDocument doc, CloneableEditorSupport support) {
  this.doc = doc;
  this.struct = new LineStruct ();
  root = NbDocument.findLineRootElement (doc);
  orig = lines = root.getElementCount ();
  this.support = support;
  
  doc.addDocumentListener(org.openide.util.WeakListeners.document (this, doc));
}
origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Creates new LineListener */
public LineListener (StyledDocument doc, CloneableEditorSupport support) {
  this.doc = doc;
  this.struct = new LineStruct ();
  root = NbDocument.findLineRootElement (doc);
  orig = lines = root.getElementCount ();
  this.support = support;
  
  doc.addDocumentListener(org.openide.util.WeakListeners.document (this, doc));
}
origin: org.netbeans.modules/org-netbeans-modules-web-debug

try {
  javax.swing.text.Element lineElem = 
    org.openide.text.NbDocument.findLineRootElement (doc).
    getElement (line);
origin: org.netbeans.modules/org-netbeans-modules-web-debug

while (line > 0) {
  javax.swing.text.Element lineElem = 
    org.openide.text.NbDocument.findLineRootElement(doc).getElement(line);
  if (lineElem == null) {
    continue;
origin: dcaoyuan/nbscala

try {
  javax.swing.text.Element lineElem =
      org.openide.text.NbDocument.findLineRootElement(doc).
      getElement(line);
origin: org.netbeans.modules/org-netbeans-modules-web-debug

try {
  javax.swing.text.Element lineElem = 
    org.openide.text.NbDocument.findLineRootElement(doc).
    getElement(line);
  if (lineElem == null) {
origin: org.netbeans.modules/org-netbeans-modules-mobility-editor

  public void run() {
    // XXX: why is this not done by LineParser ?
    final OffsetsBag bag = new OffsetsBag(document, true);
    Element root = NbDocument.findLineRootElement((StyledDocument) document);
    int count = root.getElementCount();
    try {
      for (int i = 0; i < count; i++) {
        Element elm = root.getElement(i);
        if (BLOCK_HEADER_PATTERN.matcher(document.getText(elm.getStartOffset(), elm.getEndOffset() - elm.getStartOffset()).trim()).find()) {
          bag.addHighlight(elm.getStartOffset(), elm.getEndOffset(), commandHighlight);
        }
      }
    } catch (BadLocationException ex) {
      //ignore
      return;
    }
    headersBag.setHighlights(bag);
  }
});
origin: org.netbeans.modules/org-netbeans-modules-mobility-editor

  public void run() {
    List<PPBlockInfo> blockList = (List<PPBlockInfo>) document.getProperty(DocumentPreprocessor.PREPROCESSOR_BLOCK_LIST);
    if (blockList == null) {
      return;
    }
    final OffsetsBag bag = new OffsetsBag(document, true);
    LOG.log(Level.FINE, "Dumping lineset({0})", blockList.size()); //NOI18N
    for (PPBlockInfo b : blockList) {
      if (LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, "lineBlock: type={0}, startLine={1}, endLine={2}, active={3}", //NOI18N
            new Object[]{b.getType(), b.getStartLine(), b.getEndLine(), b.isActive()});
      }
      StyledDocument doc = (StyledDocument) document;
      bag.addHighlight(
          NbDocument.findLineRootElement(doc).getElement(b.getStartLine() - 1).getStartOffset(),
          NbDocument.findLineRootElement(doc).getElement(b.getEndLine() - 1).getEndOffset(),
          b.isActive() ? activeBlockHighlight : inactiveBlockHighlight);
    }
    LOG.log(Level.FINE, "-------------------"); //NOI18N
    blocksBag.setHighlights(bag);
  }
});
origin: dcaoyuan/nbscala

try {
  Element lineElem = 
    NbDocument.findLineRootElement (doc).
    getElement (line);
origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui

try {
  javax.swing.text.Element lineElem =
    org.openide.text.NbDocument.findLineRootElement (doc).
    getElement (line);
origin: org.netbeans.modules/org-netbeans-modules-cnd-completion

final Element lineRootElement = NbDocument.findLineRootElement(document);
origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

doc.render(new Runnable() { public void run() {
// Part of #33165 - the following code is wrapped by doc.render()
int lineNumber = getLineNumber();
int lineStart = NbDocument.findLineOffset(doc, lineNumber);
// #24434: Check whether the next line exists
// (the current one could be the last one).
int lineEnd;
if((lineNumber + 1) 
>= NbDocument.findLineRootElement(doc).getElementCount()) {
  lineEnd = doc.getLength();
} else {
  lineEnd = NbDocument.findLineOffset(doc, lineNumber + 1);
}

try {
  retStringArray[0] = doc.getText(lineStart, lineEnd - lineStart);
} catch (BadLocationException ex) {
  ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
  retStringArray[0] = null;
}
// End of the code wrapped by doc.render()
}});
return retStringArray[0];
origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

doc.render(new Runnable() { public void run() {
// Part of #33165 - the following code is wrapped by doc.render()
int lineNumber = getLineNumber();
int lineStart = NbDocument.findLineOffset(doc, lineNumber);
// #24434: Check whether the next line exists
// (the current one could be the last one).
int lineEnd;
if((lineNumber + 1) 
>= NbDocument.findLineRootElement(doc).getElementCount()) {
  lineEnd = doc.getLength();
} else {
  lineEnd = NbDocument.findLineOffset(doc, lineNumber + 1);
}

try {
  retStringArray[0] = doc.getText(lineStart, lineEnd - lineStart);
} catch (BadLocationException ex) {
  ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
  retStringArray[0] = null;
}
// End of the code wrapped by doc.render()
}});
return retStringArray[0];
origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

if (expr == null && DebuggerOption.BALLOON_EVAL.isEnabled(NativeDebuggerManager.get().globalOptions())) {
  Element lineElem =
    NbDocument.findLineRootElement(doc).
    getElement(line.getLineNumber());
org.openide.textNbDocumentfindLineRootElement

Javadoc

Find the root element of all lines. All conforming NetBeans documents should return a valid element.

Popular methods of NbDocument

  • findLineNumber
    For given document and an offset, find the line number.
  • findLineOffset
    Finds offset of the beginning of a line.
  • findLineColumn
    Finds column number given an offset.
  • runAtomic
    Locks the document to have exclusive access to it. Documents implementing Lockable can specify exact
  • createPosition
    Creates position with a bias. If the bias is javax.swing.text.Position.Bias#Backwardthen if an inser
  • findRecentEditorPane
    Gets recently selected editor pane opened by editor cookie Can be called from AWT event thread only.
  • addAnnotation
    Add annotation to the document. For annotation of whole line the length parameter can be ignored (sp
  • removeAnnotation
    Removal of added annotation. Note: since 6.35 the requests (delegated to document) are no longer rep
  • checkDocParameter
    Helper method for checking document parameter validity.
  • findPageable
    Find a way to print a given document. If the document implements the correct interface(s) then the d
  • getDocument
    Get the document associated with a file.Method will throw org.openide.util.UserQuestionExceptionexce
  • markBreakpoint
    Attach a breakpoint to a line in the document. If the document has a defined style named #BREAKPOINT
  • getDocument,
  • markBreakpoint,
  • markCurrent,
  • markError,
  • markNormal,
  • runAtomicAsUser,
  • doOpen,
  • doShow,
  • getEditToBeUndoneRedoneOfType

Popular in Java

  • Finding current android device location
  • findViewById (Activity)
  • getContentResolver (Context)
  • putExtra (Intent)
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now