diff --git a/core/org.eclipse.cdt.core/.options b/core/org.eclipse.cdt.core/.options index 0bca2486a24..f90da88b7f6 100644 --- a/core/org.eclipse.cdt.core/.options +++ b/core/org.eclipse.cdt.core/.options @@ -6,6 +6,9 @@ org.eclipse.cdt.core/debug/model=false # Reports parser activity org.eclipse.cdt.core/debug/parser=false +# Reports contentAssist activity +org.eclipse.cdt.core/debug/contentassist=false + # Reports background indexer activity: indexing, saving index file, index queries org.eclipse.cdt.core/debug/indexmanager=false diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 975cb42a55f..52fc47ae2b4 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,6 @@ +2004-01-08 Hoda Amer + Added Content assist log capabilities + 2004-01-06 Alain Magloire Simple draft implementation of stabs debug format parsing. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IDebugLogConstants.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IDebugLogConstants.java index 586a696a3f1..ff791844b2c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IDebugLogConstants.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IDebugLogConstants.java @@ -23,5 +23,6 @@ public interface IDebugLogConstants { public static final DebugLogConstant PARSER = new DebugLogConstant( 1 ); public static final DebugLogConstant MODEL = new DebugLogConstant ( 2 ); - + public static final DebugLogConstant CONTENTASSIST = new DebugLogConstant ( 3 ); + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java index 85385340517..7a84ab46711 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java @@ -26,6 +26,7 @@ public class Util implements ICLogConstants { public static boolean VERBOSE_PARSER = false; public static boolean VERBOSE_MODEL = false; + public static boolean VERBOSE_CONTENTASSIST = false; private Util() { } @@ -183,12 +184,16 @@ public class Util implements ICLogConstants { Util.log(status, logType); } - public static void debugLog(String message, DebugLogConstant client) { + Util.debugLog(message, client, true); + } + + public static void debugLog(String message, DebugLogConstant client, boolean addTimeStamp) { if( CCorePlugin.getDefault() == null ) return; if ( CCorePlugin.getDefault().isDebugging() && isActive(client)) { // Time stamp - message = MessageFormat.format( "[{0}] {1}", new Object[] { new Long( System.currentTimeMillis() ), message } ); + if(addTimeStamp) + message = MessageFormat.format( "[{0}] {1}", new Object[] { new Long( System.currentTimeMillis() ), message } ); while (message.length() > 100) { String partial = message.substring(0, 100); message = message.substring(100); @@ -206,13 +211,16 @@ public class Util implements ICLogConstants { * @param client * @return */ - private static boolean isActive(DebugLogConstant client) { + public static boolean isActive(DebugLogConstant client) { if (client.equals(IDebugLogConstants.PARSER)){ return VERBOSE_PARSER; } else if (client.equals(IDebugLogConstants.MODEL)){ return VERBOSE_MODEL; } + else if (client.equals(IDebugLogConstants.CONTENTASSIST)){ + return VERBOSE_CONTENTASSIST; + } return false; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 8d306ef9e41..e338490f1c5 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -719,6 +719,7 @@ public class CCorePlugin extends Plugin { private static final String MATCH_LOCATOR = CCorePlugin.PLUGIN_ID + "/debug/matchlocator" ; //$NON-NLS-1$ private static final String PARSER = CCorePlugin.PLUGIN_ID + "/debug/parser" ; //$NON-NLS-1$ private static final String DELTA = CCorePlugin.PLUGIN_ID + "/debug/deltaprocessor" ; + private static final String CONTENTASSIST = CCorePlugin.PLUGIN_ID + "/debug/contentassist" ; //$NON-NLS-1$ /** * Configure the plugin with respect to option settings defined in ".options" file */ @@ -731,6 +732,9 @@ public class CCorePlugin extends Plugin { option = Platform.getDebugOption(MODEL); if(option != null) Util.VERBOSE_MODEL = option.equalsIgnoreCase("true") ; //$NON-NLS-1$ + option = Platform.getDebugOption(CONTENTASSIST); + if(option != null) Util.VERBOSE_CONTENTASSIST = option.equalsIgnoreCase("true") ; //$NON-NLS-1$ + boolean indexFlag = false; option = Platform.getDebugOption(INDEX_MANAGER); if(option != null) { diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index dfa775d4f94..c1724963ff8 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,6 @@ +2004-01-08 Hoda Amer + Added Content assist log cpabilities + 2004-01-07 Alain Magloire Fix for bug 49595 diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java index e76145330cf..22895896729 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java @@ -17,6 +17,7 @@ import java.util.Iterator; import java.util.List; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.parser.IParser; @@ -33,6 +34,7 @@ import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.ast.ASTClassKind; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTCodeScope; +import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode; import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.parser.ast.IASTEnumerator; @@ -49,7 +51,9 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind; import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult; import org.eclipse.cdt.internal.core.CharOperation; +import org.eclipse.cdt.internal.core.model.IDebugLogConstants; import org.eclipse.cdt.internal.core.model.IWorkingCopy; +import org.eclipse.cdt.internal.core.model.Util; import org.eclipse.cdt.internal.core.parser.util.ASTUtil; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IProject; @@ -384,6 +388,7 @@ public class CompletionEngine implements RelevanceConstants{ private LookupResult lookup(IASTScope searchNode, String prefix, LookupKind[] kinds, IASTNode context){ try { + logLookups (kinds); LookupResult result = searchNode.lookup (prefix, kinds, context); return result ; } catch (IASTNode.LookupException ilk ){ @@ -552,8 +557,16 @@ public class CompletionEngine implements RelevanceConstants{ // 1- Parse the translation unit IASTCompletionNode completionNode = parse(sourceUnit, completionOffset); - if (completionNode == null) + log(""); + + if (completionNode == null){ + log("Null Completion Node Error"); return null; + } + + logNode("Scope = " , completionNode.getCompletionScope()); + logNode("Context = " , completionNode.getCompletionContext()); + logKind("Kind = ", completionNode.getCompletionKind().getEnumValue()); // set the completionStart and the completionLength completionStart = completionOffset - completionNode.getCompletionPrefix().length(); @@ -622,5 +635,185 @@ public class CompletionEngine implements RelevanceConstants{ return completionNode; } + private void logKind(String message, int kindEnum){ + if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST) ) + return; + + String kindStr = ""; + switch (kindEnum){ + case 0: + kindStr = "MEMBER_REFERENCE"; + break; + case 1: + kindStr = "SCOPED_REFERENCE"; + break; + + case 2: + kindStr = "FIELD_TYPE"; + break; + + case 3: + kindStr = "VARIABLE_TYPE"; + break; + + case 4: + kindStr = "ARGUMENT_TYPE"; + break; + + case 5: + kindStr = "SINGLE_NAME_REFERENCE"; + break; + + case 6: + kindStr = "TYPE_REFERENCE"; + break; + + case 7: + kindStr = "CLASS_REFERENCE"; + break; + + case 8: + kindStr = "NAMESPACE_REFERENCE"; + break; + + case 9: + kindStr = "EXCEPTION_REFERENCE"; + break; + + case 10: + kindStr = "MACRO_REFERENCE"; + break; + + case 11: + kindStr = "FUNCTION_REFERENCE"; + break; + + case 12: + kindStr = "CONSTRUCTOR_REFERENCE"; + break; + + case 13: + kindStr = "KEYWORD"; + break; + + case 14: + kindStr = "PREPROCESSOR_DIRECTIVE"; + break; + + case 15: + kindStr = "USER_SPECIFIED_NAME"; + break; + + case 200: + kindStr = "NO_SUCH_KIND"; + break; + } + log (message + kindStr); + } + private void logNode(String message, IASTNode node){ + if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST)) + return; + + if(node == null){ + log(message + "null"); + return; + } + if(node instanceof IASTMethod){ + String name = "Method: "; + name += ((IASTMethod)node).getName(); + log(message + name); + return; + } + if(node instanceof IASTFunction){ + String name = "Function: "; + name += ((IASTFunction)node).getName(); + log(message + name); + return; + } + if(node instanceof IASTClassSpecifier){ + String name = "Class: "; + name += ((IASTClassSpecifier)node).getName(); + log(message + name); + return; + } + if(node instanceof IASTCompilationUnit){ + String name = "Global"; + log(message + name); + return; + } + + log(message + node.toString()); + return; + + } + private void logLookups(LookupKind[] kinds){ + if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST)) + return; + + StringBuffer kindName = new StringBuffer("Looking For "); + for(int i = 0; i