diff options
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 2 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 44 | ||||
-rw-r--r-- | basic/source/classes/sb.cxx | 1 | ||||
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 47 | ||||
-rw-r--r-- | basic/source/comp/dim.cxx | 2 | ||||
-rw-r--r-- | basic/source/comp/parser.cxx | 1 | ||||
-rw-r--r-- | basic/source/comp/sbcomp.cxx | 2 | ||||
-rw-r--r-- | include/basic/sbmod.hxx | 9 |
8 files changed, 106 insertions, 2 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index c02f502e7a58..fb48ae3202d4 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -67,7 +67,6 @@ DBG_NAMEEX( ModulWindow ) OUString getTextEngineText (ExtTextEngine&); void setTextEngineText (ExtTextEngine&, OUString const&); - class EditorWindow : public Window, public SfxListener { private: @@ -109,6 +108,7 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface(sal_Bool bCreate = true); + std::vector< CodeCompleteData > aCodeCompleteCache; protected: virtual void Paint( const Rectangle& ); diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 2347616bdb48..b6ddc4d6dd4d 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -48,6 +48,13 @@ #include <vcl/help.hxx> #include <vector> +#include <svtools/miscopt.hxx> +#include "com/sun/star/reflection/XIdlReflection.hpp" +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/configurationhelper.hxx> +#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp" +#include "com/sun/star/reflection/XIdlMethod.hpp" namespace basctl { @@ -479,6 +486,7 @@ bool EditorWindow::ImpCanModify() void EditorWindow::KeyInput( const KeyEvent& rKEvt ) { + SvtMiscOptions aMiscOptions; if ( !pEditView ) // Happens in Win95 return; @@ -492,7 +500,31 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) bool const bWasModified = pEditEngine->IsModified(); // see if there is an accelerator to be processed first bool bDone = SfxViewShell::Current()->KeyInput( rKEvt ); + if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && aMiscOptions.IsExperimentalMode()) + { + TextSelection aSel = GetEditView()->GetSelection(); + sal_uLong nLine = aSel.GetStart().GetPara(); + OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified + OUString aStr = (aLine.lastIndexOf(" ") == -1 ? aLine.replaceFirst(".","") : aLine.copy(aLine.lastIndexOf(" ")).replaceFirst(".","")); + for( unsigned int j = 0; j < aCodeCompleteCache.size(); ++j) + { + if( aCodeCompleteCache[j].sVarName == aStr ) + { + Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW ); + Reference< reflection::XIdlReflection > xRefl( xFactory->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY_THROW ); + Reference< reflection::XIdlClass > xClass = xRefl->forName(aCodeCompleteCache[j].sVarType); + if( !xRefl.is() ) + break; + Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods(); + for(sal_Int32 i = 0; i < aMethods.getLength(); ++i) + { + SAL_WARN("method information",aMethods[i]->getName()); + } + break; + } + } + } if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) ) { if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() && @@ -752,14 +784,26 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { ParagraphInsertedDeleted( rTextHint.GetValue(), true ); DoDelayedSyntaxHighlight( rTextHint.GetValue() ); + OUString sMod = rModulWindow.GetSbModule()->GetSource(); + OUString sActLine = pEditEngine->GetText( rTextHint.GetValue() ); + std::vector< CodeCompleteData > aData = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(); + aCodeCompleteCache = aData; } else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED ) { ParagraphInsertedDeleted( rTextHint.GetValue(), false ); + OUString sMod = rModulWindow.GetSbModule()->GetSource(); + OUString sActLine = pEditEngine->GetText( rTextHint.GetValue() ); + std::vector< CodeCompleteData > aData = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(); + aCodeCompleteCache = aData; } else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) { DoDelayedSyntaxHighlight( rTextHint.GetValue() ); + OUString sMod = rModulWindow.GetSbModule()->GetSource(); + OUString sActLine = pEditEngine->GetText( rTextHint.GetValue() ); + std::vector< CodeCompleteData > aData = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(); + aCodeCompleteCache = aData; } else if( rTextHint.GetId() == TEXT_HINT_VIEWSELECTIONCHANGED ) { diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 298712372ccd..3bd3fd60ce84 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -50,6 +50,7 @@ #include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/ModuleInfo.hpp> +#include <svtools/miscopt.hxx> using namespace ::com::sun::star::script; TYPEINIT1(StarBASIC,SbxObject) 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 diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index 609436944b63..8da4d1e13c3c 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -307,6 +307,8 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic ) bool bDefined = false; while( ( pDef = VarDecl( &pDim, bStatic, bConst ) ) != NULL ) { + /*fprintf(stderr, "Actual sub: \n"); + fprintf(stderr, "Symbol name: %s\n",OUStringToOString(pDef->GetName(),RTL_TEXTENCODING_UTF8).getStr());*/ EnableErrors(); // search variable: if( bSwitchPool ) diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx index d61f33444a7b..018b2938ee84 100644 --- a/basic/source/comp/parser.cxx +++ b/basic/source/comp/parser.cxx @@ -20,6 +20,7 @@ #include <basic/sbx.hxx> #include "sbcomp.hxx" #include <com/sun/star/script/ModuleType.hpp> +#include <svtools/miscopt.hxx> struct SbiParseStack { // "Stack" for statement-blocks SbiParseStack* pNext; // Chain diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 32cdabc7067b..e4d95f1dfb85 100644 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -22,6 +22,7 @@ #include "sbcomp.hxx" #include "image.hxx" #include <basic/sbobjmod.hxx> +#include <svtools/miscopt.hxx> #include <stdio.h> // To activate tracing enable in sbtrace.hxx @@ -993,5 +994,4 @@ sal_Bool SbModule::Compile() return bRet; } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx index f94e2c9e8a36..446397716dec 100644 --- a/include/basic/sbmod.hxx +++ b/include/basic/sbmod.hxx @@ -39,10 +39,18 @@ class SbProcedureProperty; class SbIfaceMapperMethod; class SbClassModuleObject; + class ModuleInitDependencyMap; struct ClassModuleRunInitItem; struct SbClassData; +struct CodeCompleteData +{ + OUString sVarName; + OUString sVarParent; + OUString sVarType; +}; + class BASIC_DLLPUBLIC SbModule : public SbxObject, private ::boost::noncopyable { friend class SbiCodeGen; @@ -132,6 +140,7 @@ public: void RemoveVars(); ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); + std::vector< CodeCompleteData > GetCodeCompleteDataFromParse(); }; SV_DECL_IMPL_REF(SbModule) |