summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-20 13:03:42 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-02 18:16:46 +0200
commit6165d0b4846590d1d85d559636dd6587ea0dadd8 (patch)
treededff6fd0d6387b4edd9a17653580a72a549e85c /basic
parent6c1854f9f3f7308dce0e326aa063d929f8da5881 (diff)
GSOC work, some code fixes
Fixed the link error: declared CodeCompleteDataCache as BASIC_DLLPUBLIC and it worked fine. Fixed sergmentation fault error in CodeCompleteWindow. The new cache implementation is fully functional. CodeCompleteWindow is now being used as boost::scoped_ptr. Change-Id: I76a0fc7407d589e7f94280fc4d50cea51b9639db
Diffstat (limited to 'basic')
-rw-r--r--basic/source/classes/codecompletecache.cxx22
-rw-r--r--basic/source/classes/sbxmod.cxx40
2 files changed, 32 insertions, 30 deletions
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index f4831039ed6d..e45e20a512b6 100644
--- a/basic/source/classes/codecompletecache.cxx
+++ b/basic/source/classes/codecompletecache.cxx
@@ -19,6 +19,21 @@
#include <basic/codecompletecache.hxx>
+std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache)
+{
+ for( CodeCompleteVarScopes::const_iterator aIt = aCache.aVarScopes.begin(); aIt != aCache.aVarScopes.end(); ++aIt )
+ {
+ aStream << aIt->first << std::endl;
+ CodeCompleteVarTypes aVarTypes = aIt->second;
+ for( CodeCompleteVarTypes::const_iterator aOtherIt = aVarTypes.begin(); aOtherIt != aVarTypes.end(); ++aOtherIt )
+ {
+ aStream << "\t" << aOtherIt->first << "," << aOtherIt->second << std::endl;
+ }
+ }
+ aStream << "-----------------" << std::endl;
+ return aStream;
+}
+
const CodeCompleteVarScopes& CodeCompleteDataCache::GetVars() const
{
return aVarScopes;
@@ -33,7 +48,7 @@ void CodeCompleteDataCache::SetVars( const CodeCompleteVarScopes& aScopes )
aVarScopes = aScopes;
}
-const OUString& CodeCompleteDataCache::GetVariableType( const OUString& sVarName, const OUString& sProcName ) const
+OUString CodeCompleteDataCache::GetVariableType( const OUString& sVarName, const OUString& sProcName ) const
{
CodeCompleteVarScopes::const_iterator aIt = aVarScopes.find( sProcName );
if( aIt == aVarScopes.end() )//procedure does not exist
@@ -47,4 +62,9 @@ const OUString& CodeCompleteDataCache::GetVariableType( const OUString& sVarName
return aOtherIt->second;
}
+void CodeCompleteDataCache::print() const
+{
+ std::cerr << *this << std::endl;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 15774d811bde..8b679c3600fc 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1780,7 +1780,6 @@ IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/)
return 0;
}
-//std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse()
CodeCompleteDataCache SbModule::GetCodeCompleteDataFromParse()
{
CodeCompleteDataCache aCache;
@@ -1793,55 +1792,38 @@ CodeCompleteDataCache SbModule::GetCodeCompleteDataFromParse()
while( pParser->Parse() ) {}
SbiSymPool* pPool = pParser->pPool;
- //std::vector< CodeCompleteData > aRet;
+ CodeCompleteVarTypes aGlobVarTypes;
for( sal_uInt16 i = 0; i < pPool->GetSize(); ++i )
{
SbiSymDef* pSymDef = pPool->Get(i);
if( pSymDef->GetType() == SbxOBJECT )
{
- //CodeCompleteData aCodeCompleteData;
- CodeCompleteVarTypes aVarTypes;
- /*aCodeCompleteData.sVarName = pSymDef->GetName();
- aCodeCompleteData.sVarParent = OUString("");
- aCodeCompleteData.sVarType = pParser->aGblStrings.Find( pSymDef->GetTypeId() );
- if(!aCodeCompleteData.sVarType.isEmpty())
+ if( !pParser->aGblStrings.Find( pSymDef->GetTypeId() ).isEmpty() )
{
- aRet.push_back(aCodeCompleteData);
- aVarTypes.insert(CodeCompleteVarTypes::value_type( pSymDef->GetName(), pParser->aGblStrings.Find( pSymDef->GetTypeId() ) ) );
- aCache.InsertProcedure( aCache.GLOB_KEY, aVarTypes );
- }*/
- if(pParser->aGblStrings.Find( pSymDef->GetTypeId() ).isEmpty() )
- {
- aVarTypes.insert(CodeCompleteVarTypes::value_type( pSymDef->GetName(), pParser->aGblStrings.Find( pSymDef->GetTypeId() ) ) );
- aCache.InsertProcedure( aCache.GLOB_KEY, aVarTypes );
+ //std::cerr << "global " << pSymDef->GetName() << std::endl;
+ aGlobVarTypes.insert( CodeCompleteVarTypes::value_type( pSymDef->GetName(), pParser->aGblStrings.Find( pSymDef->GetTypeId() ) ) );
}
}
SbiSymPool& pChildPool = pSymDef->GetPool();
+ CodeCompleteVarTypes aLocVarTypes;
for(sal_uInt16 j = 0; j < pChildPool.GetSize(); ++j )
{
- //CodeCompleteData aCodeCompleteData;
- CodeCompleteVarTypes aVarTypes;
-
SbiSymDef* pChildSymDef = pChildPool.Get(j);
if( pChildSymDef->GetType() == SbxOBJECT )
{
- /*aCodeCompleteData.sVarName = pChildSymDef->GetName();
- aCodeCompleteData.sVarParent = pSymDef->GetName();
- aCodeCompleteData.sVarType = pParser->aGblStrings.Find( pChildSymDef->GetTypeId() );
- if(!aCodeCompleteData.sVarType.isEmpty())*/
- if( pParser->aGblStrings.Find( pChildSymDef->GetTypeId() ).isEmpty() )
+ if( !pParser->aGblStrings.Find( pChildSymDef->GetTypeId() ).isEmpty() )
{
- //aRet.push_back(aCodeCompleteData);
- aVarTypes.insert(CodeCompleteVarTypes::value_type( pChildSymDef->GetName(), pParser->aGblStrings.Find( pChildSymDef->GetTypeId() ) ) );
- aCache.InsertProcedure( pSymDef->GetName(), aVarTypes );
+ //std::cerr << "local " << pChildSymDef->GetName() << std::endl;
+ aLocVarTypes.insert( CodeCompleteVarTypes::value_type( pChildSymDef->GetName(), pParser->aGblStrings.Find( pChildSymDef->GetTypeId() ) ) );
}
}
}
+ aCache.InsertProcedure( pSymDef->GetName(), aLocVarTypes );
}
- //std::cerr << aCache << std::endl;
+ aCache.InsertProcedure( aCache.GLOB_KEY, aGlobVarTypes );
+
delete pParser;
- //return aRet;
return aCache;
}