当前位置: 首页>>代码示例>>Java>>正文


Java Match.getLength方法代码示例

本文整理汇总了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());
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:12,代码来源:JavaQueryParticipantTest.java

示例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;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:64,代码来源:ReplaceRefactoring.java

示例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();
}
 
开发者ID:agusevas,项目名称:logan,代码行数:7,代码来源:TextSearchResult.java


注:本文中的org.eclipse.search.ui.text.Match.getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。