/** * @return PositionBounds representing the beginning of the file associated * with the <code>dataObject</code>. */ private PositionBounds getDefaultPositionBounds(){ PositionRef start = editorSupport.createPositionRef(0, Bias.Forward); PositionRef end = editorSupport.createPositionRef(0, Bias.Backward); return new PositionBounds(start, end); }
public static DiffElement create(Difference diff, FileObject fileObject, ModificationResult modification) { PositionRef start = diff.getStartPosition(); PositionRef end = diff.getEndPosition(); StyledDocument doc = null; PositionBounds bounds = new PositionBounds(start, end); return new DiffElement(diff, bounds, fileObject, modification); } }
private static PositionBounds createPositionBounds(DataObject dao, int start, int end) { CloneableEditorSupport ces = CsmUtilities.findCloneableEditorSupport(dao); if (ces != null) { PositionRef posBeg = ces.createPositionRef(start, Position.Bias.Forward); PositionRef posEnd = ces.createPositionRef(end, Position.Bias.Backward); return new PositionBounds(posBeg, posEnd); } return null; }
public static DiffElement create(Difference diff, FileObject fileObject, ModificationResult modification) { PositionRef start = diff.getStartPosition(); PositionRef end = diff.getEndPosition(); StyledDocument doc = null; PositionBounds bounds = new PositionBounds(start, end); return new DiffElement(diff, bounds, fileObject, modification); } }
/** * Factory method for DiffElement * @param diff diff instance corresponding to thid Element * @param fileObject fileObject corresponding to this Element * @param modification * @return ModificationResult corresponding to this change */ public static DiffElement create(Difference diff, FileObject fileObject, ModificationResult modification) { PositionRef start = diff.getStartPosition(); PositionRef end = diff.getEndPosition(); PositionBounds bounds = new PositionBounds(start, end); return new DiffElement(diff, bounds, fileObject, modification); } }
/** *@return PositionBounds representing the position of the name of the entity that is being * refactored or PostionBounds representing the start of the file if the position * of the entity could not be resolved. */ public PositionBounds getPositionBounds(){ if (elementName != null){ try { BaseDocument doc = getDocument(); String text = doc.getText(0, doc.getLength()); int offset = text.indexOf(elementName); if (offset > -1){ PositionRef start = editorSupport.createPositionRef(offset, Bias.Forward); PositionRef end = editorSupport.createPositionRef(offset + elementName.length(), Bias.Backward); return new PositionBounds(start, end); } } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } } return getDefaultPositionBounds(); }
/** * Factory method for DiffElement * @param diff diff instance corresponding to thid Element * @param fileObject fileObject corresponding to this Element * @param modification * @return ModificationResult corresponding to this change */ public static DiffElement create(Difference diff, FileObject fileObject, ModificationResult modification) { PositionRef start = diff.getStartPosition(); PositionRef end = diff.getEndPosition(); PositionBounds bounds = null; if (diff.getKind() != Difference.Kind.CREATE) { bounds = new PositionBounds(start, end); } return new DiffElement(diff, bounds, fileObject, modification); } }
private Occurrence createClassOccurrence(String matched, SpringBean bean) throws BadLocationException { Location loc = bean.getLocation(); if (loc == null) { return null; } int startOffset = loc.getOffset(); if (startOffset == -1) { return null; } AttributeValueFinder finder = new AttributeValueFinder(syntaxSupport, startOffset); // NOI18N if (!finder.find("class")) { return null; } int foundOffset = finder.getFoundOffset(); String foundValue = finder.getValue(); int index = foundValue.indexOf(matched); if (index == -1) { return null; } String displayText = createClassDisplayText(finder, foundValue, index, matched.length()); PositionRef startRef = docAccess.createPositionRef(foundOffset + index, Bias.Forward); PositionRef endRef = docAccess.createPositionRef(foundOffset + index + matched.length(), Bias.Backward); return new JavaElementRefOccurrence(displayText, docAccess.getFileObject(), new PositionBounds(startRef, endRef)); }
public static PositionBounds createPositionBounds(CsmOffsetable csmObj) { if (csmObj == null) { return null; } CloneableEditorSupport ces = findCloneableEditorSupport(csmObj.getContainingFile()); if (ces != null) { PositionRef beg = ces.createPositionRef(csmObj.getStartOffset(), Position.Bias.Forward); PositionRef end = ces.createPositionRef(csmObj.getEndOffset(), Position.Bias.Backward); return new PositionBounds(beg, end); } return null; }
PositionRef ref1 = ces.createPositionRef(start, Bias.Forward); PositionRef ref2 = ces.createPositionRef(end, Bias.Forward); PositionBounds bounds = new PositionBounds(ref1, ref2);
PositionRef startRef = docAccess.createPositionRef(foundOffset + index, Bias.Forward); PositionRef endRef = docAccess.createPositionRef(foundOffset + index + name.length(), Bias.Backward); result.add(new PropertyRefOccurrence(displayText, docAccess.getFileObject(), new PositionBounds(startRef, endRef))); PositionRef startRef = docAccess.createPositionRef(foundOffset + index, Bias.Forward); PositionRef endRef = docAccess.createPositionRef(foundOffset + index + name.length(), Bias.Backward); result.add(new PropertyRefOccurrence(displayText, docAccess.getFileObject(), new PositionBounds(startRef, endRef))); PositionRef startRef = docAccess.createPositionRef(foundOffset + index, Bias.Forward); PositionRef endRef = docAccess.createPositionRef(foundOffset + index + name.length(), Bias.Backward); result.add(new PropertyRefOccurrence(displayText, docAccess.getFileObject(), new PositionBounds(startRef, endRef)));
public static WhereUsedElement create(CloneableEditorSupport ces, FileObject fo, String name, String html, OffsetRange range, Icon icon) { int start = range.getStart(); int end = range.getEnd(); PositionRef ref1 = ces.createPositionRef(start, Bias.Forward); PositionRef ref2 = ces.createPositionRef(end, Bias.Forward); PositionBounds bounds = new PositionBounds(ref1, ref2); return new WhereUsedElement(bounds, html, fo, name, new OffsetRange(start, end), icon); } }
end = editor.createPositionRef(endOffset, Bias.Backward); return new PositionBounds(bgn, end);
PositionRef ref1 = ces.createPositionRef(start, Bias.Forward); PositionRef ref2 = ces.createPositionRef(end, Bias.Forward); PositionBounds bounds = new PositionBounds(ref1, ref2);
PositionRef startRef = docAccess.createPositionRef(foundOffset + index + setterElement.getStartIndex(), Bias.Forward); PositionRef endRef = docAccess.createPositionRef(foundOffset + index + setterElement.getEndIndex(), Bias.Backward); result.add(new PropertyRefOccurrence(displayText, docAccess.getFileObject(), new PositionBounds(startRef, endRef)));
public static WhereUsedElement create(JsParseResult info, String name, String html, OffsetRange range, Icon icon) { int start = range.getStart(); int end = range.getEnd(); CloneableEditorSupport ces = RetoucheUtils.findCloneableEditorSupport(info); PositionRef ref1 = ces.createPositionRef(start, Bias.Forward); PositionRef ref2 = ces.createPositionRef(end, Bias.Forward); PositionBounds bounds = new PositionBounds(ref1, ref2); return new WhereUsedElement(bounds, html, info.getSnapshot().getSource().getFileObject(), name, new OffsetRange(start, end), icon); } }
public void run() { synchronized (editor.getLock()) { /* editor.getLock(): fixes deadlock - this lock is acquired later anyhow, so we are changing the order in which the locks are acquired */ try { // [MaM] remember doclen to compute new length // of the inserted string (the length changes // because insertString removes \r characters // from it) int docLen = doc.getLength(); int p1 = end.getOffset(); doc.insertString (p1, text, null); int p2 = p1 + doc.getLength() - docLen; end = editor.createPositionRef(p1, end.getPositionBias()); PositionRef posBegin = editor.createPositionRef(p1, Position.Bias.Forward); PositionRef posEnd = editor.createPositionRef(p2, Position.Bias.Backward); hold[1] = new PositionBounds(posBegin, posEnd); } catch (BadLocationException e) { hold[0] = e; } } } };
PositionRef startRef = docAccess.createPositionRef(foundOffset + index + pathElement.getStartIndex(), Bias.Forward); PositionRef endRef = docAccess.createPositionRef(foundOffset + index + pathElement.getEndIndex(), Bias.Backward); result.add(new PropertyRefOccurrence(displayText, docAccess.getFileObject(), new PositionBounds(startRef, endRef)));
public void run() { synchronized (editor.getLock()) { /* editor.getLock(): fixes deadlock - this lock is acquired later anyhow, so we are changing the order in which the locks are acquired */ try { // [MaM] remember doclen to compute new length // of the inserted string (the length changes // because insertString removes \r characters // from it) int docLen = doc.getLength(); int p1 = end.getOffset(); doc.insertString(p1, text, null); int p2 = (p1 + doc.getLength()) - docLen; end = editor.createPositionRef(p1, end.getPositionBias()); PositionRef posBegin = editor.createPositionRef(p1, Position.Bias.Forward); PositionRef posEnd = editor.createPositionRef(p2, Position.Bias.Backward); hold[1] = new PositionBounds(posBegin, posEnd); } catch (BadLocationException e) { hold[0] = e; } } } };
public void run() { synchronized (editor.getLock()) { /* editor.getLock(): fixes deadlock - this lock is acquired later anyhow, so we are changing the order in which the locks are acquired */ try { // [MaM] remember doclen to compute new length // of the inserted string (the length changes // because insertString removes \r characters // from it) int docLen = doc.getLength(); int p1 = end.getOffset(); doc.insertString (p1, text, null); int p2 = p1 + doc.getLength() - docLen; end = editor.createPositionRef(p1, end.getPositionBias()); PositionRef posBegin = editor.createPositionRef(p1, Position.Bias.Forward); PositionRef posEnd = editor.createPositionRef(p2, Position.Bias.Backward); hold[1] = new PositionBounds(posBegin, posEnd); } catch (BadLocationException e) { hold[0] = e; } } } };