Java Code Examples for org.eclipse.text.edits.TextEdit#getCoverage()

The following examples show how to use org.eclipse.text.edits.TextEdit#getCoverage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenameAnalyzeUtil.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
/**
 *
 * @param change
 * @return Map <Integer oldOffset, Integer updatedOffset>
 */
private static Map<Integer, Integer> getEditChangeOffsetUpdates(TextChange change) {
	TextEditChangeGroup[] editChanges= change.getTextEditChangeGroups();
	Map<Integer, Integer> offsetUpdates= new HashMap<>(editChanges.length);
	for (int i= 0; i < editChanges.length; i++) {
		TextEditChangeGroup editChange= editChanges[i];
		IRegion oldRegion= editChange.getRegion();
		if (oldRegion == null) {
			continue;
		}
		IRegion updatedRegion= TextEdit.getCoverage(change.getPreviewEdits(editChange.getTextEdits()));
		if (updatedRegion == null) {
			continue;
		}

		offsetUpdates.put(Integer.valueOf(oldRegion.getOffset()), Integer.valueOf(updatedRegion.getOffset()));
	}
	return offsetUpdates;
}
 
Example 2
Source File: RenameAnalyzeUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 *
 * @param change
 * @return Map &lt;Integer oldOffset, Integer updatedOffset&gt;
 */
private static Map<Integer, Integer> getEditChangeOffsetUpdates(TextChange change) {
	TextEditChangeGroup[] editChanges= change.getTextEditChangeGroups();
	Map<Integer, Integer> offsetUpdates= new HashMap<Integer, Integer>(editChanges.length);
	for (int i= 0; i < editChanges.length; i++) {
		TextEditChangeGroup editChange= editChanges[i];
		IRegion oldRegion= editChange.getRegion();
		if (oldRegion == null)
			continue;
		IRegion updatedRegion= TextEdit.getCoverage(change.getPreviewEdits(editChange.getTextEdits()));
		if (updatedRegion == null)
			continue;

		offsetUpdates.put(new Integer(oldRegion.getOffset()), new Integer(updatedRegion.getOffset()));
	}
	return offsetUpdates;
}
 
Example 3
Source File: RenameAnalyzeUtil.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static IRegion getCorrespondingEditChangeRange(SearchMatch searchResult, TextChangeManager manager) {
	TextChange change= getTextChange(searchResult, manager);
	if (change == null) {
		return null;
	}

	IRegion oldMatchRange= createTextRange(searchResult);
	TextEditChangeGroup[] editChanges= change.getTextEditChangeGroups();
	for (int i= 0; i < editChanges.length; i++) {
		if (oldMatchRange.equals(editChanges[i].getRegion())) {
			return TextEdit.getCoverage(change.getPreviewEdits(editChanges[i].getTextEdits()));
		}
	}
	return null;
}
 
Example 4
Source File: RenameAnalyzeUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static IRegion getCorrespondingEditChangeRange(SearchMatch searchResult, TextChangeManager manager) {
	TextChange change= getTextChange(searchResult, manager);
	if (change == null)
		return null;

	IRegion oldMatchRange= createTextRange(searchResult);
	TextEditChangeGroup[] editChanges= change.getTextEditChangeGroups();
	for (int i= 0; i < editChanges.length; i++) {
		if (oldMatchRange.equals(editChanges[i].getRegion()))
			return TextEdit.getCoverage(change.getPreviewEdits(editChanges[i].getTextEdits()));
	}
	return null;
}
 
Example 5
Source File: TrackedNodePosition.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public int getStartPosition() {
	if (this.group.isEmpty()) {
		return this.node.getStartPosition();
	}
	IRegion coverage= TextEdit.getCoverage(this.group.getTextEdits());
	if (coverage == null) {
		return this.node.getStartPosition();
	}
	return coverage.getOffset();
}
 
Example 6
Source File: TrackedNodePosition.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public int getLength() {
	if (this.group.isEmpty()) {
		return this.node.getLength();
	}
	IRegion coverage= TextEdit.getCoverage(this.group.getTextEdits());
	if (coverage == null) {
		return this.node.getLength();
	}
	return coverage.getLength();
}