Commit c9d6bae4 authored by Naba Kumar's avatar Naba Kumar

language-support-cpp-java: Port to new symbol query API

parent 06a59b6b
......@@ -45,9 +45,6 @@ public:
/* setter for the IAnjutaSymbolManager. */
void setSymbolManager (IAnjutaSymbolManager *manager);
/* getter for the IAnjutaSymbolManager. */
IAnjutaSymbolManager * getSymbolManager ();
IAnjutaIterable * getCurrentScopeChainByFileLine (const char* full_file_path,
unsigned long linenum);
......@@ -64,7 +61,7 @@ public:
IAnjutaIterable * switchTypedefToStruct (IAnjutaIterable * test,
IAnjutaSymbolField sym_info =
(IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_SIMPLE | IANJUTA_SYMBOL_FIELD_KIND));
(IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_NAME | IANJUTA_SYMBOL_FIELD_KIND));
IAnjutaIterable * switchMemberToContainer (IAnjutaIterable * test);
......@@ -123,7 +120,12 @@ private:
CppTokenizer *_main_tokenizer;
CppTokenizer *_extra_tokenizer;
IAnjutaSymbolManager *_sym_man;
IAnjutaSymbolQuery *query_scope;
IAnjutaSymbolQuery *query_search;
IAnjutaSymbolQuery *query_search_in_scope;
IAnjutaSymbolQuery *query_parent_scope;
IAnjutaSymbolQuery *query_scope_chain;
};
......
......@@ -21,6 +21,7 @@
#include <libanjuta/anjuta-debug.h>
#include <string>
#include <vector>
#include <libanjuta/interfaces/ianjuta-symbol-query.h>
#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
#include "engine-parser-priv.h"
......@@ -51,7 +52,6 @@ EngineParser::EngineParser ()
{
_main_tokenizer = new CppTokenizer ();
_extra_tokenizer = new CppTokenizer ();
_sym_man = NULL;
}
EngineParser::~EngineParser ()
......@@ -119,13 +119,40 @@ EngineParser::parseExpression(const string &in)
void
EngineParser::setSymbolManager (IAnjutaSymbolManager *manager)
{
_sym_man = manager;
}
IAnjutaSymbolManager *
EngineParser::getSymbolManager ()
{
return _sym_man;
static IAnjutaSymbolField query_scope_chain_fields[] =
{
IANJUTA_SYMBOL_FIELD_ID, IANJUTA_SYMBOL_FIELD_NAME,
IANJUTA_SYMBOL_FIELD_KIND, IANJUTA_SYMBOL_FIELD_TYPE
};
static IAnjutaSymbolField query_search_fields[] =
{
IANJUTA_SYMBOL_FIELD_ID, IANJUTA_SYMBOL_FIELD_NAME,
IANJUTA_SYMBOL_FIELD_KIND
};
query_search = ianjuta_symbol_manager_create_query (manager,
IANJUTA_SYMBOL_QUERY_SEARCH,
IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
ianjuta_symbol_query_set_filters (query_search,
(IAnjutaSymbolType) (IANJUTA_SYMBOL_TYPE_SCOPE_CONTAINER |
IANJUTA_SYMBOL_TYPE_TYPEDEF), TRUE, NULL);
ianjuta_symbol_query_set_fields (query_search,
G_N_ELEMENTS (query_search_fields),
query_search_fields, NULL);
query_scope = ianjuta_symbol_manager_create_query (manager,
IANJUTA_SYMBOL_QUERY_SEARCH_SCOPE,
IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
query_search_in_scope = ianjuta_symbol_manager_create_query (manager,
IANJUTA_SYMBOL_QUERY_SEARCH_IN_SCOPE,
IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
query_parent_scope = ianjuta_symbol_manager_create_query (manager,
IANJUTA_SYMBOL_QUERY_SEARCH_PARENT_SCOPE,
IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
query_scope_chain = ianjuta_symbol_manager_create_query (manager,
IANJUTA_SYMBOL_QUERY_SEARCH_SCOPE_CHAIN,
IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
ianjuta_symbol_query_set_fields (query_scope_chain,
G_N_ELEMENTS (query_scope_chain_fields),
query_scope_chain_fields, NULL);
}
void
......@@ -156,8 +183,7 @@ EngineParser::getCurrentScopeChainByFileLine (const char* full_file_path,
unsigned long linenum)
{
IAnjutaIterable *iter =
ianjuta_symbol_manager_get_scope_chain (_sym_man, full_file_path, linenum,
IANJUTA_SYMBOL_FIELD_SIMPLE, NULL);
ianjuta_symbol_query_search_scope_chain (query_scope_chain, full_file_path, linenum, NULL);
DEBUG_PRINT ("Checking for completion scope..");
/* it's a global one if it's NULL or if it has just only one element */
......@@ -177,7 +203,7 @@ EngineParser::getCurrentScopeChainByFileLine (const char* full_file_path,
{
IAnjutaSymbol *node = IANJUTA_SYMBOL (iter);
DEBUG_PRINT ("Got completion scope name: %s",
ianjuta_symbol_get_name (node, NULL));
ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL));
} while (ianjuta_iterable_next (iter, NULL) == TRUE);
}
......@@ -245,10 +271,7 @@ EngineParser::getTypeNameAndScopeByToken (ExpressionResult &result,
*/
IAnjutaIterable* scope_chain_iter =
ianjuta_symbol_manager_get_scope_chain (_sym_man, full_file_path.c_str (), linenum,
IAnjutaSymbolField(IANJUTA_SYMBOL_FIELD_SIMPLE |
IANJUTA_SYMBOL_FIELD_KIND |
IANJUTA_SYMBOL_FIELD_TYPE), NULL);
ianjuta_symbol_query_search_scope_chain (query_scope_chain, full_file_path.c_str (), linenum, NULL);
/* will we find a good class scope? */
out_type_scope = result.m_scope.empty() ? "" : result.m_scope.c_str();
......@@ -262,10 +285,10 @@ EngineParser::getTypeNameAndScopeByToken (ExpressionResult &result,
do
{
IAnjutaSymbol *node = IANJUTA_SYMBOL (scope_chain_iter);
DEBUG_PRINT ("sym_name = %s", ianjuta_symbol_get_name (node, NULL));
DEBUG_PRINT ("sym_name = %s", ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL));
if (ianjuta_symbol_get_sym_type (node, NULL) == IANJUTA_SYMBOL_TYPE_CLASS)
{
out_type_name = ianjuta_symbol_get_name (node, NULL);
out_type_name = ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL);
break;
}
} while (ianjuta_iterable_next (scope_chain_iter, NULL) == TRUE);
......@@ -321,8 +344,7 @@ EngineParser::getTypeNameAndScopeByToken (ExpressionResult &result,
}
IAnjutaIterable* curr_scope_iter =
ianjuta_symbol_manager_get_scope (_sym_man, full_file_path.c_str (), linenum,
IANJUTA_SYMBOL_FIELD_SIMPLE, NULL);
ianjuta_symbol_query_search_scope (query_scope, full_file_path.c_str (), linenum, NULL);
if (curr_scope_iter != NULL)
{
......@@ -331,7 +353,7 @@ EngineParser::getTypeNameAndScopeByToken (ExpressionResult &result,
/* try to get the signature from the symbol and test if the
* variable searched is found there.
*/
const gchar * signature = ianjuta_symbol_get_args (node, NULL);
const gchar * signature = ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_SIGNATURE, NULL);
if (signature == NULL)
{
g_object_unref (curr_scope_iter);
......@@ -376,16 +398,7 @@ EngineParser::getCurrentSearchableScope (string &type_name, string &type_scope)
{
// FIXME: case of more results now it's hardcoded to 1
IAnjutaIterable *curr_searchable_scope =
ianjuta_symbol_manager_search_project (_sym_man,
(IAnjutaSymbolType) (IANJUTA_SYMBOL_TYPE_SCOPE_CONTAINER |
IANJUTA_SYMBOL_TYPE_TYPEDEF),
TRUE,
(IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_SIMPLE | IANJUTA_SYMBOL_FIELD_KIND),
type_name.c_str(),
IANJUTA_SYMBOL_MANAGER_SEARCH_FS_IGNORE,
-1,
-1,
NULL);
ianjuta_symbol_query_search (query_search, type_name.c_str(), NULL);
if (curr_searchable_scope != NULL)
{
......@@ -393,15 +406,15 @@ EngineParser::getCurrentSearchableScope (string &type_name, string &type_scope)
node = IANJUTA_SYMBOL (curr_searchable_scope);
const gchar *skind = ianjuta_symbol_get_extra_info_string (node,
const gchar *skind = ianjuta_symbol_get_string (node,
IANJUTA_SYMBOL_FIELD_KIND, NULL);
DEBUG_PRINT ("Current Searchable Scope name \"%s\" kind \"%s\" and id %d",
ianjuta_symbol_get_name (node, NULL), skind,
ianjuta_symbol_get_id (node, NULL));
ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL), skind,
ianjuta_symbol_get_int (node, IANJUTA_SYMBOL_FIELD_ID, NULL));
/* is it a typedef? In that case find the parent struct */
if (g_strcmp0 (ianjuta_symbol_get_extra_info_string (node,
if (g_strcmp0 (ianjuta_symbol_get_string (node,
IANJUTA_SYMBOL_FIELD_KIND, NULL), "typedef") == 0)
{
DEBUG_PRINT ("It's a TYPEDEF... trying to find the associated struct...!");
......@@ -410,8 +423,8 @@ EngineParser::getCurrentSearchableScope (string &type_name, string &type_scope)
node = IANJUTA_SYMBOL (curr_searchable_scope);
DEBUG_PRINT ("(NEW) Current Searchable Scope %s and id %d",
ianjuta_symbol_get_name (node, NULL),
ianjuta_symbol_get_id (node, NULL));
ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL),
ianjuta_symbol_get_int (node, IANJUTA_SYMBOL_FIELD_ID, NULL));
}
}
else
......@@ -436,8 +449,8 @@ EngineParser::switchTypedefToStruct (IAnjutaIterable * test,
IAnjutaSymbol *node = IANJUTA_SYMBOL (test);
IAnjutaIterable *new_struct;
DEBUG_PRINT ("Switching TYPEDEF (%d) ==> to STRUCT", ianjuta_symbol_get_id (node, NULL));
new_struct = ianjuta_symbol_manager_get_parent_scope (_sym_man, node, NULL, sym_info, NULL);
DEBUG_PRINT ("Switching TYPEDEF (%d) ==> to STRUCT", ianjuta_symbol_get_int (node, IANJUTA_SYMBOL_FIELD_ID, NULL));
new_struct = ianjuta_symbol_query_search_parent_scope (query_parent_scope, node, NULL);
if (new_struct != NULL)
{
......@@ -459,23 +472,14 @@ EngineParser::switchMemberToContainer (IAnjutaIterable * test)
{
IAnjutaSymbol *node = IANJUTA_SYMBOL (test);
IAnjutaIterable *new_container;
const gchar* sym_type_name = ianjuta_symbol_get_extra_info_string (node,
const gchar* sym_type_name = ianjuta_symbol_get_string (node,
IANJUTA_SYMBOL_FIELD_TYPE_NAME, NULL);
DEBUG_PRINT ("Switching container with type_name %s", sym_type_name);
/* hopefully we'll find a new container for the type_name of test param */
new_container = ianjuta_symbol_manager_search_project (_sym_man,
IANJUTA_SYMBOL_TYPE_SCOPE_CONTAINER,
TRUE,
(IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_SIMPLE | IANJUTA_SYMBOL_FIELD_KIND |
IANJUTA_SYMBOL_FIELD_TYPE_NAME),
sym_type_name,
IANJUTA_SYMBOL_MANAGER_SEARCH_FS_IGNORE,
-1,
-1,
NULL);
new_container = ianjuta_symbol_query_search (query_search,
sym_type_name, NULL);
if (new_container != NULL)
{
g_object_unref (test);
......@@ -584,24 +588,14 @@ EngineParser::processExpression(const string& stmt,
node = IANJUTA_SYMBOL (curr_searchable_scope);
iter = ianjuta_symbol_manager_search_symbol_in_scope (_sym_man,
result.m_name.c_str (),
node,
IANJUTA_SYMBOL_TYPE_UNDEF,
TRUE,
-1,
-1,
(IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_SIMPLE |
IANJUTA_SYMBOL_FIELD_KIND |
IANJUTA_SYMBOL_FIELD_TYPE |
IANJUTA_SYMBOL_FIELD_TYPE_NAME),
NULL);
iter = ianjuta_symbol_query_search_in_scope (query_search_in_scope,
result.m_name.c_str (), node, NULL);
if (iter == NULL)
{
DEBUG_PRINT ("Warning, the result.m_name %s "
"does not belong to scope (id %d)", result.m_name.c_str (),
ianjuta_symbol_get_id (node, NULL));
ianjuta_symbol_get_int (node, IANJUTA_SYMBOL_FIELD_ID, NULL));
if (curr_searchable_scope != NULL)
g_object_unref (curr_searchable_scope );
......@@ -614,7 +608,7 @@ EngineParser::processExpression(const string& stmt,
DEBUG_PRINT ("Good element %s", result.m_name.c_str ());
node = IANJUTA_SYMBOL (iter);
sym_kind = (gchar*)ianjuta_symbol_get_extra_info_string (node,
sym_kind = (gchar*)ianjuta_symbol_get_string (node,
IANJUTA_SYMBOL_FIELD_KIND, NULL);
DEBUG_PRINT (".. it has sym_kind \"%s\"", sym_kind);
......@@ -626,18 +620,18 @@ EngineParser::processExpression(const string& stmt,
{
iter = switchMemberToContainer (iter);
node = IANJUTA_SYMBOL (iter);
sym_kind = (gchar*)ianjuta_symbol_get_extra_info_string (node,
sym_kind = (gchar*)ianjuta_symbol_get_string (node,
IANJUTA_SYMBOL_FIELD_KIND, NULL);
}
/* check for any typedef */
if (g_strcmp0 (ianjuta_symbol_get_extra_info_string (node,
if (g_strcmp0 (ianjuta_symbol_get_string (node,
IANJUTA_SYMBOL_FIELD_KIND, NULL),
"typedef") == 0)
{
iter = switchTypedefToStruct (iter);
node = IANJUTA_SYMBOL (iter);
sym_kind = (gchar*)ianjuta_symbol_get_extra_info_string (node,
sym_kind = (gchar*)ianjuta_symbol_get_string (node,
IANJUTA_SYMBOL_FIELD_KIND, NULL);
}
......@@ -648,10 +642,10 @@ EngineParser::processExpression(const string& stmt,
{
string func_ret_type_name =
ianjuta_symbol_get_returntype (node, NULL);
ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_RETURNTYPE, NULL);
string func_signature =
ianjuta_symbol_get_args (node, NULL);
ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_SIGNATURE, NULL);
func_ret_type_name += " " + result.m_name + func_signature + "{}";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment