本文整理汇总了Java中org.eclipse.search.ui.text.Match类的典型用法代码示例。如果您正苦于以下问题:Java Match类的具体用法?Java Match怎么用?Java Match使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Match类属于org.eclipse.search.ui.text包,在下文中一共展示了Match类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
@Override
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
startTime = System.currentTimeMillis();
AbstractTextSearchResult textResult = (AbstractTextSearchResult) getSearchResult();
textResult.removeAll();
try {
IContainer dir = configFile.getParent();
dir.accept(new AbstractSectionPatternVisitor(section) {
@Override
protected void collect(IResourceProxy proxy) {
Match match = new FileMatch((IFile) proxy.requestResource());
result.addMatch(match);
}
}, IResource.NONE);
return Status.OK_STATUS;
} catch (Exception ex) {
return new Status(IStatus.ERROR, EditorConfigPlugin.PLUGIN_ID, ex.getMessage(), ex);
}
}
示例2: initialize
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
private synchronized void initialize(AbstractTextSearchResult result) {
fResult= result;
fChildrenMap= new HashMap();
boolean showLineMatches= true; //!((TypeScriptSearchQuery) fResult.getQuery()).isFileNameSearch();
if (result != null) {
Object[] elements= result.getElements();
for (int i= 0; i < elements.length; i++) {
if (showLineMatches) {
Match[] matches= result.getMatches(elements[i]);
for (int j= 0; j < matches.length; j++) {
insert(((TypeScriptMatch) matches[j]).getLineElement(), false);
}
} else {
insert(elements[i], false);
}
}
}
}
示例3: evaluateLineStart
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
private int evaluateLineStart(Match[] matches, String lineContent, int lineOffset) {
int max= lineContent.length();
if (matches.length > 0) {
TypeScriptMatch match= (TypeScriptMatch) matches[0];
max= match.getOriginalOffset() - lineOffset;
if (max < 0) {
return 0;
}
}
for (int i= 0; i < max; i++) {
char ch= lineContent.charAt(i);
if (!Character.isWhitespace(ch) || ch == '\n' || ch == '\r') {
return i;
}
}
return max;
}
示例4: collectMatches
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
private void collectMatches(Set<Match> matches, IJavaElement element) {
Match[] m = getMatches(element);
if (m.length != 0) {
for (int i = 0; i < m.length; i++) {
matches.add(m[i]);
}
}
if (element instanceof IParent) {
IParent parent = (IParent) element;
try {
IJavaElement[] children = parent.getChildren();
for (int i = 0; i < children.length; i++) {
collectMatches(matches, children[i]);
}
} catch (JavaModelException e) {
// we will not be tracking these results
}
}
}
示例5: addMatch
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
boolean addMatch(Match match, IMatchPresentation participant) {
Object element = match.getElement();
if (fElementsToParticipants.get(element) != null) {
// TODO must access the participant id / label to properly report the error.
JavaPlugin.log(
new Status(
IStatus.WARNING,
JavaPlugin.getPluginId(),
0,
"A second search participant was found for an element",
null)); // $NON-NLS-1$
return false;
}
fElementsToParticipants.put(element, participant);
addMatch(match);
return true;
}
示例6: collectMatches
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
private void collectMatches(Set<Match> matches, IJavaElement element) {
//TODO: copied from JavaSearchResult:
Match[] m= getMatches(element);
if (m.length != 0) {
for (int i= 0; i < m.length; i++) {
matches.add(m[i]);
}
}
if (element instanceof IParent) {
IParent parent= (IParent) element;
try {
IJavaElement[] children= parent.getChildren();
for (int i= 0; i < children.length; i++) {
collectMatches(matches, children[i]);
}
} catch (JavaModelException e) {
// we will not be tracking these results
}
}
}
示例7: addMatch
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
private void addMatch(FileEntry groupElement, String propertyName) {
/*
* TODO (bug 63794): Should read in .properties file with our own reader and not
* with Properties.load(InputStream) . Then, we can remember start position and
* original version (not interpreting escape characters) for each property.
*
* The current workaround is to escape the key again before searching in the
* .properties file. However, this can fail if the key is escaped in a different
* manner than what PropertyFileDocumentModel.unwindEscapeChars(.) produces.
*/
String escapedPropertyName= PropertyFileDocumentModel.escape(propertyName, false);
int start= findPropertyNameStartPosition(escapedPropertyName);
int length;
if (start == -1) { // not found -> report at beginning
start= 0;
length= 0;
} else {
length= escapedPropertyName.length();
}
fResult.addMatch(new Match(groupElement, start, length));
}
示例8: collectMatches
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
private void collectMatches(Set<Match> matches, IJavaElement element) {
Match[] m= getMatches(element);
if (m.length != 0) {
for (int i= 0; i < m.length; i++) {
matches.add(m[i]);
}
}
if (element instanceof IParent) {
IParent parent= (IParent) element;
try {
IJavaElement[] children= parent.getChildren();
for (int i= 0; i < children.length; i++) {
collectMatches(matches, children[i]);
}
} catch (JavaModelException e) {
// we will not be tracking these results
}
}
}
示例9: computeContainedMatches
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
//TODO same code in JavaSearchResult
IEditorInput editorInput= editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
return computeContainedMatches(result, fileEditorInput.getFile());
} else if (editorInput instanceof IClassFileEditorInput) {
IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput;
IClassFile classFile= classFileEditorInput.getClassFile();
Object[] elements= getElements();
if (elements.length == 0)
return NO_MATCHES;
//all matches from same file:
JavaElementLine jel= (JavaElementLine) elements[0];
if (jel.getJavaElement().equals(classFile))
return collectMatches(elements);
}
return NO_MATCHES;
}
示例10: isShownInEditor
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
public boolean isShownInEditor(Match match, IEditorPart editor) {
Object element= match.getElement();
IJavaElement je= ((JavaElementLine) element).getJavaElement();
IEditorInput editorInput= editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
try {
return ((IFileEditorInput)editorInput).getFile().equals(je.getCorrespondingResource());
} catch (JavaModelException e) {
return false;
}
} else if (editorInput instanceof IClassFileEditorInput) {
return ((IClassFileEditorInput)editorInput).getClassFile().equals(je);
}
return false;
}
示例11: showMatch
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
@Override
public void showMatch(Match match, int offset, int length, boolean activate) throws PartInitException {
IEditorPart editor= fEditorOpener.openMatch(match);
if (editor != null && activate)
editor.getEditorSite().getPage().activate(editor);
Object element= match.getElement();
if (editor instanceof ITextEditor) {
ITextEditor textEditor= (ITextEditor) editor;
textEditor.selectAndReveal(offset, length);
} else if (editor != null) {
if (element instanceof IFile) {
IFile file= (IFile) element;
showWithMarker(editor, file, offset, length);
}
} else if (getInput() instanceof JavaSearchResult) {
JavaSearchResult result= (JavaSearchResult) getInput();
IMatchPresentation participant= result.getSearchParticpant(element);
if (participant != null)
participant.showMatch(match, offset, length, activate);
}
}
示例12: removeSearchResults
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
private void removeSearchResults(final Match[] matches)
{
final IExecutionModel model = executionModel();
model.readLock();
try
{
for (final Match match : matches)
{
final IJiveEvent event = (IJiveEvent) match.getElement();
final IInitiatorEvent execution = event.parent();
if (searchResultMap.containsKey(execution))
{
final List<IJiveEvent> results = searchResultMap.get(execution);
results.remove(event);
if (results.isEmpty())
{
searchResultMap.remove(execution);
}
}
}
}
finally
{
model.readUnlock();
}
}
示例13: search
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
protected void search(final IProgressMonitor monitor, final IQueryFactory queryFactory)
{
final EventQuery query = createQuery(queryFactory);
if (query == null)
{
return;
}
final JiveSearchResult result = (JiveSearchResult) getSearchResult();
query.open();
try
{
while (!monitor.isCanceled() && query.processEvent())
{
// add a result only if the last processed event was a match
if (query.match() != null)
{
result.addMatch(new Match(query.match(), 0, 1));
}
}
}
finally
{
query.close();
}
}
示例14: evaluateLineStart
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
private int evaluateLineStart(Match[] matches, String lineContent, int lineOffset) {
int max = lineContent.length();
if (matches.length > 0) {
ICustomMatch match = (ICustomMatch) matches[0];
max = match.getOriginalOffset() - lineOffset;
if (max < 0) {
return 0;
}
}
for (int i = 0; i < max; i++) {
char ch = lineContent.charAt(i);
if (!Character.isWhitespace(ch) || ch == '\n' || ch == '\r') {
return i;
}
}
return max;
}
示例15: handleDelta
import org.eclipse.search.ui.text.Match; //导入依赖的package包/类
private void handleDelta(IResourceDelta d) {
try {
d.accept(new IResourceDeltaVisitor() {
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
switch (delta.getKind()) {
case IResourceDelta.ADDED:
return false;
case IResourceDelta.REMOVED:
IResource res = delta.getResource();
if (res instanceof IFile) {
Match[] matches = fResult.getMatches(res);
fResult.removeMatches(matches);
}
break;
case IResourceDelta.CHANGED:
// handle changed resource (remove existing matches and redo search in file).
break;
}
return true;
}
});
} catch (CoreException e) {
Log.log(e);
}
}