#ifndef TEST_PARSER_CLIENT_H #define TEST_PARSER_CLIENT_H #include "data/parser/ParseLocation.h" #include "data/parser/ParserClient.h" class TestParserClient: public ParserClient { public: virtual Id recordSymbol( const NameHierarchy& symbolName, SymbolKind symbolKind, AccessKind access, DefinitionKind definitionKind) override { std::vector* bin = getBinForSymbolKind(symbolKind); if (bin != nullptr) { bin->push_back(addAccessPrefix(symbolName.getQualifiedNameWithSignature(), access)); } return 0; } virtual Id recordSymbol( const NameHierarchy& symbolName, SymbolKind symbolKind, const ParseLocation& location, AccessKind access, DefinitionKind definitionKind) override { std::vector* bin = getBinForSymbolKind(symbolKind); if (bin != nullptr) { bin->push_back(addLocationSuffix(addAccessPrefix(symbolName.getQualifiedNameWithSignature(), access), location)); } return 0; } virtual Id recordSymbol( const NameHierarchy& symbolName, SymbolKind symbolKind, const ParseLocation& location, const ParseLocation& scopeLocation, AccessKind access, DefinitionKind definitionKind) override { std::vector* bin = getBinForSymbolKind(symbolKind); if (bin != nullptr) { bin->push_back(addLocationSuffix(addAccessPrefix(symbolName.getQualifiedNameWithSignature(), access), location, scopeLocation)); } return 0; } void recordReference( ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName, const ParseLocation& location) override { std::vector* referenceContainer = nullptr; switch (referenceKind) { case REFERENCE_TYPE_USAGE: referenceContainer = &typeUses; break; case REFERENCE_USAGE: referenceContainer = &usages; break; case REFERENCE_CALL: referenceContainer = &calls; break; case REFERENCE_INHERITANCE: referenceContainer = &inheritances; break; case REFERENCE_OVERRIDE: referenceContainer = &overrides; break; case REFERENCE_TEMPLATE_ARGUMENT: referenceContainer = &templateArgumentTypes; break; case REFERENCE_TYPE_ARGUMENT: referenceContainer = &typeArguments; break; case REFERENCE_TEMPLATE_DEFAULT_ARGUMENT: referenceContainer = &templateDefaultArgumentTypes; break; case REFERENCE_TEMPLATE_SPECIALIZATION: referenceContainer = &templateSpecializations; break; case REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION: referenceContainer = &templateMemberSpecializations; break; case REFERENCE_INCLUDE: referenceContainer = &includes; break; case REFERENCE_IMPORT: referenceContainer = &imports; break; case REFERENCE_MACRO_USAGE: referenceContainer = ¯oUses; break; default: break; } if (referenceContainer != nullptr) { referenceContainer->push_back(addLocationSuffix( contextName.getQualifiedNameWithSignature() + L" -> " + referencedName.getQualifiedNameWithSignature(), location) ); } } virtual void recordQualifierLocation( const NameHierarchy& qualifierName, const ParseLocation& location) override { qualifiers.push_back(addLocationSuffix(qualifierName.getQualifiedNameWithSignature(), location)); } virtual void recordLocalSymbol(const std::wstring& name, const ParseLocation& location) override { localSymbols.push_back(addLocationSuffix(name, location)); } virtual void recordFile(const FileInfo& fileInfo, bool indexed) override { files.insert(fileInfo.path.wstr()); } virtual void recordComment(const ParseLocation& location) override { comments.push_back(addLocationSuffix(L"comment", location)); } std::vector errors; std::vector qualifiers; std::vector packages; std::vector typedefs; std::vector builtinTypes; std::vector classes; std::vector unions; std::vector interfaces; std::vector enums; std::vector enumConstants; std::vector functions; std::vector fields; std::vector globalVariables; std::vector methods; std::vector namespaces; std::vector structs; std::vector macros; std::vector templateParameterTypes; std::vector typeParameters; std::vector localSymbols; std::set files; std::vector comments; std::vector inheritances; std::vector overrides; std::vector calls; std::vector usages; // for variables std::vector typeUses; // for types std::vector macroUses; std::vector templateArgumentTypes; std::vector typeArguments; std::vector templateDefaultArgumentTypes; std::vector templateSpecializations; std::vector templateMemberSpecializations; std::vector includes; std::vector imports; private: virtual void doRecordError( const ParseLocation& location, const std::wstring& message, bool fatal, bool indexed, const FilePath& translationUnit) override { if (location.isValid()) { errors.push_back(addLocationSuffix(message, location)); } } std::vector* getBinForSymbolKind(SymbolKind symbolType) { switch (symbolType) { case SYMBOL_PACKAGE: return &packages; case SYMBOL_TYPEDEF: return &typedefs; case SYMBOL_BUILTIN_TYPE: return &builtinTypes; case SYMBOL_CLASS: return &classes; case SYMBOL_UNION: return &unions; case SYMBOL_INTERFACE: return &interfaces; case SYMBOL_ENUM: return &enums; case SYMBOL_ENUM_CONSTANT: return &enumConstants; case SYMBOL_FUNCTION: return &functions; case SYMBOL_FIELD: return &fields; case SYMBOL_GLOBAL_VARIABLE: return &globalVariables; case SYMBOL_METHOD: return &methods; case SYMBOL_NAMESPACE: return &namespaces; case SYMBOL_STRUCT: return &structs; case SYMBOL_MACRO: return ¯os; case SYMBOL_TEMPLATE_PARAMETER: return &templateParameterTypes; case SYMBOL_TYPE_PARAMETER: return &typeParameters; default: break; } return nullptr; } }; #endif // TEST_PARSER_CLIENT_H