/** * Sets the caret where hyperlinking got initiated. * * @since 3.5 */ private void setCaret() { Point selectedRange= fTextViewer.getSelectedRange(); if (fCursorOffset != -1 && !(fSubjectRegion.getOffset() <= selectedRange.x && selectedRange.x + selectedRange.y <= fSubjectRegion.getOffset() + fSubjectRegion.getLength())) fTextViewer.setSelectedRange(fCursorOffset, 0); }
public boolean existsConflict(String proposal, ContentAssistContext context) { // hidden node between lastCompleteNode and currentNode? INode lastCompleteNode = context.getLastCompleteNode(); Region replaceRegion = context.getReplaceRegion(); int nodeEnd = lastCompleteNode.getOffset() + lastCompleteNode.getLength(); if (nodeEnd < replaceRegion.getOffset()) return false; return existsConflict(lastCompleteNode, replaceRegion.getOffset(), proposal, context); }
private static int computeInsertOffset(NLSElement[] elements, int index, ICompilationUnit cu) throws CoreException { NLSElement previousTagged= findPreviousTagged(index, elements); if (previousTagged != null) return previousTagged.getTagPosition().getOffset() + previousTagged.getTagPosition().getLength(); NLSElement nextTagged= findNextTagged(index, elements); if (nextTagged != null) return nextTagged.getTagPosition().getOffset(); return findLineEnd(cu, elements[index].getPosition().getOffset()); }
private static int computeInsertOffset(NLSElement[] elements, int index, ICompilationUnit cu) throws CoreException { NLSElement previousTagged= findPreviousTagged(index, elements); if (previousTagged != null) { return previousTagged.getTagPosition().getOffset() + previousTagged.getTagPosition().getLength(); } NLSElement nextTagged= findNextTagged(index, elements); if (nextTagged != null) { return nextTagged.getTagPosition().getOffset(); } return findLineEnd(cu, elements[index].getPosition().getOffset()); }
private boolean isAffected(ASTNode node) { if (fSubRange == null) { return true; } int nodeStart= node.getStartPosition(); int offset= fSubRange.getOffset(); return nodeStart + node.getLength() > offset && offset + fSubRange.getLength() > nodeStart; }
private static int computeInsertOffset(NLSElement[] elements, int index, int defaultValue) { NLSElement previousTagged= findPreviousTagged(index, elements); if (previousTagged != null) { return previousTagged.getTagPosition().getOffset() + previousTagged.getTagPosition().getLength(); } NLSElement nextTagged= findNextTagged(index, elements); if (nextTagged != null) { return nextTagged.getTagPosition().getOffset(); } return defaultValue; }
private TextEdit createAddTagChange(NLSElement element) { int offset= element.getTagPosition().getOffset(); //to be changed String text= ' ' + element.getTagText(); return new InsertEdit(offset, text); }
private static int computeInsertOffset(NLSElement[] elements, int index, int defaultValue) { NLSElement previousTagged= findPreviousTagged(index, elements); if (previousTagged != null) return previousTagged.getTagPosition().getOffset() + previousTagged.getTagPosition().getLength(); NLSElement nextTagged= findNextTagged(index, elements); if (nextTagged != null) return nextTagged.getTagPosition().getOffset(); return defaultValue; }
private TextEdit createAddTagChange(NLSElement element) { int offset= element.getTagPosition().getOffset(); //to be changed String text= ' ' + element.getTagText(); return new InsertEdit(offset, text); }
private void updateSourceView(IStructuredSelection selection) { NLSSubstitution first= (NLSSubstitution) selection.getFirstElement(); if (first != null) { Region region= first.getNLSElement().getPosition(); fSourceViewer.setSelectedRange(region.getOffset(), region.getLength()); fSourceViewer.revealRange(region.getOffset(), region.getLength()); } }
private void updateSourceView(IStructuredSelection selection) { NLSSubstitution first= (NLSSubstitution) selection.getFirstElement(); if (first != null) { Region region= first.getNLSElement().getPosition(); fSourceViewer.setSelectedRange(region.getOffset(), region.getLength()); fSourceViewer.revealRange(region.getOffset(), region.getLength()); } }
private void updateSourceView(IStructuredSelection selection) { NLSSubstitution first= (NLSSubstitution) selection.getFirstElement(); if (first != null) { Region region= first.getNLSElement().getPosition(); fSourceViewer.setSelectedRange(region.getOffset(), region.getLength()); fSourceViewer.revealRange(region.getOffset(), region.getLength()); } }
private void deleteTag(NLSSubstitution substitution, TextChange change) { Region textRegion= substitution.getNLSElement().getTagPosition(); TextChangeCompatibility.addTextEdit(change, NLSMessages.NLSSourceModifier_remove_tag, new DeleteEdit(textRegion.getOffset(), textRegion.getLength())); }
private void replaceKey(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialKey(), BasicElementLabels.getJavaElementName(substitution.getKey())}; ReplaceEdit replaceEdit; if (fIsEclipseNLS) replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), substitution.getKey()); else replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getKey()) + '\"'); // TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_key, args), replaceEdit); }
private void replaceKey(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialKey(), BasicElementLabels.getJavaElementName(substitution.getKey())}; ReplaceEdit replaceEdit; if (fIsEclipseNLS) replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), substitution.getKey()); else replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getKey()) + '\"'); // TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_key, args), replaceEdit); }
protected ConfigurableCompletionProposal doCreateProposal(String proposal, StyledString displayString, Image image, int priority, ContentAssistContext context) { int replacementOffset = context.getReplaceRegion().getOffset(); int replacementLength = context.getReplaceRegion().getLength(); ConfigurableCompletionProposal result = doCreateProposal(proposal, displayString, image, replacementOffset, replacementLength); result.setPriority(priority); result.setMatcher(context.getMatcher()); result.setReplaceContextLength(context.getReplaceContextLength()); return result; }
private void replaceValue(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialValue(), substitution.getValueNonEmpty()}; TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_value, args), new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getValueNonEmpty()) + '\"')); // }
private void replaceValue(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialValue(), substitution.getValueNonEmpty()}; TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_value, args), new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getValueNonEmpty()) + '\"')); // }