mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 13:55:39 +02:00
Cosmetics.
This commit is contained in:
parent
c644a857ba
commit
63019e2c6a
2 changed files with 26 additions and 27 deletions
|
@ -48,12 +48,12 @@ import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||||
*/
|
*/
|
||||||
public class CSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
|
public class CSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
|
||||||
private static final String KEY_SHOW_POLYMORPHIC_CALLS = "ShowPolymorphicCalls"; //$NON-NLS-1$
|
private static final String KEY_SHOW_POLYMORPHIC_CALLS = "ShowPolymorphicCalls"; //$NON-NLS-1$
|
||||||
final static MatchFilter[] ALL_FILTERS = new MatchFilter[] {HidePolymorphicCalls.FILTER};
|
final static MatchFilter[] ALL_FILTERS = new MatchFilter[] { HidePolymorphicCalls.FILTER };
|
||||||
final static MatchFilter[] NO_FILTERS = {};
|
final static MatchFilter[] NO_FILTERS = {};
|
||||||
|
|
||||||
private CSearchQuery query;
|
private CSearchQuery query;
|
||||||
private boolean indexerBusy;
|
private boolean indexerBusy;
|
||||||
|
|
||||||
public CSearchResult(CSearchQuery query) {
|
public CSearchResult(CSearchQuery query) {
|
||||||
super();
|
super();
|
||||||
this.query = query;
|
this.query = query;
|
||||||
|
@ -73,48 +73,48 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
|
||||||
final IEditorInput input= editor.getEditorInput();
|
final IEditorInput input= editor.getEditorInput();
|
||||||
IPath path= null;
|
IPath path= null;
|
||||||
if (input instanceof FileEditorInput) {
|
if (input instanceof FileEditorInput) {
|
||||||
final FileEditorInput fileInput = (FileEditorInput)input;
|
final FileEditorInput fileInput = (FileEditorInput) input;
|
||||||
path= fileInput.getFile().getLocation();
|
path= fileInput.getFile().getLocation();
|
||||||
} else if (input instanceof ExternalEditorInput) {
|
} else if (input instanceof ExternalEditorInput) {
|
||||||
final ExternalEditorInput extInput = (ExternalEditorInput)input;
|
final ExternalEditorInput extInput = (ExternalEditorInput) input;
|
||||||
path= extInput.getPath();
|
path= extInput.getPath();
|
||||||
} else if (input instanceof IStorageEditorInput) {
|
} else if (input instanceof IStorageEditorInput) {
|
||||||
try {
|
try {
|
||||||
final IStorage storage= ((IStorageEditorInput)input).getStorage();
|
final IStorage storage= ((IStorageEditorInput) input).getStorage();
|
||||||
path= storage.getFullPath();
|
path= storage.getFullPath();
|
||||||
} catch (CoreException exc) {
|
} catch (CoreException e) {
|
||||||
// ignore
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
} else if (input instanceof IPathEditorInput) {
|
} else if (input instanceof IPathEditorInput) {
|
||||||
path= ((IPathEditorInput)input).getPath();
|
path= ((IPathEditorInput) input).getPath();
|
||||||
} else {
|
} else {
|
||||||
ILocationProvider provider= (ILocationProvider) input.getAdapter(ILocationProvider.class);
|
ILocationProvider provider= (ILocationProvider) input.getAdapter(ILocationProvider.class);
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
path= provider.getPath(input);
|
path= provider.getPath(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (path != null)
|
if (path != null)
|
||||||
return path.toOSString();
|
return path.toOSString();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isShownInEditor(Match match, IEditorPart editor) {
|
public boolean isShownInEditor(Match match, IEditorPart editor) {
|
||||||
final String fileName= getFileName(editor);
|
final String fileName= getFileName(editor);
|
||||||
if (fileName != null && match instanceof CSearchMatch) {
|
if (fileName != null && match instanceof CSearchMatch) {
|
||||||
final IPath filePath= new Path(fileName);
|
final IPath filePath= new Path(fileName);
|
||||||
return filePath.equals(IndexLocationFactory.getAbsolutePath(((CSearchMatch)match).getLocation()));
|
return filePath.equals(IndexLocationFactory.getAbsolutePath(((CSearchMatch) match).getLocation()));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Match[] computeContainedMatches(AbstractTextSearchResult result, String filename) throws CoreException {
|
private Match[] computeContainedMatches(AbstractTextSearchResult result, String filename) throws CoreException {
|
||||||
IPath pfilename= new Path(filename);
|
IPath pfilename= new Path(filename);
|
||||||
List<Match> list = new ArrayList<Match>();
|
List<Match> list = new ArrayList<Match>();
|
||||||
Object[] elements = result.getElements();
|
Object[] elements = result.getElements();
|
||||||
for (int i = 0; i < elements.length; ++i) {
|
for (int i = 0; i < elements.length; ++i) {
|
||||||
if (pfilename.equals(IndexLocationFactory.getAbsolutePath(((CSearchElement)elements[i]).getLocation()))) {
|
if (pfilename.equals(IndexLocationFactory.getAbsolutePath(((CSearchElement) elements[i]).getLocation()))) {
|
||||||
Match[] matches = result.getMatches(elements[i]);
|
Match[] matches = result.getMatches(elements[i]);
|
||||||
for (int j = 0; j < matches.length; ++j) {
|
for (int j = 0; j < matches.length; ++j) {
|
||||||
if (matches[j] instanceof CSearchMatch) {
|
if (matches[j] instanceof CSearchMatch) {
|
||||||
|
@ -125,7 +125,7 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
|
||||||
}
|
}
|
||||||
return list.toArray(new Match[list.size()]);
|
return list.toArray(new Match[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
|
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
|
||||||
try {
|
try {
|
||||||
|
@ -152,17 +152,17 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
|
||||||
@Override
|
@Override
|
||||||
public IFile getFile(Object element) {
|
public IFile getFile(Object element) {
|
||||||
if (element instanceof IIndexName) {
|
if (element instanceof IIndexName) {
|
||||||
IIndexName name = (IIndexName)element;
|
IIndexName name = (IIndexName) element;
|
||||||
try {
|
try {
|
||||||
IIndexFileLocation location = name.getFile().getLocation();
|
IIndexFileLocation location = name.getFile().getLocation();
|
||||||
if(location.getFullPath()!=null) {
|
if (location.getFullPath() != null) {
|
||||||
return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath()));
|
return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath()));
|
||||||
}
|
}
|
||||||
} catch(CoreException ce) { /* fall-through to return null */ }
|
} catch(CoreException ce) { /* fall-through to return null */ }
|
||||||
} else if (element instanceof CSearchElement) {
|
} else if (element instanceof CSearchElement) {
|
||||||
CSearchElement searchElement = (CSearchElement)element;
|
CSearchElement searchElement = (CSearchElement) element;
|
||||||
IIndexFileLocation location = searchElement.getLocation();
|
IIndexFileLocation location = searchElement.getLocation();
|
||||||
if(location.getFullPath()!=null) {
|
if (location.getFullPath() != null) {
|
||||||
return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath()));
|
return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,15 +191,15 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remember whether the indexer was busy when the search was performed.
|
* Remembers whether the indexer was busy when the search was performed.
|
||||||
* @param b
|
* @param b
|
||||||
*/
|
*/
|
||||||
public void setIndexerBusy(boolean b) {
|
public void setIndexerBusy(boolean b) {
|
||||||
this.indexerBusy = b;
|
this.indexerBusy = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell if the indexer was busy when search results were gathered.
|
* Tells if the indexer was busy when search results were gathered.
|
||||||
*/
|
*/
|
||||||
public boolean wasIndexerBusy() {
|
public boolean wasIndexerBusy() {
|
||||||
return indexerBusy;
|
return indexerBusy;
|
||||||
|
@ -211,7 +211,7 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MatchFilter[] getActiveMatchFilters() {
|
public MatchFilter[] getActiveMatchFilters() {
|
||||||
MatchFilter[] result = super.getActiveMatchFilters();
|
MatchFilter[] result = super.getActiveMatchFilters();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
if (CUIPlugin.getDefault().getDialogSettings().getBoolean(KEY_SHOW_POLYMORPHIC_CALLS)) {
|
if (CUIPlugin.getDefault().getDialogSettings().getBoolean(KEY_SHOW_POLYMORPHIC_CALLS)) {
|
||||||
|
|
|
@ -6,15 +6,14 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import org.eclipse.search.ui.text.Match;
|
import org.eclipse.search.ui.text.Match;
|
||||||
import org.eclipse.search.ui.text.MatchFilter;
|
import org.eclipse.search.ui.text.MatchFilter;
|
||||||
|
|
||||||
public class HidePolymorphicCalls extends MatchFilter {
|
public class HidePolymorphicCalls extends MatchFilter {
|
||||||
|
|
||||||
public static final MatchFilter FILTER = new HidePolymorphicCalls();
|
public static final MatchFilter FILTER = new HidePolymorphicCalls();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue