From 5beb4be54cf296e3895a8849072f1892841aec75 Mon Sep 17 00:00:00 2001 From: Gergo Mocsi Date: Sun, 7 Jul 2013 19:43:05 +0200 Subject: GSOC work week 5, some recent fixes This week I've managed to fix the ListBox appearance. Also, I've modified the code: it gets the data on insert/remove/change, and gets updated only when the dot is pressed. This makes the data to be up-to-date. Next, I wrote a Split(OUString , char) function to do the nested reflection (It works, but it will need some tweaks later). Also, code generation is disabled for code completition (just a boolean value, maybe it could be done in a more "elegant" way, like the error supression). Change-Id: I43d250c0a065351950ac6424dcd88266d70bcef3 --- basic/source/classes/sbxmod.cxx | 9 ++++++--- basic/source/comp/codegen.cxx | 18 ++++++++++++++++++ basic/source/comp/parser.cxx | 9 +++++++++ basic/source/inc/codegen.hxx | 2 ++ basic/source/inc/parser.hxx | 5 ++++- 5 files changed, 39 insertions(+), 4 deletions(-) (limited to 'basic/source') diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index c5608a877fc7..7f85be207f14 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1781,12 +1781,10 @@ IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/) 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 ); + pParser->SetCodeCompleting(true); while( pParser->Parse() ) {} SbiSymPool* pPool = pParser->pPool; @@ -1823,6 +1821,11 @@ std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse() return aRet; } +SbxArrayRef SbModule::GetMethods() +{ + return pMethods; +} + bool SbModule::HasExeCode() { // And empty Image always has the Global Chain set up diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index 32b1d84a9e79..abbbce94b8f2 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -46,6 +46,9 @@ sal_uInt32 SbiCodeGen::GetPC() void SbiCodeGen::Statement() { + if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + return; + bStmnt = true; nLine = pParser->GetLine(); @@ -60,6 +63,9 @@ void SbiCodeGen::Statement() void SbiCodeGen::GenStmnt() { + if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + return; + if( bStmnt ) { bStmnt = false; @@ -72,6 +78,9 @@ void SbiCodeGen::GenStmnt() sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode ) { + if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + return 0; + #ifdef DBG_UTIL if( eOpcode < SbOP0_START || eOpcode > SbOP0_END ) pParser->Error( SbERR_INTERNAL_ERROR, "OPCODE1" ); @@ -83,6 +92,9 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode ) sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd ) { + if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + return 0; + #ifdef DBG_UTIL if( eOpcode < SbOP1_START || eOpcode > SbOP1_END ) pParser->Error( SbERR_INTERNAL_ERROR, "OPCODE2" ); @@ -96,6 +108,9 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd ) sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd1, sal_uInt32 nOpnd2 ) { + if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + return 0; + #ifdef DBG_UTIL if( eOpcode < SbOP2_START || eOpcode > SbOP2_END ) pParser->Error( SbERR_INTERNAL_ERROR, "OPCODE3" ); @@ -112,6 +127,9 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd1, sal_uInt32 nOp void SbiCodeGen::Save() { + if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + return; + SbiImage* p = new SbiImage; rMod.StartDefinitions(); // OPTION BASE-Value: diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx index 018b2938ee84..e24f89b020a8 100644 --- a/basic/source/comp/parser.cxx +++ b/basic/source/comp/parser.cxx @@ -133,6 +133,7 @@ SbiParser::SbiParser( StarBASIC* pb, SbModule* pm ) bGblDefs = bNewGblDefs = bSingleLineIf = + bCodeCompleting = bExplicit = false; bClassModule = ( pm->GetModuleType() == com::sun::star::script::ModuleType::CLASS ); OSL_TRACE("Parser - %s, bClassModule %d", OUStringToOString( pm->GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), bClassModule ); @@ -314,7 +315,15 @@ void SbiParser::StmntBlock( SbiToken eEnd ) } } +void SbiParser::SetCodeCompleting( const bool& b ) +{ + bCodeCompleting = b; +} +bool SbiParser::IsCodeCompleting() const +{ + return bCodeCompleting; +} bool SbiParser::Parse() { diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx index 246ff167ce79..3cdd27c21710 100644 --- a/basic/source/inc/codegen.hxx +++ b/basic/source/inc/codegen.hxx @@ -24,6 +24,7 @@ class SbiParser; class SbModule; #include "opcodes.hxx" #include "buffer.hxx" +#include class SbiCodeGen { SbiParser* pParser; // for error messages, line, column etc. @@ -32,6 +33,7 @@ class SbiCodeGen { short nLine, nCol; // for stmnt command short nForLevel; // #29955 bool bStmnt; // true: statement-opcode is pending + SvtMiscOptions aMiscOptions; public: SbiCodeGen( SbModule&, SbiParser*, short ); SbiParser* GetParser() { return pParser; } diff --git a/basic/source/inc/parser.hxx b/basic/source/inc/parser.hxx index 0ab6bcbb533b..a6f3751d8c57 100644 --- a/basic/source/inc/parser.hxx +++ b/basic/source/inc/parser.hxx @@ -42,6 +42,7 @@ class SbiParser : public SbiTokenizer bool bGblDefs; // true: global definitions general bool bNewGblDefs; // true: globale definitions before sub bool bSingleLineIf; + bool bCodeCompleting; SbiSymDef* VarDecl( SbiDimList**, bool, bool ); SbiProcDef* ProcDecl(bool bDecl); @@ -57,7 +58,7 @@ class SbiParser : public SbiTokenizer void DefEnum( bool bPrivate ); // Parse enum declaration void DefDeclare( bool bPrivate ); void EnableCompatibility(); - bool IsUnoInterface(const OUString& sTypeName); + bool IsUnoInterface( const OUString& sTypeName ); public: SbxArrayRef rTypeArray; SbxArrayRef rEnumArray; @@ -80,6 +81,8 @@ public: SbiParser( StarBASIC*, SbModule* ); bool Parse(); + void SetCodeCompleting( const bool& b ); + bool IsCodeCompleting() const; SbiExprNode* GetWithVar(); // from 31.3.1996, search symbol in the runtime-library -- cgit