private static int findReplaceEndPos(IDocument doc, String newText, String oldText, int pos) { if (oldText.length() == 0 || oldText.equals(newText)) { return pos; } try { IRegion lineInfo= doc.getLineInformationOfOffset(pos); int end= lineInfo.getOffset() + lineInfo.getLength(); // for html, search the tag end character return findClosingCharacter(doc, pos, end, '>'); } catch (BadLocationException e) { // ignore } return pos; }
private static int findReplaceEndPos(IDocument doc, String newText, String oldText, int pos) { if (oldText.length() == 0 || oldText.equals(newText)) { return pos; } try { IRegion lineInfo= doc.getLineInformationOfOffset(pos); int end= lineInfo.getOffset() + lineInfo.getLength(); // for html, search the tag end character return findClosingCharacter(doc, pos, end, '>'); } catch (BadLocationException e) { // ignore } return pos; }
private static int findReplaceEndPos(IDocument doc, String newText, String oldText, int pos) { if (oldText.length() == 0 || oldText.equals(newText)) { return pos; } try { IRegion lineInfo= doc.getLineInformationOfOffset(pos); int end= lineInfo.getOffset() + lineInfo.getLength(); // for html, search the tag end character return findClosingCharacter(doc, pos, end, '>'); } catch (BadLocationException e) { // ignore } return pos; }
public String[] getArguments() { String prefix= ""; //$NON-NLS-1$ String postfix= ""; //$NON-NLS-1$ try { IRegion line= fDocument.getLineInformationOfOffset(fSourceStart); prefix= fDocument.get(line.getOffset(), fSourceStart - line.getOffset()); postfix= fDocument.get(fSourceEnd + 1, line.getOffset() + line.getLength() - fSourceEnd); } catch (BadLocationException exception) { // Do nothing } return new String[] { fWord, prefix, postfix, fSentence ? Boolean.toString(true) : Boolean.toString(false), fMatch ? Boolean.toString(true) : Boolean.toString(false) }; }
private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException { IDocumentProvider documentProvider= editor.getDocumentProvider(); if (documentProvider == null) { return null; } IDocument document= documentProvider.getDocument(editor.getEditorInput()); if (document == null) { return null; } return document.getLineInformationOfOffset(invocationLocation); }
private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException { IDocumentProvider documentProvider= editor.getDocumentProvider(); if (documentProvider == null) { return null; } IDocument document= documentProvider.getDocument(editor.getEditorInput()); if (document == null) { return null; } return document.getLineInformationOfOffset(invocationLocation); }
@Override public String[] getArguments() { String prefix= ""; //$NON-NLS-1$ String postfix= ""; //$NON-NLS-1$ try { IRegion line= fDocument.getLineInformationOfOffset(fSourceStart); prefix= fDocument.get(line.getOffset(), fSourceStart - line.getOffset()); int postfixStart= fSourceEnd + 1; postfix= fDocument.get(postfixStart, line.getOffset() + line.getLength() - postfixStart); } catch (BadLocationException exception) { // Do nothing } return new String[] { fWord, prefix, postfix, fSentence ? Boolean.toString(true) : Boolean.toString(false), fMatch ? Boolean.toString(true) : Boolean.toString(false) }; }
private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException { IDocumentProvider documentProvider = editor.getDocumentProvider(); if (documentProvider == null) { return null; } IDocument document = documentProvider.getDocument(editor.getEditorInput()); if (document == null) { return null; } return document.getLineInformationOfOffset(invocationLocation); }
private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException { IDocumentProvider documentProvider= editor.getDocumentProvider(); if (documentProvider == null) { return null; } IDocument document= documentProvider.getDocument(editor.getEditorInput()); if (document == null) { return null; } return document.getLineInformationOfOffset(invocationLocation); }
private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException { IDocumentProvider documentProvider= editor.getDocumentProvider(); if (documentProvider == null) { return null; } IDocument document= documentProvider.getDocument(editor.getEditorInput()); if (document == null) { return null; } return document.getLineInformationOfOffset(invocationLocation); }
private static String getIndentAt(IDocument document, int offset, CodeGenerationSettings settings) { try { IRegion region= document.getLineInformationOfOffset(offset); return IndentManipulation.extractIndentString(document.get(region.getOffset(), region.getLength()), settings.tabWidth, settings.indentWidth); } catch (BadLocationException e) { return ""; //$NON-NLS-1$ } }
private String getLineIndentation(IDocument document, int offset) throws BadLocationException { // find start of line int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset); IRegion line= document.getLineInformationOfOffset(adjustedOffset); int start= line.getOffset(); // find white spaces int end= findEndOfWhiteSpace(document, start, offset); return document.get(start, end - start); }
private static String getIndentAt(IDocument document, int offset, CodeGenerationSettings settings) { try { IRegion region= document.getLineInformationOfOffset(offset); return IndentManipulation.extractIndentString(document.get(region.getOffset(), region.getLength()), settings.tabWidth, settings.indentWidth); } catch (BadLocationException e) { return ""; //$NON-NLS-1$ } }
private String getLineIndentation(IDocument document, int offset) throws BadLocationException { // find start of line int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset); IRegion line= document.getLineInformationOfOffset(adjustedOffset); int start= line.getOffset(); // find white spaces int end= findEndOfWhiteSpace(document, start, offset); return document.get(start, end - start); }
private String getLineIndentation(IDocument document, int offset) throws BadLocationException { // find start of line int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset); IRegion line= document.getLineInformationOfOffset(adjustedOffset); int start= line.getOffset(); // find white spaces int end= findEndOfWhiteSpace(document, start, offset); return document.get(start, end - start); }
private static String getIndentAt(IDocument document, int offset, CodeGenerationSettings settings) { try { IRegion region= document.getLineInformationOfOffset(offset); return IndentManipulation.extractIndentString(document.get(region.getOffset(), region.getLength()), settings.tabWidth, settings.indentWidth); } catch (BadLocationException e) { return ""; //$NON-NLS-1$ } }
private static String getIndentAt(final IDocument document, final int offset, final CodeGenerationSettings settings) { try { IRegion region = document.getLineInformationOfOffset(offset); return IndentManipulation.extractIndentString(document.get(region.getOffset(), region.getLength()), settings.tabWidth, settings.indentWidth); } catch (BadLocationException e) { return ""; } }
private static Position getPosition(ASTNode node, IDocument document) { int offset = node.getStartPosition(); try { IRegion region = document.getLineInformationOfOffset(offset); return new Position(region.getOffset() + region.getLength(), 1); } catch (BadLocationException e) { return new Position(offset, 1); } }
@Override public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { try { IRegion startLineInfo= fDocument.getLineInformationOfOffset(subRegion.getOffset()); IRegion endLineInfo= fDocument.getLineInformationOfOffset(subRegion.getOffset() + Math.max(0, subRegion.getLength() - 1)); if (startLineInfo.getOffset() == endLineInfo.getOffset()) subRegion= startLineInfo; else subRegion= new Region(startLineInfo.getOffset(), endLineInfo.getOffset() + Math.max(0, endLineInfo.getLength() - 1) - startLineInfo.getOffset()); } catch (BadLocationException e) { subRegion= new Region(0, fDocument.getLength()); } reconcile(subRegion); }
private String formatElement(IDocument document, TypedPosition partition) throws BadLocationException { String partitionText = document.get(partition.getOffset(), partition.getLength()); IRegion line = document.getLineInformationOfOffset(partition.getOffset()); int indentLength = partition.getOffset() - line.getOffset(); String lineDelimiter = document.getLineDelimiter(document.getLineOfOffset(line.getOffset())); if (lineDelimiter == null) { lineDelimiter = TextUtilities.getDefaultLineDelimiter(document); } return XmlTagFormatter.format(partitionText, prefs, document.get(line.getOffset(), indentLength), lineDelimiter); }