1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 145419 - Added more info to the Count Nodes menu item.

This commit is contained in:
Doug Schaefer 2006-06-07 17:54:05 +00:00
parent d205704a2c
commit 76a9aa7233
2 changed files with 32 additions and 5 deletions

View file

@ -328,6 +328,6 @@ IndexView.ToggleExternals.tooltip = Show Externaly Defined Symbols
IndexView.setFastIndexer.name = Use Fast Indexer
IndexView.CountSymbols.name = Count Symbols
IndexView.CountSymbols.title = Symbol Count
IndexView.CountSymbols.message = The PDOM contains {0} symbols.
IndexView.CountSymbols.message = The selected PDOMs contain {0} files, {1} macros; {2} symbols\r\n{3} references, {4} declarations, {5} definitions.
IndexerPreferencePage.applyToAllProjects = Apply indexer to all projects now

View file

@ -9,8 +9,10 @@ import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;
@ -39,8 +41,15 @@ public class CountNodeAction extends IndexAction {
return false;
}
static final int FILES = 0;
static final int MACROS = 1;
static final int SYMBOLS = 2;
static final int REFS = 3;
static final int DECLS = 4;
static final int DEFS = 5;
public void run() {
final int[] count = new int[1];
final int[] count = new int[6];
try {
ISelection selection = viewer.getSelection();
@ -54,6 +63,7 @@ public class CountNodeAction extends IndexAction {
ICProject project = (ICProject)objs[i];
final PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
pdom.getFileIndex().accept(new IBTreeVisitor() {
public int compare(int record) throws CoreException {
return 1;
@ -61,9 +71,10 @@ public class CountNodeAction extends IndexAction {
public boolean visit(int record) throws CoreException {
if (record != 0) {
PDOMFile file = new PDOMFile(pdom, record);
++count[FILES];
PDOMMacro macro = file.getFirstMacro();
while (macro != null) {
++count[0];
++count[MACROS];
macro = macro.getNextMacro();
}
}
@ -72,7 +83,16 @@ public class CountNodeAction extends IndexAction {
});
pdom.accept(new IPDOMVisitor() {
public boolean visit(IPDOMNode node) throws CoreException {
count[0]++;
++count[SYMBOLS];
if (node instanceof PDOMBinding) {
PDOMBinding binding = (PDOMBinding)node;
for (PDOMName name = binding.getFirstReference(); name != null; name = name.getNextInBinding())
++count[REFS];
for (PDOMName name = binding.getFirstDeclaration(); name != null; name = name.getNextInBinding())
++count[DECLS];
for (PDOMName name = binding.getFirstDefinition(); name != null; name = name.getNextInBinding())
++count[DEFS];
}
return true;
}
});
@ -84,7 +104,14 @@ public class CountNodeAction extends IndexAction {
MessageDialog.openInformation(null,
CUIPlugin.getResourceString("IndexView.CountSymbols.title"), //$NON-NLS-1$
CUIPlugin.getFormattedString("IndexView.CountSymbols.message", //$NON-NLS-1$
new String[] { String.valueOf(count[0]) }));
new String[] {
String.valueOf(count[0]),
String.valueOf(count[1]),
String.valueOf(count[2]),
String.valueOf(count[3]),
String.valueOf(count[4]),
String.valueOf(count[5])
}));
}
}