summaryrefslogtreecommitdiff
path: root/basic/source/classes/sbxmod.cxx
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-06-21 14:10:31 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-06-21 14:10:31 +0200
commit035be6eb0de0b02796ee73940817278f5007e112 (patch)
tree1de5a9cb21e183bc6efc3f3dae39afcfcf9bcd52 /basic/source/classes/sbxmod.cxx
parent809edacfabfbb5b6cc0bac335aa8f62367948b4b (diff)
GSOC work week 2, getting infromation from variables and print on terminal
This is an early version. I use the BASIC parser to parse the source, then the infromation is extracted from the symbol table built by parser. Error reporting is suppressed, beacuse it is not needed fro code completition. I placed my function inside SbModule, and created a struct called CodeCompletitionData, which holds the object's name, it's parent, and it's type name. This function, SbMethod::GetCodeCompleteDataFromParse() is called from Basic IDE's Notify function, which updates a cache(actually, reassigns a viariable :) ). Later, in the EditorWindow::KeyInput function there is a check wheteher dot key is pressed. After that, the actual variable (or word) is being looked up in the vector that holds code completition data. And finally, if it is found, it's methods are printed on the terminal. Change-Id: Idaf19baa8f720b8b117a76dc3cc2f90dd04fd155
Diffstat (limited to 'basic/source/classes/sbxmod.cxx')
-rw-r--r--basic/source/classes/sbxmod.cxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 28d10e290b01..c5608a877fc7 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -83,6 +83,7 @@ using namespace com::sun::star::uno;
#include <com/sun/star/awt/XControl.hpp>
#include <comphelper/anytostring.hxx>
#include <ooo/vba/VbQueryClose.hpp>
+#include "sbcomp.hxx"
typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE;
typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap;
@@ -1776,6 +1777,52 @@ IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/)
return 0;
}
+
+std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse()
+{
+ ErrorHdlResetter aErrHdl;
+ StarBASIC* pBasic = PTR_CAST(StarBASIC,GetParent());
+ SbxBase::ResetError();
+ SbModule* pOld = GetSbData()->pCompMod;
+ GetSbData()->pCompMod = this;
+
+ SbiParser* pParser = new SbiParser( (StarBASIC*) GetParent(), this );
+
+ while( pParser->Parse() ) {}
+ SbiSymPool* pPool = pParser->pPool;
+ std::vector< CodeCompleteData > aRet;
+ for( sal_uInt16 i = 0; i < pPool->GetSize(); ++i )
+ {
+ SbiSymDef* pSymDef = pPool->Get(i);
+ if( pSymDef->GetType() == SbxOBJECT )
+ {
+ CodeCompleteData aCodeCompleteData;
+ aCodeCompleteData.sVarName = pSymDef->GetName();
+ aCodeCompleteData.sVarParent = OUString("");
+ aCodeCompleteData.sVarType = pParser->aGblStrings.Find( pSymDef->GetTypeId() );
+ if(!aCodeCompleteData.sVarType.isEmpty())
+ aRet.push_back(aCodeCompleteData);
+ }
+
+ SbiSymPool& pChildPool = pSymDef->GetPool();
+ for(sal_uInt16 j = 0; j < pChildPool.GetSize(); ++j )
+ {
+ CodeCompleteData aCodeCompleteData;
+ 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())
+ aRet.push_back(aCodeCompleteData);
+ }
+ }
+ }
+ delete pParser;
+ return aRet;
+}
+
bool SbModule::HasExeCode()
{
// And empty Image always has the Global Chain set up