public synchronized String get(int pos, int length) throws BadLocationException { return super.get(pos, length); } /* (non-Javadoc)
@Override protected String getLine(Document d, int line) throws BadLocationException { return d.get(d.getLineOffset(line), d.getLineLength(line)); }
protected String getIndent(Document sourceDocument, ISourceRange replaceRange) throws BadLocationException { IRegion line = sourceDocument.getLineInformationOfOffset(replaceRange.getOffset()); Matcher matcher = REGEX_WHITE_SPACE_START.matcher(sourceDocument.get(line.getOffset(), line.getLength())); if (matcher.find()) { return matcher.group(1); } return ""; }
@Override public boolean isLineInformationRepairNeeded(int offset, int length, String text) throws BadLocationException { if ((0 > offset) || (0 > length) || (offset + length > getLength())) throw new BadLocationException(); return isLineInformationRepairNeeded(text) || isLineInformationRepairNeeded(get(offset, length)); }
@Override public synchronized String get(int pos, int length) throws BadLocationException { return super.get(pos, length); } /* (non-Javadoc)
@Override public boolean isLineInformationRepairNeeded(int offset, int length, String text) throws BadLocationException { if ((0 > offset) || (0 > length) || (offset + length > getLength())) throw new BadLocationException(); return isLineInformationRepairNeeded(text) || isLineInformationRepairNeeded(get(offset, length)); }
public String getContent() { return document.get(); }
public void setEditorMode(boolean editorMode) { if (fEditorMode && !editorMode) { fPreviewText= fPreviewDocument.get(); } fEditorMode= editorMode; update(); fSourceViewer.setEditable(editorMode); }
private void saveAttributeValue() { if (fCurrentAttributeSelection.size() == 1) { ((String[])fCurrentAttributeSelection.getFirstElement())[1]= fSnippetDocument.get(); } }
public static String rewriteSource(CompilationUnit cu, File file) { Document document = new Document(getSourceDoc(file.getPath())); TextEdit edits = cu.rewrite(document, formatterOptions); try { edits.apply(document); } catch (Exception e) { throw new RuntimeException(e); } return document.get(); }
public static CompilationUnit getCompilationUnit(final Path path) { final StringBuilder builder = GlobalUtils.readTextFile(path); final ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setResolveBindings(true); parser.setSource(new Document(builder.toString()).get().toCharArray()); return (CompilationUnit) parser.createAST(null); }
public static CompilationUnit getCompilationUnit(final String content) { final ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setResolveBindings(true); parser.setSource(new Document(content).get().toCharArray()); return (CompilationUnit) parser.createAST(null); }
public static CompilationUnit getCompilationUnit(final Path path) { final StringBuilder builder = GlobalUtils.readTextFile(path); final ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setResolveBindings(true); parser.setSource(new Document(builder.toString()).get().toCharArray()); return (CompilationUnit) parser.createAST(null); }
public static CompilationUnit getCompilationUnit(final String content) { final ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setResolveBindings(true); parser.setSource(new Document(content).get().toCharArray()); return (CompilationUnit) parser.createAST(null); }
public static String asFormattedString(ASTNode node, int indent, String lineDelim, Map<String, String> options) { String unformatted= asString(node); TextEdit edit= CodeFormatterUtil.format2(node, unformatted, indent, lineDelim, options); if (edit != null) { Document document= new Document(unformatted); try { edit.apply(document, TextEdit.NONE); } catch (BadLocationException e) { JavaPlugin.log(e); } return document.get(); } return unformatted; // unknown node }
protected static String getSourceFormatted(String unformattedJavaSource, IJavaProject settings, IProgressMonitor monitor, IWorkingCopyManager workingCopyManager) throws CoreException { SourceFormatOperation op = new SourceFormatOperation(settings, new Document(unformattedJavaSource)); op.validate(); op.run(monitor, workingCopyManager); return op.getDocument().get(); }