summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basctl/source/basicide/baside2.hxx55
-rw-r--r--basctl/source/basicide/baside2b.cxx149
-rw-r--r--basic/source/classes/codecompletecache.cxx22
-rw-r--r--basic/source/classes/sbxmod.cxx40
-rw-r--r--include/basic/codecompletecache.hxx10
-rw-r--r--include/basic/sbmod.hxx1
6 files changed, 114 insertions, 163 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 8f361bed7ead..eaf700bdb5b2 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -115,9 +115,7 @@ private:
virtual
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
GetComponentInterface(sal_Bool bCreate = true);
- //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
@@ -474,32 +472,6 @@ private:
} aSyntaxColors;
};
-class CodeCompleteWindow: public Window
-{
-friend class CodeCompleteListBox;
-private:
- EditorWindow* pParent; // parent window
- TextSelection aTextSelection;
- CodeCompleteListBox* pListBox;
-
- void InitListBox(); // initialize the ListBox
-
-public:
- CodeCompleteWindow( EditorWindow* pPar );
- virtual ~CodeCompleteWindow();
-
- void InsertEntry( const OUString& aStr );
- void ClearListBox();
- void SetTextSelection( const TextSelection& aSel );
- const TextSelection& GetTextSelection() const;
- void ResizeListBox();
- void SelectFirstEntry(); //selects first entry in ListBox
-
-/*protected:
- //virtual void KeyInput( const KeyEvent& rKeyEvt );
- virtual void LoseFocus();*/
-};
-
class CodeCompleteListBox: public ListBox
{
friend class CodeCompleteWindow;
@@ -517,16 +489,35 @@ private:
void SetVisibleEntries(); // sets the visible entries based on aFuncBuffer variable
public:
- CodeCompleteListBox(CodeCompleteWindow* pPar);
- virtual ~CodeCompleteListBox();
+ CodeCompleteListBox( CodeCompleteWindow* pPar );
void InsertSelectedEntry(); //insert the selected entry
DECL_LINK(ImplDoubleClickHdl, void*);
virtual long PreNotify( NotifyEvent& rNEvt );
-/*protected:
- virtual void LoseFocus();*/
+};
+
+class CodeCompleteWindow: public Window
+{
+friend class CodeCompleteListBox;
+private:
+ EditorWindow* pParent; // parent window
+ TextSelection aTextSelection;
+ CodeCompleteListBox* pListBox;
+
+ void InitListBox(); // initialize the ListBox
+
+public:
+ CodeCompleteWindow( EditorWindow* pPar );
+ ~CodeCompleteWindow(){ delete pListBox; }
+
+ void InsertEntry( const OUString& aStr );
+ void ClearListBox();
+ void SetTextSelection( const TextSelection& aSel );
+ const TextSelection& GetTextSelection() const;
+ void ResizeListBox();
+ void SelectFirstEntry(); //selects first entry in ListBox
};
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 513894baef55..d3006427939d 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -518,65 +518,57 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
aVect.push_back( aLine.copy(r.nBegin, r.nEnd - r.nBegin) );
}
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 );
+ OUString sVarType = aCodeCompleteCache.GetVariableType(sBaseName, aCodeCompleteCache.GLOB_KEY);
+ if( sVarType == aCodeCompleteCache.NOT_FOUND )
+ sVarType = aCodeCompleteCache.GetVariableType(sBaseName, sActSub);
+
+ 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() )
+ if( xRefl.is() )
+ {
+ Reference< reflection::XIdlClass > xClass = xRefl->forName(sVarType);//get the base class for reflection
+ if( xClass != NULL )
+ {
+ unsigned int j = 1;
+ OUString sMethName;
+ while( j != aVect.size() )
{
- Reference< reflection::XIdlClass > xClass = xRefl->forName(sVarType);//get the base class for reflection
- if( xClass != NULL )
+ sMethName = aVect[j];
+ Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName );
+ if( xMethod != NULL ) //method OK
{
- unsigned int j = 1;
- OUString sMethName;
- while( j != aVect.size() )
- {
- sMethName = aVect[j];
- Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName );
- if( xMethod != NULL ) //method OK
- {
- xClass = xMethod->getReturnType();
- if( xClass == NULL )
- break;
- }
- else
- {
- break;
- }
- j++;
- }
- Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
- if( aMethods.getLength() != 0 )
- {
- Rectangle aRect = ( (TextEngine*) GetEditEngine() )->PaMtoEditCursor( aSel.GetEnd() , false );
- aSel.GetStart().GetIndex() += 1;
- aSel.GetEnd().GetIndex() += 1;
- pCodeCompleteWnd->ClearListBox();
- pCodeCompleteWnd->SetTextSelection(aSel);
-
- pCodeCompleteWnd->SetPosPixel( aRect.BottomRight() );
- for(sal_Int32 l = 0; l < aMethods.getLength(); ++l)
- {
- pCodeCompleteWnd->InsertEntry( OUString(aMethods[l]->getName()) );
- }
- pCodeCompleteWnd->Show();
- pCodeCompleteWnd->ResizeListBox();
- pCodeCompleteWnd->SelectFirstEntry();
- }
+ xClass = xMethod->getReturnType();
+ if( xClass == NULL )
+ break;
+ }
+ else
+ {
+ break;
+ }
+ j++;
+ }
+ Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
+ if( aMethods.getLength() != 0 )
+ {
+ Rectangle aRect = ( (TextEngine*) GetEditEngine() )->PaMtoEditCursor( aSel.GetEnd() , false );
+ aSel.GetStart().GetIndex() += 1;
+ aSel.GetEnd().GetIndex() += 1;
+ pCodeCompleteWnd->ClearListBox();
+ pCodeCompleteWnd->SetTextSelection(aSel);
+
+ pCodeCompleteWnd->SetPosPixel( aRect.BottomRight() );
+ for(sal_Int32 l = 0; l < aMethods.getLength(); ++l)
+ {
+ pCodeCompleteWnd->InsertEntry( OUString(aMethods[l]->getName()) );
}
+ pCodeCompleteWnd->Show();
+ pCodeCompleteWnd->ResizeListBox();
+ pCodeCompleteWnd->SelectFirstEntry();
}
}
- /*break;
- }*/
- //}
+ }
+
}
if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) )
{
@@ -843,6 +835,7 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED )
{
ParagraphInsertedDeleted( rTextHint.GetValue(), false );
+ rModulWindow.UpdateModule();
aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
}
else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED )
@@ -859,6 +852,7 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
else if( rTextHint.GetId() == TEXT_HINT_MODIFIED )
{
+ rModulWindow.UpdateModule();
aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
}
}
@@ -878,6 +872,7 @@ OUString EditorWindow::GetActualSubName( sal_uLong nLine )
pMeth->GetLineRange(l1,l2);
if( (l1 <= nLine+1) && (nLine+1 <= l2) )
{
+ //std::cerr << "sName: " << sName << std::endl;
return sName;
}
}
@@ -2362,16 +2357,11 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
CodeCompleteListBox::CodeCompleteListBox( CodeCompleteWindow* pPar )
: ListBox(pPar, WB_SORT | WB_BORDER ),
-pCodeCompleteWindow(pPar)
+pCodeCompleteWindow( pPar )
{
SetDoubleClickHdl(LINK(this, CodeCompleteListBox, ImplDoubleClickHdl));
}
-CodeCompleteListBox::~CodeCompleteListBox()
-{
- delete pCodeCompleteWindow;
-}
-
IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
{
InsertSelectedEntry();
@@ -2434,7 +2424,7 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
case KEY_ESCAPE: // hide, do nothing
pCodeCompleteWindow->Hide();
pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
- pCodeCompleteWindow->pParent->GrabFocus();
+ //pCodeCompleteWindow->pParent->GrabFocus();
return 0;
case KEY_TAB: case KEY_SPACE:
/* space, tab the user probably have typed in the whole
@@ -2462,11 +2452,6 @@ 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 );
}
@@ -2482,16 +2467,10 @@ void CodeCompleteListBox::SetVisibleEntries()
}
}
-/*void CodeCompleteListBox::LoseFocus()
-{
- std::cerr << "CodeCompleteListBox::LoseFocus" << std::endl;
- Window::LoseFocus();
- //pCodeCompleteWindow->Hide();
-}*/
-
CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar )
: Window( pPar ),
-pParent(pPar)
+pParent( pPar ),
+pListBox( new CodeCompleteListBox(this) )
{
SetSizePixel( Size(151,151) ); //default, later it changes
InitListBox();
@@ -2499,15 +2478,9 @@ pParent(pPar)
void CodeCompleteWindow::InitListBox()
{
- pListBox = new CodeCompleteListBox( this );
pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length
pListBox->Show();
- //pListBox->GrabFocus();
-}
-
-CodeCompleteWindow::~CodeCompleteWindow()
-{
- delete pListBox;
+ pListBox->GrabFocus();
}
void CodeCompleteWindow::InsertEntry( const OUString& aStr )
@@ -2522,14 +2495,6 @@ 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
- Hide();
- }
-}*/
void CodeCompleteWindow::SetTextSelection( const TextSelection& aSel )
{
@@ -2563,7 +2528,6 @@ void CodeCompleteWindow::ResizeListBox()
aSize.setHeight( aSize.getHeight() + 1 );
SetSizePixel( aSize );
}
- //pListBox->GrabFocus();
}
void CodeCompleteWindow::SelectFirstEntry()
@@ -2572,15 +2536,8 @@ void CodeCompleteWindow::SelectFirstEntry()
{
pListBox->SelectEntryPos( 0 );
}
- //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/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;
}
diff --git a/include/basic/codecompletecache.hxx b/include/basic/codecompletecache.hxx
index f375f04d0484..bba25d9b0659 100644
--- a/include/basic/codecompletecache.hxx
+++ b/include/basic/codecompletecache.hxx
@@ -32,7 +32,7 @@ typedef boost::unordered_map< OUString, OUString, OUStringHash > CodeCompleteVar
typedef boost::unordered_map< OUString, CodeCompleteVarTypes, OUStringHash > CodeCompleteVarScopes;
/* procedure, CodeCompleteVarTypes */
-class CodeCompleteDataCache
+class BASIC_DLLPUBLIC CodeCompleteDataCache
{
/*
* cache to store data for
@@ -44,16 +44,18 @@ private:
public:
const OUString GLOB_KEY = OUString("global key");
const OUString NOT_FOUND = OUString("not found");
- CodeCompleteDataCache(){}
+ CodeCompleteDataCache(){}
virtual ~CodeCompleteDataCache(){}
+ friend std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache);
+
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;
-
+ OUString GetVariableType( const OUString& sVarName, const OUString& sProcName ) const;
+ void print() const; // wrapper for operator<<, prints to std::cerr
};
#endif // CODECOMPLETECACHE_H
diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx
index 763beefe3c5d..5a77cfb9dd2d 100644
--- a/include/basic/sbmod.hxx
+++ b/include/basic/sbmod.hxx
@@ -152,7 +152,6 @@ 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();
CodeCompleteDataCache GetCodeCompleteDataFromParse();
SbxArrayRef GetMethods();
};