本文整理汇总了Java中org.eclipse.search.ui.text.Match.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java Match.getLength方法的具体用法?Java Match.getLength怎么用?Java Match.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.search.ui.text.Match
的用法示例。
在下文中一共展示了Match.getLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import org.eclipse.search.ui.text.Match; //导入方法依赖的package包/类
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Match)) {
return false;
}
// We only care about matching the offset/length; we can ignore the
// container element (see comment in constructor)
Match other = (Match) obj;
return (this.getOffset() == other.getOffset() && this.getLength() == other.getLength());
}
示例2: createFileChange
import org.eclipse.search.ui.text.Match; //导入方法依赖的package包/类
private TextChange createFileChange(IFile file, Pattern pattern, Collection<Match> matches,
RefactoringStatus resultingStatus, Collection<MatchGroup> matchGroups)
throws PatternSyntaxException, CoreException {
PositionTracker tracker = InternalSearchUI.getInstance().getPositionTracker();
TextFileChange change = new SynchronizedTextFileChange(MessageFormat.format(
SearchMessages.ReplaceRefactoring_group_label_change_for_file, file.getName()), file);
change.setEdit(new MultiTextEdit());
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.connect(file.getFullPath(), LocationKind.IFILE, null);
try {
ITextFileBuffer textFileBuffer = manager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
if (textFileBuffer == null) {
resultingStatus
.addError(MessageFormat.format(SearchMessages.ReplaceRefactoring_error_accessing_file_buffer,
file.getName()));
return null;
}
IDocument document = textFileBuffer.getDocument();
String lineDelimiter = TextUtilities.getDefaultLineDelimiter(document);
for (Iterator<Match> iterator = matches.iterator(); iterator.hasNext();) {
Match match = iterator.next();
int offset = match.getOffset();
int length = match.getLength();
Position currentPosition = tracker.getCurrentPosition(match);
if (currentPosition != null) {
offset = currentPosition.offset;
if (length != currentPosition.length) {
resultingStatus.addError(MessageFormat.format(
SearchMessages.ReplaceRefactoring_error_match_content_changed, file.getName()));
continue;
}
}
String originalText = getOriginalText(document, offset, length);
if (originalText == null) {
resultingStatus.addError(MessageFormat.format(
SearchMessages.ReplaceRefactoring_error_match_content_changed, file.getName()));
continue;
}
String replacementString = computeReplacementString(pattern, originalText, fReplaceString,
lineDelimiter);
if (replacementString == null) {
resultingStatus.addError(MessageFormat.format(
SearchMessages.ReplaceRefactoring_error_match_content_changed, file.getName()));
continue;
}
ReplaceEdit replaceEdit = new ReplaceEdit(offset, length, replacementString);
change.addEdit(replaceEdit);
TextEditChangeGroup textEditChangeGroup = new TextEditChangeGroup(change, new TextEditGroup(
SearchMessages.ReplaceRefactoring_group_label_match_replace, replaceEdit));
change.addTextEditChangeGroup(textEditChangeGroup);
matchGroups.add(new MatchGroup(textEditChangeGroup, match));
}
} finally {
manager.disconnect(file.getFullPath(), LocationKind.IFILE, null);
}
return change;
}
示例3: compare
import org.eclipse.search.ui.text.Match; //导入方法依赖的package包/类
private static int compare(Match match1, Match match2) {
int diff = match2.getOffset() - match1.getOffset();
if (diff != 0)
return diff;
return match2.getLength() - match1.getLength();
}