public String getText(int[] block) throws BadLocationException { return getText(block[0], block[1] - block[0]); }
public String getText() { try { return support.getDocument().getText( offset, length ); } catch( BadLocationException exc ) { // this could happen only when in inconsistent state throw new ConcurrentModificationException( "SyntaxElement in inconsistent state" ); // NOI18N } }
public String getText() { try { return support.getDocument().getText(offset, length); } catch (BadLocationException exc) { // this could happen only when in inconsistent state throw new ConcurrentModificationException("SyntaxElement in inconsistent state"); // NOI18N } }
/** * Get the identifier around the given position or null if there's no * identifier * * @see getIdentifierBlock() */ public static String getIdentifier(BaseDocument doc, int offset) throws BadLocationException { int[] blk = getIdentifierBlock(doc, offset); return (blk != null) ? doc.getText(blk[0], blk[1] - blk[0]) : null; }
/** Get the identifier around the given position or null if there's no identifier * @see getIdentifierBlock() */ public static String getIdentifier(BaseDocument doc, int offset) throws BadLocationException { int[] blk = getIdentifierBlock(doc, offset); return (blk != null) ? doc.getText(blk[0], blk[1] - blk[0]) : null; }
private boolean checkCase(BaseDocument doc, int fnw, String what) throws BadLocationException { return fnw >= 0 && fnw + what.length() <= doc.getLength() && what.equalsIgnoreCase(doc.getText(fnw, what.length())); } }
static boolean isTokenContinue(BaseDocument doc, int dotPos) { try { int rowStart = Utilities.getRowStart(doc, dotPos); if (rowStart > 1) { String prev = doc.getText(rowStart-2, 2); if ("\\\n".equals(prev)) { // NOI18N return true; } } } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } return false; } }
private static boolean checkCase(BaseDocument doc, int fnw, String what) throws BadLocationException { return fnw >= 0 && fnw + what.length() <= doc.getLength() && what.equals(doc.getText(fnw, what.length())); }
@Override public void run() { try { String docText = src.getText(0, src.getLength()); dest.insertString(0, docText, null); } catch(BadLocationException ble) { Exceptions.printStackTrace(ble); retVal[0] = false; } } });
private String asText(Assignment assignment) { String retval = ""; //NOI18N try { int start = assignment.getStartOffset(); int end = assignment.getEndOffset(); retval = doc.getText(start, end - start); } catch (BadLocationException ex) { LOGGER.log(Level.FINE, "Can't obtain assignment text.", ex); } return retval; }
private boolean isMultilinedNode(ASTNode node) { boolean result = false; try { result = document.getText(node.getStartOffset(), node.getEndOffset() - node.getStartOffset()).contains("\n"); //NOI18N } catch (BadLocationException ex) { LOGGER.log(Level.FINE, null, ex); } return result; }
@Override public void run() { try { String pfx = doc.getText(anchor, caretOffset - anchor); doc.remove(caretOffset - pfx.length(), pfx.length()); doc.insertString(caretOffset - pfx.length(), value, null); component.setCaretPosition(component.getCaretPosition() - backOffset); } catch (BadLocationException e) { Exceptions.printStackTrace(e); } } });
@Override public void implement() throws Exception { EditList edits = new EditList(doc); int startOffset = getStartOffset(doc, elementOffset); int length = elementOffset - startOffset; String replaceText = doc.getText(startOffset, length).replace(modifier, "").replaceAll("^\\s+", ""); //NOI18N edits.replace(startOffset, length, replaceText, true, 0); edits.apply(); }
private String getExpressionText(Expression expression) throws BadLocationException { int start = expression.getStartOffset(); int end = expression.getEndOffset(); return doc.getText(start, end - start); }
private String showAssertionFor188809() { String result = ""; try { result = "The same token (index: " + ts.index() + " - " + ts.token().id() + ", format tokens: " + formatTokens.size() //NOI18N + ") was precessed before.\nPlease report this to help fix issue 188809.\n\n" //NOI18N + document.getText(0, document.getLength() - 1); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } return result; }
private String createReplaceText() throws BadLocationException { String leadingText = baseDocument.getText(enclosingStatement.getStartOffset(), node.getStartOffset() - enclosingStatement.getStartOffset()); String middleText = baseDocument.getText(node.getStartOffset(), node.getEndOffset() - node.getStartOffset()); String trailingText = baseDocument.getText(node.getEndOffset(), enclosingStatement.getEndOffset() - node.getEndOffset()); return leadingText + "{\n" + middleText + "\n}" + trailingText; //NOI18N }
@Override public void implement() throws Exception { EditList edits = new EditList(doc); int startOffset = getStartOffset(doc, elementOffset); int length = elementOffset - startOffset; String replaceText = modifier + " " + doc.getText(startOffset, length); //NOI18N edits.replace(startOffset, length, replaceText, true, 0); edits.apply(); }
private String getTokenText(int offset, int length) { try { return sup.getDocument().getText(offset, length); } catch (BadLocationException e) { ErrorManager.getDefault().notify(e); return ""; } }
private boolean isRhtmlStartTag(BaseDocument doc, int offset, char[] origin) throws BadLocationException { int length = doc.getText().length(); if (length < offset + 1) { return false; } if (origin[0] == '<' && length >= offset + 1 && doc.getChars(offset + 1, 1)[0] == '%') { return true; } if (origin[0] == '%' && offset - 1 > 0) { return doc.getChars(offset - 1, 1)[0] == '<'; } return false; }
private static boolean posWithinAnyQuote(BaseDocument doc, int offset, TokenSequence<GroovyTokenId> ts) throws BadLocationException { if (ts.token().id() == GroovyTokenId.STRING_LITERAL || ts.token().id() == GroovyTokenId.STRING_CH) { char chr = doc.getText(offset, 1).charAt(0); return (offset - ts.offset() == 1 || (chr != '"' && chr != '\'')); } return false; } }