From 76a9aa72333e3f567ed03aa45b95ac4cf5b230a7 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Wed, 7 Jun 2006 17:54:05 +0000 Subject: [PATCH] Bug 145419 - Added more info to the Count Nodes menu item. --- .../internal/ui/CPluginResources.properties | 2 +- .../ui/indexview/CountNodeAction.java | 35 ++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties index 5a9a64a578c..bd49071494a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties @@ -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 diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java index b282aba373f..30db548f342 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java @@ -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]) + })); } }