Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoda Amer2004-01-08 15:37:26 +0000
committerHoda Amer2004-01-08 15:37:26 +0000
commited90c66221a7252c35108bacd9e77a97ae88e8ff (patch)
tree0b10dbc2c3d0b6a819658fae312bfdf74745b183
parentc2090121417a9e628a6e5ac40e6c1ededf090e48 (diff)
downloadorg.eclipse.cdt-ed90c66221a7252c35108bacd9e77a97ae88e8ff.tar.gz
org.eclipse.cdt-ed90c66221a7252c35108bacd9e77a97ae88e8ff.tar.xz
org.eclipse.cdt-ed90c66221a7252c35108bacd9e77a97ae88e8ff.zip
Content Assist Work : Adding logging capabilities
-rw-r--r--core/org.eclipse.cdt.core/.options3
-rw-r--r--core/org.eclipse.cdt.core/ChangeLog3
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IDebugLogConstants.java3
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java14
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java4
-rw-r--r--core/org.eclipse.cdt.ui/ChangeLog3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java195
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java7
9 files changed, 225 insertions, 9 deletions
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<kinds.length; i++){
+ LookupKind kind = (LookupKind) kinds[i];
+ switch (kind.getEnumValue()){
+ case 0:
+ kindName.append("ALL");
+ break;
+ case 1:
+ kindName.append("STRUCTURES");
+ break;
+ case 2:
+ kindName.append("STRUCS");
+ break;
+ case 3:
+ kindName.append("UNIONS");
+ break;
+ case 4:
+ kindName.append("CLASSES");
+ break;
+ case 5:
+ kindName.append("FUNCTIONS");
+ break;
+ case 6:
+ kindName.append("VARIABLES");
+ break;
+ case 7:
+ kindName.append("LOCAL_VARIABLES");
+ break;
+ case 8:
+ kindName.append("MEMBERS");
+ break;
+ case 9:
+ kindName.append("METHODS");
+ break;
+ case 10:
+ kindName.append("FIELDS");
+ break;
+ case 11:
+ kindName.append("CONSTRUCTORS");
+ break;
+ case 12:
+ kindName.append("NAMESPACES");
+ break;
+ case 13:
+ kindName.append("MACROS");
+ break;
+ case 14:
+ kindName.append("ENUMERATIONS");
+ break;
+ case 15:
+ kindName.append("ENUMERATORS");
+ break;
+ case 16:
+ kindName.append("THIS");
+ break;
+ }
+ kindName.append(", ");
+ }
+ log (kindName.toString());
+ }
+ private void log(String message){
+ if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST))
+ return;
+ Util.debugLog(message, IDebugLogConstants.CONTENTASSIST, false);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java
index ea8b23af907..5641cf8de0a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java
@@ -265,7 +265,7 @@ public class ResultCollector extends CompletionRequestorAdaptor {
displayString = name;
String functionPrototype = returnType + " " + name;
if(parameterString != null){
- if ((parameterString.indexOf("(") != -1) && (parameterString.indexOf(")") != -1))
+ if ((parameterString.indexOf("(") == -1) && (parameterString.indexOf(")") == -1))
{
functionPrototype += "(" + parameterString + ")";
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
index d877a4e4f20..2cff9c6084d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
@@ -78,9 +78,9 @@ public class CUIPlugin extends AbstractUIPlugin {
private static CUIPlugin fgCPlugin;
private static ResourceBundle fgResourceBundle;
private ImageDescriptorRegistry fImageDescriptorRegistry;
-
+
static String SEPARATOR = System.getProperty("file.separator");
-
+
// -------- static methods --------
static {
@@ -213,7 +213,7 @@ public class CUIPlugin extends AbstractUIPlugin {
fDocumentProvider = null;
fTextTools = null;
}
-
+
/**
* Returns the used document provider
*/
@@ -308,6 +308,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public void startup() throws CoreException {
super.startup();
+
runUI(new Runnable() {
public void run() {
registerAdapters();

Back to the top