本文整理汇总了Java中org.eclipse.search.core.text.TextSearchMatchAccess类的典型用法代码示例。如果您正苦于以下问题:Java TextSearchMatchAccess类的具体用法?Java TextSearchMatchAccess怎么用?Java TextSearchMatchAccess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextSearchMatchAccess类属于org.eclipse.search.core.text包,在下文中一共展示了TextSearchMatchAccess类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRenameChangeForTestImplementation
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
public Change createRenameChangeForTestImplementation(IProgressMonitor pm) {
IResource[] roots = { getProject() };
String[] fileNamePatterns = new String[] { "*.java" };
FileTextSearchScope scope = FileTextSearchScope.newSearchScope(roots, fileNamePatterns, false);
IPath path = Helper.buildGeneratedAnnotationValue(getOriginalFile());
Pattern pattern = Pattern.compile(Helper.getGeneratedAnnotationRegExp(path));
List<Change> changes = new ArrayList<Change>();
TextSearchRequestor collector = new TextSearchRequestor() {
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
IFile file = matchAccess.getFile();
Change rename = new RenameCompilationUnitChange(getProject(),file.getFullPath(), getNewName(),CompilationUnitType.TEST_IMPLEMENTATION);
changes.add(rename);
return true;
}
};
TextSearchEngine.create().search(scope, collector, pattern, pm);
if (changes.isEmpty())
return null;
CompositeChange result = new CompositeChange("Rename GraphWalker Test Implementation(s)");
Map<IPath,IPath> maps = new HashMap<IPath,IPath> ();
for (Iterator<Change> iter = changes.iterator(); iter.hasNext();) {
RenameCompilationUnitChange mc = (RenameCompilationUnitChange)iter.next();
IPath mcPath = mc.getTargetFilePath();
IPath p = maps.get(mcPath);
if (p!=null) {
String[] parts = mc.getNewName().split(Pattern.quote("."));
String newValue = parts[0] + System.currentTimeMillis() + "." + parts[1];
mc.setNewName(newValue);
}
maps.put(mc.getTargetFilePath(),mc.getTargetFilePath());
result.add(mc);
}
return result;
}
示例2: createRenameChangeForTestInterface
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
public Change createRenameChangeForTestInterface(IProgressMonitor pm) {
IResource[] roots = { getProject() };
String[] fileNamePatterns = new String[] { "*.java" };
FileTextSearchScope scope = FileTextSearchScope.newSearchScope(roots, fileNamePatterns, false);
IPath path = Helper.buildModelAnnotationValue(originalFile);
Pattern pattern = Pattern.compile(Helper.getModelAnnotationRegExp(path));
List<Change> changes = new ArrayList<Change>();
TextSearchRequestor collector = new TextSearchRequestor() {
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
IFile file = matchAccess.getFile();
Change rename = new RenameCompilationUnitChange(getProject(),file.getFullPath(), getNewName(),CompilationUnitType.TEST_INTERFACE);
changes.add(rename);
return true;
}
};
TextSearchEngine.create().search(scope, collector, pattern, pm);
if (changes.isEmpty())
return null;
CompositeChange result = new CompositeChange("Rename GraphWalker Test Interface(s)");
Map<IPath,IPath> maps = new HashMap<IPath,IPath> ();
for (Iterator<Change> iter = changes.iterator(); iter.hasNext();) {
RenameCompilationUnitChange mc = (RenameCompilationUnitChange)iter.next();
IPath p = maps.get(mc.getTargetFilePath());
if (p!=null) {
String[] parts = mc.getNewName().split(Pattern.quote("."));
mc.setNewName(parts[0] + System.currentTimeMillis() + "." + parts[1]);
}
result.add(mc);
}
return result;
}
示例3: createMoveChangeForTestImplementation
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
public Change createMoveChangeForTestImplementation(IProgressMonitor pm) {
IResource[] roots = { originalFile.getProject() };
String[] fileNamePatterns = new String[] { "*.java" };
FileTextSearchScope scope = FileTextSearchScope.newSearchScope(roots, fileNamePatterns, false);
IPath path = Helper.buildGeneratedAnnotationValue(originalFile);
Pattern pattern = Pattern.compile(Helper.getGeneratedAnnotationRegExp(path));
List<Change> changes = new ArrayList<Change>();
TextSearchRequestor collector = new TextSearchRequestor() {
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
IFile file = matchAccess.getFile();
MoveChange move = new MoveCompilationUnitChange(originalFile,file, destination,CompilationUnitType.TEST_IMPLEMENTATION);
changes.add(move);
return true;
}
};
TextSearchEngine.create().search(scope, collector, pattern, pm);
if (changes.isEmpty())
return null;
CompositeChange result = new CompositeChange("Move GraphWalker Test Implementation(s)");
for (Iterator<Change> iter = changes.iterator(); iter.hasNext();) {
Change mc = iter.next();
result.add(mc);
}
return result;
}
示例4: createMoveChangeForTestInterface
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
public Change createMoveChangeForTestInterface(IProgressMonitor pm) {
IResource[] roots = { originalFile.getProject() };
String[] fileNamePatterns = new String[] { "*.java" };
FileTextSearchScope scope = FileTextSearchScope.newSearchScope(roots, fileNamePatterns, false);
IPath path = Helper.buildModelAnnotationValue(originalFile);
Pattern pattern = Pattern.compile(Helper.getModelAnnotationRegExp(path));
List<Change> changes = new ArrayList<Change>();
TextSearchRequestor collector = new TextSearchRequestor() {
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
IFile file = matchAccess.getFile();
MoveChange move = new MoveCompilationUnitChange(originalFile,file, destination,CompilationUnitType.TEST_INTERFACE);
changes.add(move);
return true;
}
};
TextSearchEngine.create().search(scope, collector, pattern, pm);
if (changes.isEmpty())
return null;
CompositeChange result = new CompositeChange("Move GraphWalker Test Interface(s)");
for (Iterator<Change> iter = changes.iterator(); iter.hasNext();) {
Change mc = iter.next();
result.add(mc);
}
return result;
}
示例5: acceptPatternMatch
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
int start = matchAccess.getMatchOffset();
int length = matchAccess.getMatchLength();
// skip embedded FQNs (bug 130764):
if (start > 0) {
char before = matchAccess.getFileContentChar(start - 1);
if (before == '.' || Character.isJavaIdentifierPart(before)) return true;
}
int fileContentLength = matchAccess.getFileContentLength();
int end = start + length;
if (end < fileContentLength) {
char after = matchAccess.getFileContentChar(end);
if (Character.isJavaIdentifierPart(after)) return true;
}
IFile file = matchAccess.getFile();
TextChange change = fResult.getChange(file);
TextChangeCompatibility.addTextEdit(
change,
RefactoringCoreMessages.QualifiedNameFinder_update_name,
new ReplaceEdit(start, length, fNewValue),
QUALIFIED_NAMES);
return true;
}
示例6: acceptPatternMatch
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
int start= matchAccess.getMatchOffset();
int length= matchAccess.getMatchLength();
// skip embedded FQNs (bug 130764):
if (start > 0) {
char before= matchAccess.getFileContentChar(start - 1);
if (before == '.' || Character.isJavaIdentifierPart(before))
return true;
}
int fileContentLength= matchAccess.getFileContentLength();
int end= start + length;
if (end < fileContentLength) {
char after= matchAccess.getFileContentChar(end);
if (Character.isJavaIdentifierPart(after))
return true;
}
IFile file= matchAccess.getFile();
TextChange change= fResult.getChange(file);
TextChangeCompatibility.addTextEdit(
change,
RefactoringCoreMessages.QualifiedNameFinder_update_name,
new ReplaceEdit(start, length, fNewValue), QUALIFIED_NAMES);
return true;
}
示例7: acceptPatternMatch
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
int start= matchAccess.getMatchOffset();
int length= matchAccess.getMatchLength();
if (fIsKeyDoubleQuoted) {
start= start + 1;
length= length - 2;
}
fResult.add(new KeyReference(matchAccess.getFile(), null, start, length, true));
return true;
}
示例8: acceptPatternMatch
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException
{
int matchOffset = matchAccess.getMatchOffset();
if (isActualMatch(matchAccess, matchOffset))
{
List<ReplaceEdit> edits = getEdits(matchAccess.getFile());
edits.add(
new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), newValue));
}
return true;
}
示例9: isActualMatch
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
protected boolean isActualMatch(TextSearchMatchAccess matchAccess, int matchOffset)
{
if (!newValue.startsWith("\"") && (",\" "
.indexOf(matchAccess.getFileContentChar(matchOffset + matchAccess.getMatchLength())) == -1
|| ",\" ".indexOf(matchAccess.getFileContentChar(matchOffset - 1)) == -1))
return false;
StringBuilder buffer = new StringBuilder();
boolean nameRegion = false;
for (int i = 1; i < matchOffset; i++)
{
char c = matchAccess.getFileContentChar(matchOffset - i);
if (!nameRegion)
{
if (c == '=')
nameRegion = true;
}
else if (Character.isWhitespace(c) && buffer.length() > 0)
{
break;
}
else
{
buffer.insert(0, c);
}
}
return attrNames.contains(buffer.toString());
}
示例10: acceptPatternMatch
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
int start= matchAccess.getMatchOffset();
int length= matchAccess.getMatchLength();
if (fIsKeyDoubleQuoted) {
start= start + 1;
length= length - 2;
}
fResult.add(new KeyReference(matchAccess.getFile(), start, length));
return true;
}
示例11: getMatchOffsets
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
/**
* @return a list with the offsets for the match in the full string.
* Note that the offsets will be ordered
* @throws CoreException
*/
public static ArrayList<Integer> getMatchOffsets(String match, String fullString) throws CoreException {
final ArrayList<Integer> offsets = new ArrayList<Integer>();
TextSearchRequestor textSearchRequestor = new TextSearchRequestor() {
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
offsets.add(matchAccess.getMatchOffset());
return true;
}
};
TokenMatching matching = new TokenMatching(textSearchRequestor, match);
matching.collectMatches(null, fullString, new NullProgressMonitor(), false);
return offsets;
}
示例12: testMatches
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
public void testMatches() throws Exception {
final ArrayList<Integer> offsets = new ArrayList<Integer>();
TextSearchRequestor textSearchRequestor = new TextSearchRequestor() {
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
offsets.add(matchAccess.getMatchOffset());
return true;
}
};
TokenMatching matching = new TokenMatching(textSearchRequestor, "foo");
matching.collectMatches(null, "foo , foo fooba, afoo, foo)a", new NullProgressMonitor(), false);
compare(new Integer[] { 0, 6, 23 }, offsets);
compare(new Integer[] { 0, 6, 23 }, TokenMatching.getMatchOffsets("foo", "foo , foo fooba, afoo, foo)a"));
}
示例13: acceptPatternMatch
import org.eclipse.search.core.text.TextSearchMatchAccess; //导入依赖的package包/类
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchRequestor) throws CoreException {
int matchOffset = matchRequestor.getMatchOffset();
int matchLength = matchRequestor.getMatchLength();
IFile file = matchRequestor.getFile();
FileMatch fileMatch = new FileMatch(file, matchOffset, matchLength, expression);
fCachedMatches.add(fileMatch);
return true;
}