Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] FIXED 78574 - [Parser][IProblem] assert() breaks the parser


FIXED 78574 - [Parser][IProblem] assert() breaks the parser

This patch fixes the content assist problem for this bug.  I can't reproduce the incomplete Outline view described in the bug report.

Devin Steffler
IBM's Eclipse CDT
Ottawa (Palladium), Ontario, Canada


Index: ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java,v
retrieving revision 1.4
diff -u -r1.4 ContentAssistTests.java
--- ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java	18 Nov 2004 21:09:43 -0000	1.4
+++ ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java	3 Dec 2004 16:40:51 -0000
@@ -234,4 +234,25 @@
         assertEquals( results[2].getDisplayString(), "void" ); //$NON-NLS-1$
         assertEquals( results[3].getDisplayString(), "volatile" ); //$NON-NLS-1$
     }
+    
+    public void testBug78574() throws Exception {
+    	StringWriter writer = new StringWriter();
+		writer.write("#define x int y;\n"); //$NON-NLS-1$
+		writer.write("struct uio {\n"); //$NON-NLS-1$
+		writer.write("int a;\n"); //$NON-NLS-1$
+		writer.write("int b;\n};\n"); //$NON-NLS-1$
+		writer.write("static void foo(struct uio *u)\n"); //$NON-NLS-1$
+		writer.write("{\n"); //$NON-NLS-1$
+		writer.write("x\n"); //$NON-NLS-1$
+		writer.write("u->b = 2;\n"); //$NON-NLS-1$
+		writer.write("}\n"); //$NON-NLS-1$
+
+        String code = writer.toString();
+        IFile cu = importFile( "t.cpp", code ); //$NON-NLS-1$
+        ICompletionProposal [] results = getResults( cu, code.indexOf( "u->b" ) + 3 ); //$NON-NLS-1$
+        
+        assertEquals( results.length, 2 );
+        assertEquals( results[0].getDisplayString(), "a : int" ); //$NON-NLS-1$
+        assertEquals( results[1].getDisplayString(), "b : int" ); //$NON-NLS-1$
+    }
 }
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java,v
retrieving revision 1.268
diff -u -r1.268 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java	29 Nov 2004 21:00:31 -0000	1.268
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java	3 Dec 2004 16:40:28 -0000
@@ -4175,7 +4175,8 @@
 			skipOverCompoundStatement();
 		else if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE )
 		{
-			if( scanner.isOnTopContext() )
+			if( scanner.isOnTopContext() || 
+					(scope instanceof IASTOffsetableElement &&  CharArrayUtils.equals(((IASTOffsetableElement)scope).getFilename(), parserStartFilename))	)
 				functionBody(scope);
 			else
 				skipOverCompoundStatement();

Back to the top