basctl/source/basicide/baside2.hxx | 16 +++- basctl/source/basicide/baside2b.cxx | 107 +++++++++++++++++++---------- basic/Library_sb.mk | 1 basic/source/classes/codecompletecache.cxx | 50 +++++++++++++ basic/source/classes/sbxmod.cxx | 44 +++++++++-- include/basic/codecompletecache.hxx | 61 ++++++++++++++++ include/basic/sbmod.hxx | 7 + 7 files changed, 235 insertions(+), 51 deletions(-)
New commits: commit 1ca65c728b36daa93eba550d22bd2b6959d9d454 Author: Gergo Mocsi <gmocs...@gmail.com> Date: Fri Jul 19 22:00:29 2013 +0200 GSOC work, code fixes + cache implementation WARNING: cache implementation gives a link error to it's methods. Created the cache called CodeCompleteDataCache in file include/basic/codecompletecache.hxx This class should replace the std::vector< CodeCompleteData > int file baside2b.cxx When issuing command "make basic", it compiles fine, but, when "make basctl", it gives a link error (ld returned status 1) to CodeCompleteDataCache's methods. Change-Id: If78c6533b7fb5653cc459d22b80c98d097b886eb diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 8bb34cf..8f361be 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -52,6 +52,7 @@ class SvxSearchItem; #include <boost/scoped_ptr.hpp> #include <vcl/textdata.hxx> +#include <basic/codecompletecache.hxx> namespace com { namespace sun { namespace star { namespace beans { class XMultiPropertySet; @@ -114,8 +115,10 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface(sal_Bool bCreate = true); - std::vector< CodeCompleteData > aCodeCompleteCache; - CodeCompleteWindow* pCodeCompleteWnd; + //std::vector< CodeCompleteData > aCodeCompleteCache; + CodeCompleteDataCache aCodeCompleteCache; + //CodeCompleteWindow* pCodeCompleteWnd; + boost::scoped_ptr< CodeCompleteWindow > pCodeCompleteWnd; OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number protected: @@ -492,8 +495,9 @@ public: void ResizeListBox(); void SelectFirstEntry(); //selects first entry in ListBox -protected: - virtual void KeyInput( const KeyEvent& rKeyEvt ); +/*protected: + //virtual void KeyInput( const KeyEvent& rKeyEvt ); + virtual void LoseFocus();*/ }; class CodeCompleteListBox: public ListBox @@ -520,6 +524,10 @@ public: DECL_LINK(ImplDoubleClickHdl, void*); virtual long PreNotify( NotifyEvent& rNEvt ); + +/*protected: + virtual void LoseFocus();*/ + }; } // namespace basctl diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 3c8fbbe..6c099c8 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -232,7 +232,8 @@ EditorWindow::EditorWindow (Window* pParent, ModulWindow* pModulWindow) : nCurTextWidth(0), bHighlightning(false), bDoSyntaxHighlight(true), - bDelayHighlight(true) + bDelayHighlight(true), + pCodeCompleteWnd(new CodeCompleteWindow(this)) { SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor())); SetPointer( Pointer( POINTER_TEXT ) ); @@ -250,9 +251,6 @@ EditorWindow::EditorWindow (Window* pParent, ModulWindow* pModulWindow) : s[0] = OUString( "FontHeight" ); s[1] = OUString( "FontName" ); n->addPropertiesChangeListener(s, listener_.get()); - //aListBox = new CodeCompleteListBox(this); - //pCodeCopleteWnd = new CodeCompleteWindow(this); - pCodeCompleteWnd = new CodeCompleteWindow( this ); } @@ -274,8 +272,6 @@ EditorWindow::~EditorWindow() EndListening( *pEditEngine ); pEditEngine->RemoveView(pEditView.get()); } - - delete pCodeCompleteWnd; } OUString EditorWindow::GetWordAtCursor() @@ -504,7 +500,6 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) TextSelection aSel = GetEditView()->GetSelection(); sal_uLong nLine = aSel.GetStart().GetPara(); OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified - OUString aStr = aLine.copy( std::max(aLine.lastIndexOf(" "), aLine.lastIndexOf("\t"))+1 ); // variable name OUString sActSub = GetActualSubName( nLine ); std::vector< OUString > aVect; @@ -516,18 +511,22 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) if( r.tokenType == 1 ) // extract the identifers(methods, base variable) aVect.push_back( aLine.copy(r.nBegin, r.nEnd - r.nBegin) ); } - OUString sBaseName = aVect[0]; - for( unsigned int i = 0; i < aCodeCompleteCache.size(); ++i) - { - if( aCodeCompleteCache[i].sVarName.equalsIgnoreAsciiCase( sBaseName ) && + OUString sBaseName = aVect[0];//variable name + OUString sVarType = aCodeCompleteCache.GetVariableType(sBaseName, sActSub); + + /*for( unsigned int i = 0; i < aCodeCompleteCache.size(); ++i) + {*/ + /*if( aCodeCompleteCache[i].sVarName.equalsIgnoreAsciiCase( sBaseName ) && ( aCodeCompleteCache[i].sVarParent == sActSub || aCodeCompleteCache[i].IsGlobal() ) ) + {*/ + if( sVarType != aCodeCompleteCache.NOT_FOUND ) { Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW ); Reference< reflection::XIdlReflection > xRefl( xFactory->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY_THROW ); if( xRefl.is() ) { - Reference< reflection::XIdlClass > xClass = xRefl->forName(aCodeCompleteCache[i].sVarType);//get the base class for reflection + Reference< reflection::XIdlClass > xClass = xRefl->forName(sVarType);//get the base class for reflection if( xClass != NULL ) { unsigned int j = 1; @@ -552,8 +551,6 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) if( aMethods.getLength() != 0 ) { Rectangle aRect = ( (TextEngine*) GetEditEngine() )->PaMtoEditCursor( aSel.GetEnd() , false ); - //GetEditView()->EnableCursor( false ); - aSel.GetStart().GetIndex() += 1; aSel.GetEnd().GetIndex() += 1; pCodeCompleteWnd->ClearListBox(); @@ -564,15 +561,16 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) { pCodeCompleteWnd->InsertEntry( OUString(aMethods[l]->getName()) ); } - pCodeCompleteWnd->ResizeListBox(); pCodeCompleteWnd->Show(); + pCodeCompleteWnd->ResizeListBox(); pCodeCompleteWnd->SelectFirstEntry(); } } } - break; } - } + /*break; + }*/ + //} } if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) ) { @@ -834,12 +832,12 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) ParagraphInsertedDeleted( rTextHint.GetValue(), true ); DoDelayedSyntaxHighlight( rTextHint.GetValue() ); rModulWindow.UpdateModule(); - aCodeCompleteCache = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(); + aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); } else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED ) { ParagraphInsertedDeleted( rTextHint.GetValue(), false ); - aCodeCompleteCache = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(); + aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); } else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) { @@ -855,7 +853,7 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } else if( rTextHint.GetId() == TEXT_HINT_MODIFIED ) { - aCodeCompleteCache = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(); + aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); } } } @@ -878,7 +876,7 @@ OUString EditorWindow::GetActualSubName( sal_uLong nLine ) } } } - return OUString(""); + return aCodeCompleteCache.GLOB_KEY; } void EditorWindow::SetScrollBarRanges() @@ -2357,7 +2355,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped ) } CodeCompleteListBox::CodeCompleteListBox( CodeCompleteWindow* pPar ) -: ListBox(pPar, WB_SORT | WB_BORDER), +: ListBox(pPar, WB_SORT | WB_BORDER ), pCodeCompleteWindow(pPar) { SetDoubleClickHdl(LINK(this, CodeCompleteListBox, ImplDoubleClickHdl)); @@ -2376,7 +2374,7 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) void CodeCompleteListBox::InsertSelectedEntry() { - if( GetEntry( GetSelectEntryPos() ) != OUString("") ) + if( aFuncBuffer.toString() != OUString("") ) { // if the user typed in something: remove, and insert TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() + aFuncBuffer.getLength()); @@ -2384,16 +2382,35 @@ void CodeCompleteListBox::InsertSelectedEntry() pCodeCompleteWindow->pParent->GetEditView()->SetSelection(TextSelection(aStart, aEnd)); pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected(); - pCodeCompleteWindow->pParent->GetEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True ); - pCodeCompleteWindow->Hide(); - pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) ); - pCodeCompleteWindow->pParent->GrabFocus(); + if( GetEntry( GetSelectEntryPos() ) != OUString("") ) + {//if the user selected something + pCodeCompleteWindow->pParent->GetEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True ); + pCodeCompleteWindow->Hide(); + pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) ); + pCodeCompleteWindow->pParent->GrabFocus(); + } + else + { + pCodeCompleteWindow->Hide(); + pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) ); + pCodeCompleteWindow->pParent->GrabFocus(); + } + } + else + { + if( GetEntry( GetSelectEntryPos() ) != OUString("") ) + {//if the user selected something + pCodeCompleteWindow->pParent->GetEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True ); + pCodeCompleteWindow->Hide(); + pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) ); + pCodeCompleteWindow->pParent->GrabFocus(); + } } } long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt ) { - if( ( rNEvt.GetType() == EVENT_KEYINPUT ) ) + if( rNEvt.GetType() == EVENT_KEYINPUT ) { KeyEvent aKeyEvt = *rNEvt.GetKeyEvent(); sal_Unicode aChar = aKeyEvt.GetKeyCode().GetCode(); @@ -2439,6 +2456,11 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt ) } } } + /*if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN ) + { + //MouseEvent rMEvt = *rNEvt.GetMouseEvent(); + std::cerr << "parent active: " << (pCodeCompleteWindow->pParent->IsActive() == sal_True) << std::endl; + }*/ return ListBox::PreNotify( rNEvt ); } @@ -2454,12 +2476,19 @@ void CodeCompleteListBox::SetVisibleEntries() } } +/*void CodeCompleteListBox::LoseFocus() +{ + std::cerr << "CodeCompleteListBox::LoseFocus" << std::endl; + Window::LoseFocus(); + //pCodeCompleteWindow->Hide(); +}*/ + CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar ) -: Window( pPar, WB_BORDER ), +: Window( pPar ), pParent(pPar) { + SetSizePixel( Size(151,151) ); //default, later it changes InitListBox(); - SetSizePixel( Size(150,150) ); //default, later it changes } void CodeCompleteWindow::InitListBox() @@ -2467,7 +2496,7 @@ void CodeCompleteWindow::InitListBox() pListBox = new CodeCompleteListBox( this ); pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length pListBox->Show(); - pListBox->GrabFocus(); + //pListBox->GrabFocus(); } CodeCompleteWindow::~CodeCompleteWindow() @@ -2487,15 +2516,14 @@ void CodeCompleteWindow::ClearListBox() pListBox->aEntryVect.clear(); pListBox->aFuncBuffer.makeStringAndClear(); } - +/* void CodeCompleteWindow::KeyInput( const KeyEvent& rKeyEvt ) { if( rKeyEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) {// ESC key closes the window: does not modify anything - //pParent->GetEditView()->EnableCursor( true ); Hide(); } -} +}*/ void CodeCompleteWindow::SetTextSelection( const TextSelection& aSel ) { @@ -2525,8 +2553,11 @@ void CodeCompleteWindow::ResizeListBox() aSize.setWidth( pListBox->CalcSize(aLongestEntry.getLength(),pListBox->GetEntryCount()).getWidth() ); pListBox->SetSizePixel( aSize ); + aSize.setWidth( aSize.getWidth() + 1 ); + aSize.setHeight( aSize.getHeight() + 1 ); SetSizePixel( aSize ); } + //pListBox->GrabFocus(); } void CodeCompleteWindow::SelectFirstEntry() @@ -2534,10 +2565,16 @@ void CodeCompleteWindow::SelectFirstEntry() if( pListBox->GetEntryCount() > 0 ) { pListBox->SelectEntryPos( 0 ); - pListBox->GrabFocus(); } + //pListBox->GrabFocus(); } +/*void CodeCompleteWindow::LoseFocus() +{ + std::cerr << "CodeCompleteWindow::LoseFocus" << std::endl; + Window::LoseFocus(); +}*/ + } // namespace basctl /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/Library_sb.mk b/basic/Library_sb.mk index c892143..b325a15 100644 --- a/basic/Library_sb.mk +++ b/basic/Library_sb.mk @@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_exception_objects,sb,\ basic/source/basmgr/basicmanagerrepository \ basic/source/basmgr/basmgr \ basic/source/basmgr/vbahelper \ + basic/source/classes/codecompletecache \ basic/source/classes/errobject \ basic/source/classes/eventatt \ basic/source/classes/global \ diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx new file mode 100644 index 0000000..f483103 --- /dev/null +++ b/basic/source/classes/codecompletecache.cxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <basic/codecompletecache.hxx> + +const CodeCompleteVarScopes& CodeCompleteDataCache::GetVars() const +{ + return aVarScopes; +} + +void CodeCompleteDataCache::InsertProcedure( const OUString& sProcName, const CodeCompleteVarTypes& aVarTypes ) +{ + aVarScopes.insert( CodeCompleteVarScopes::value_type(sProcName, aVarTypes) ); +} +void CodeCompleteDataCache::SetVars( const CodeCompleteVarScopes& aScopes ) +{ + aVarScopes = aScopes; +} + +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 + return NOT_FOUND; + + CodeCompleteVarTypes aVarTypes = aIt->second; + CodeCompleteVarTypes::const_iterator aOtherIt = aVarTypes.find( sVarName ); + if( aOtherIt == aVarTypes.end() ) + return NOT_FOUND; + else + return aOtherIt->second; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 7f85be2..15774d8 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -90,6 +90,9 @@ typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap; ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar ); void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue ); +/*const OUString CodeCompleteDataCache::GLOB_KEY = OUString("global key"); +const OUString CodeCompleteDataCache::NOT_FOUND = OUString("not found");*/ + class DocObjectWrapper : public DocObjectWrapper_BASE { Reference< XAggregation > m_xAggProxy; @@ -1777,9 +1780,11 @@ IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/) return 0; } - -std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse() +//std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse() +CodeCompleteDataCache SbModule::GetCodeCompleteDataFromParse() { + CodeCompleteDataCache aCache; + ErrorHdlResetter aErrHdl; SbxBase::ResetError(); @@ -1788,37 +1793,56 @@ std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse() while( pParser->Parse() ) {} SbiSymPool* pPool = pParser->pPool; - std::vector< CodeCompleteData > aRet; + //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(); + //CodeCompleteData aCodeCompleteData; + CodeCompleteVarTypes aVarTypes; + /*aCodeCompleteData.sVarName = pSymDef->GetName(); aCodeCompleteData.sVarParent = OUString(""); aCodeCompleteData.sVarType = pParser->aGblStrings.Find( pSymDef->GetTypeId() ); if(!aCodeCompleteData.sVarType.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 ); + } } SbiSymPool& pChildPool = pSymDef->GetPool(); for(sal_uInt16 j = 0; j < pChildPool.GetSize(); ++j ) { - CodeCompleteData aCodeCompleteData; + //CodeCompleteData aCodeCompleteData; + CodeCompleteVarTypes aVarTypes; + SbiSymDef* pChildSymDef = pChildPool.Get(j); if( pChildSymDef->GetType() == SbxOBJECT ) { - aCodeCompleteData.sVarName = pChildSymDef->GetName(); + /*aCodeCompleteData.sVarName = pChildSymDef->GetName(); aCodeCompleteData.sVarParent = pSymDef->GetName(); aCodeCompleteData.sVarType = pParser->aGblStrings.Find( pChildSymDef->GetTypeId() ); - if(!aCodeCompleteData.sVarType.isEmpty()) - aRet.push_back(aCodeCompleteData); + if(!aCodeCompleteData.sVarType.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 << aCache << std::endl; delete pParser; - return aRet; + //return aRet; + return aCache; } SbxArrayRef SbModule::GetMethods() diff --git a/include/basic/codecompletecache.hxx b/include/basic/codecompletecache.hxx new file mode 100644 index 0000000..f375f04 --- /dev/null +++ b/include/basic/codecompletecache.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef CODECOMPLETECACHE_H +#define CODECOMPLETECACHE_H + +#include <basic/sbdef.hxx> +#include <basic/sbxobj.hxx> +#include <basic/sbxdef.hxx> +#include <boost/utility.hpp> +#include <boost/unordered_map.hpp> +#include <rtl/ustring.hxx> + +typedef boost::unordered_map< OUString, OUString, OUStringHash > CodeCompleteVarTypes; +/* variable name, type */ +typedef boost::unordered_map< OUString, CodeCompleteVarTypes, OUStringHash > CodeCompleteVarScopes; +/* procedure, CodeCompleteVarTypes */ + +class CodeCompleteDataCache +{ +/* + * cache to store data for + * code completition + * */ +private: + CodeCompleteVarScopes aVarScopes; + +public: + const OUString GLOB_KEY = OUString("global key"); + const OUString NOT_FOUND = OUString("not found"); + CodeCompleteDataCache(){} + + virtual ~CodeCompleteDataCache(){} + + void SetVars( const CodeCompleteVarScopes& aScopes ); + const CodeCompleteVarScopes& GetVars() const; + + void InsertProcedure( const OUString& sProcName, const CodeCompleteVarTypes& aVarTypes ); + const OUString& GetVariableType( const OUString& sVarName, const OUString& sProcName ) const; + +}; + +#endif // CODECOMPLETECACHE_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx index 65dab93..763beef 100644 --- a/include/basic/sbmod.hxx +++ b/include/basic/sbmod.hxx @@ -29,6 +29,7 @@ #include <deque> #include <boost/utility.hpp> #include "basicdllapi.h" +#include <basic/codecompletecache.hxx> class SbMethod; class SbProperty; @@ -44,6 +45,7 @@ class ModuleInitDependencyMap; struct ClassModuleRunInitItem; struct SbClassData; +/* struct CodeCompleteData { OUString sVarName; @@ -59,7 +61,7 @@ struct CodeCompleteData { return ( sVarParent == OUString("") ); } -}; +};*/ class BASIC_DLLPUBLIC SbModule : public SbxObject, private ::boost::noncopyable { @@ -150,7 +152,8 @@ 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(); + //std::vector< CodeCompleteData > GetCodeCompleteDataFromParse(); + CodeCompleteDataCache GetCodeCompleteDataFromParse(); SbxArrayRef GetMethods(); }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits