Java Code Examples for org.netbeans.editor.Utilities#isRowWhite()
The following examples show how to use
org.netbeans.editor.Utilities#isRowWhite() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsTypedBreakInterceptor.java From netbeans with Apache License 2.0 | 6 votes |
/** * Computes the indentation of the next line (after the line break). * * @param doc document * @param offset current offset * @return indentation size * @throws BadLocationException */ private int getNextLineIndentation(BaseDocument doc, int offset) throws BadLocationException { int indent = GsfUtilities.getLineIndent(doc, offset); int currentOffset = offset; while (currentOffset > 0) { if (!Utilities.isRowEmpty(doc, currentOffset) && !Utilities.isRowWhite(doc, currentOffset) && !isCommentOnlyLine(doc, currentOffset, language)) { indent = GsfUtilities.getLineIndent(doc, currentOffset); int parenBalance = getLineBalance(doc, currentOffset, JsTokenId.BRACKET_LEFT_PAREN, JsTokenId.BRACKET_RIGHT_PAREN); if (parenBalance < 0) { break; } int curlyBalance = getLineBalance(doc, currentOffset, JsTokenId.BRACKET_LEFT_CURLY, JsTokenId.BRACKET_RIGHT_CURLY); if (curlyBalance > 0) { indent += IndentUtils.indentLevelSize(doc); } return indent; } currentOffset = Utilities.getRowStart(doc, currentOffset) - 1; } return indent; }
Example 2
Source File: GroovyTypedBreakInterceptor.java From netbeans with Apache License 2.0 | 6 votes |
/** * Computes the indentation of the next line (after the line break). * * @param doc document * @param offset current offset * @return indentation size * @throws BadLocationException */ private int getNextLineIndentation(BaseDocument doc, int offset) throws BadLocationException { int indent = GsfUtilities.getLineIndent(doc, offset); int currentOffset = offset; while (currentOffset > 0) { if (!Utilities.isRowEmpty(doc, currentOffset) && !Utilities.isRowWhite(doc, currentOffset) && !LexUtilities.isCommentOnlyLine(doc, currentOffset)) { indent = GsfUtilities.getLineIndent(doc, currentOffset); int parenBalance = LexUtilities.getLineBalance(doc, currentOffset, GroovyTokenId.LPAREN, GroovyTokenId.RPAREN); if (parenBalance < 0) { break; } int curlyBalance = LexUtilities.getLineBalance(doc, currentOffset, GroovyTokenId.LBRACE, GroovyTokenId.RBRACE); if (curlyBalance > 0) { indent += IndentUtils.indentLevelSize(doc); } return indent; } currentOffset = Utilities.getRowStart(doc, currentOffset) - 1; } return indent; }
Example 3
Source File: CslTestBase.java From netbeans with Apache License 2.0 | 6 votes |
public static int getLineIndent(BaseDocument doc, int offset) { try { int start = Utilities.getRowStart(doc, offset); int end; if (Utilities.isRowWhite(doc, start)) { end = Utilities.getRowEnd(doc, offset); } else { end = Utilities.getRowFirstNonWhite(doc, start); } int indent = Utilities.getVisualColumn(doc, end); return indent; } catch (BadLocationException ble) { Exceptions.printStackTrace(ble); return 0; } }
Example 4
Source File: YamlKeystrokeHandler.java From netbeans with Apache License 2.0 | 6 votes |
public static int getLineIndent(BaseDocument doc, int offset) { try { int start = Utilities.getRowStart(doc, offset); int end; if (Utilities.isRowWhite(doc, start)) { end = Utilities.getRowEnd(doc, offset); } else { end = Utilities.getRowFirstNonWhite(doc, start); } int indent = Utilities.getVisualColumn(doc, end); return indent; } catch (BadLocationException ble) { Exceptions.printStackTrace(ble); return 0; } }
Example 5
Source File: ImportHelper.java From netbeans with Apache License 2.0 | 5 votes |
private static void addImportStatements(FileObject fo, List<String> fqNames) { BaseDocument doc = LexUtilities.getDocument(fo, true); if (doc == null) { return; } for (String fqName : fqNames) { EditList edits = new EditList(doc); try { int packageLine = getPackageLineIndex(doc); int afterPackageLine = packageLine + 1; int afterPackageOffset = Utilities.getRowStartFromLineOffset(doc, afterPackageLine); int importLine = getAppropriateLine(doc, fqName); // If the line after the package statement isn't empty, put one empty line there if (!Utilities.isRowWhite(doc, afterPackageOffset)) { edits.replace(afterPackageOffset, 0, "\n", false, 0); } else { if (collectImports(doc).isEmpty()) { importLine++; } } // Find appropriate place to import and put it there int importOffset = Utilities.getRowStartFromLineOffset(doc, importLine); edits.replace(importOffset, 0, "import " + fqName + "\n", false, 0); // If it's the last import and if the line after the last import // statement isn't empty, put one empty line there int afterImportsOffset = Utilities.getRowStartFromLineOffset(doc, importLine); if (!Utilities.isRowWhite(doc, afterImportsOffset) && isLastImport(doc, fqName)) { edits.replace(afterImportsOffset, 0, "\n", false, 0); } } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } edits.apply(); } }
Example 6
Source File: ExtSyntaxSupport.java From netbeans with Apache License 2.0 | 4 votes |
/** Does the line contain some valid code besides of possible white space * and comments? */ public boolean isRowValid(int offset) throws BadLocationException { return Utilities.isRowWhite(getDocument(), offset); }