1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

Got more of the PDOM working. Able to do stdio.h and iostream.

This commit is contained in:
Doug Schaefer 2005-10-13 19:43:40 +00:00
parent 083a674975
commit 8c41743dc7
4 changed files with 31 additions and 7 deletions

View file

@ -124,7 +124,7 @@ public class CASTTranslationUnit extends CASTNode implements
try { try {
names = pdom.getDeclarations(binding); names = pdom.getDeclarations(binding);
} catch (CoreException e) { } catch (CoreException e) {
names = null; names = new IASTName[0];
} }
} }
return names; return names;

View file

@ -916,7 +916,8 @@ public class CVisitor {
binding = scope.getBinding( name, false ); binding = scope.getBinding( name, false );
if( binding != null ){ if( binding != null ){
((CStructure)binding).addDefinition( compositeTypeSpec ); if (binding instanceof CStructure)
((CStructure)binding).addDefinition( compositeTypeSpec );
return binding; return binding;
} }
} catch (DOMException e2) { } catch (DOMException e2) {

View file

@ -61,6 +61,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider.CPPBuiltinParameter; import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider.CPPBuiltinParameter;
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver; import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException; import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException;
import org.eclipse.core.runtime.CoreException;
/** /**
* @author jcamelon * @author jcamelon
@ -177,7 +178,15 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
return EMPTY_NAME_ARRAY; return EMPTY_NAME_ARRAY;
return resolver.getDeclarations( (IMacroBinding)b ); return resolver.getDeclarations( (IMacroBinding)b );
} }
return CPPVisitor.getDeclarations( this, b ); IASTName[] names = CPPVisitor.getDeclarations( this, b );
if (names.length == 0 && pdom != null) {
try {
names = pdom.getDeclarations(b);
} catch (CoreException e) {
names = new IASTName[0];
}
}
return names;
} }
/* /*

View file

@ -13,6 +13,7 @@
*/ */
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
@ -124,6 +125,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil.ArrayWrapper;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.CoreException;
/** /**
* @author aniefer * @author aniefer
@ -744,10 +746,22 @@ public class CPPSemantics {
} }
} }
if( binding == null ){ if( binding == null ){
if( name instanceof ICPPASTQualifiedName && data.forDefinition() ) // Let's try the pdom
binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND, data.name() ); IPDOM pdom = name.getTranslationUnit().getPDOM();
else if (pdom != null) {
binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, data.name() ); try {
binding = pdom.resolveBinding(name);
} catch (CoreException e) {
binding = null;
}
}
// If we're still null...
if (binding == null) {
if( name instanceof ICPPASTQualifiedName && data.forDefinition() )
binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND, data.name() );
else
binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, data.name() );
}
} }
return binding; return binding;
} }