Kaydet (Commit) 6c1854f9 authored tarafından Gergo Mocsi's avatar Gergo Mocsi

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
üst 5a615ddf
...@@ -52,6 +52,7 @@ class SvxSearchItem; ...@@ -52,6 +52,7 @@ class SvxSearchItem;
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <vcl/textdata.hxx> #include <vcl/textdata.hxx>
#include <basic/codecompletecache.hxx>
namespace com { namespace sun { namespace star { namespace beans { namespace com { namespace sun { namespace star { namespace beans {
class XMultiPropertySet; class XMultiPropertySet;
...@@ -114,8 +115,10 @@ private: ...@@ -114,8 +115,10 @@ private:
virtual virtual
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
GetComponentInterface(sal_Bool bCreate = true); GetComponentInterface(sal_Bool bCreate = true);
std::vector< CodeCompleteData > aCodeCompleteCache; //std::vector< CodeCompleteData > aCodeCompleteCache;
CodeCompleteWindow* pCodeCompleteWnd; CodeCompleteDataCache aCodeCompleteCache;
//CodeCompleteWindow* pCodeCompleteWnd;
boost::scoped_ptr< CodeCompleteWindow > pCodeCompleteWnd;
OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number
protected: protected:
...@@ -492,8 +495,9 @@ public: ...@@ -492,8 +495,9 @@ public:
void ResizeListBox(); void ResizeListBox();
void SelectFirstEntry(); //selects first entry in ListBox void SelectFirstEntry(); //selects first entry in ListBox
protected: /*protected:
virtual void KeyInput( const KeyEvent& rKeyEvt ); //virtual void KeyInput( const KeyEvent& rKeyEvt );
virtual void LoseFocus();*/
}; };
class CodeCompleteListBox: public ListBox class CodeCompleteListBox: public ListBox
...@@ -520,6 +524,10 @@ public: ...@@ -520,6 +524,10 @@ public:
DECL_LINK(ImplDoubleClickHdl, void*); DECL_LINK(ImplDoubleClickHdl, void*);
virtual long PreNotify( NotifyEvent& rNEvt ); virtual long PreNotify( NotifyEvent& rNEvt );
/*protected:
virtual void LoseFocus();*/
}; };
} // namespace basctl } // namespace basctl
......
...@@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_exception_objects,sb,\ ...@@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_exception_objects,sb,\
basic/source/basmgr/basicmanagerrepository \ basic/source/basmgr/basicmanagerrepository \
basic/source/basmgr/basmgr \ basic/source/basmgr/basmgr \
basic/source/basmgr/vbahelper \ basic/source/basmgr/vbahelper \
basic/source/classes/codecompletecache \
basic/source/classes/errobject \ basic/source/classes/errobject \
basic/source/classes/eventatt \ basic/source/classes/eventatt \
basic/source/classes/global \ basic/source/classes/global \
......
/* -*- 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: */
...@@ -90,6 +90,9 @@ typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap; ...@@ -90,6 +90,9 @@ typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap;
::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar ); ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar );
void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue ); 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 class DocObjectWrapper : public DocObjectWrapper_BASE
{ {
Reference< XAggregation > m_xAggProxy; Reference< XAggregation > m_xAggProxy;
...@@ -1777,9 +1780,11 @@ IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/) ...@@ -1777,9 +1780,11 @@ IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/)
return 0; return 0;
} }
//std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse()
std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse() CodeCompleteDataCache SbModule::GetCodeCompleteDataFromParse()
{ {
CodeCompleteDataCache aCache;
ErrorHdlResetter aErrHdl; ErrorHdlResetter aErrHdl;
SbxBase::ResetError(); SbxBase::ResetError();
...@@ -1788,37 +1793,56 @@ std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse() ...@@ -1788,37 +1793,56 @@ std::vector< CodeCompleteData > SbModule::GetCodeCompleteDataFromParse()
while( pParser->Parse() ) {} while( pParser->Parse() ) {}
SbiSymPool* pPool = pParser->pPool; SbiSymPool* pPool = pParser->pPool;
std::vector< CodeCompleteData > aRet; //std::vector< CodeCompleteData > aRet;
for( sal_uInt16 i = 0; i < pPool->GetSize(); ++i ) for( sal_uInt16 i = 0; i < pPool->GetSize(); ++i )
{ {
SbiSymDef* pSymDef = pPool->Get(i); SbiSymDef* pSymDef = pPool->Get(i);
if( pSymDef->GetType() == SbxOBJECT ) if( pSymDef->GetType() == SbxOBJECT )
{ {
CodeCompleteData aCodeCompleteData; //CodeCompleteData aCodeCompleteData;
aCodeCompleteData.sVarName = pSymDef->GetName(); CodeCompleteVarTypes aVarTypes;
/*aCodeCompleteData.sVarName = pSymDef->GetName();
aCodeCompleteData.sVarParent = OUString(""); aCodeCompleteData.sVarParent = OUString("");
aCodeCompleteData.sVarType = pParser->aGblStrings.Find( pSymDef->GetTypeId() ); aCodeCompleteData.sVarType = pParser->aGblStrings.Find( pSymDef->GetTypeId() );
if(!aCodeCompleteData.sVarType.isEmpty()) if(!aCodeCompleteData.sVarType.isEmpty())
{
aRet.push_back(aCodeCompleteData); 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(); SbiSymPool& pChildPool = pSymDef->GetPool();
for(sal_uInt16 j = 0; j < pChildPool.GetSize(); ++j ) for(sal_uInt16 j = 0; j < pChildPool.GetSize(); ++j )
{ {
CodeCompleteData aCodeCompleteData; //CodeCompleteData aCodeCompleteData;
CodeCompleteVarTypes aVarTypes;
SbiSymDef* pChildSymDef = pChildPool.Get(j); SbiSymDef* pChildSymDef = pChildPool.Get(j);
if( pChildSymDef->GetType() == SbxOBJECT ) if( pChildSymDef->GetType() == SbxOBJECT )
{ {
aCodeCompleteData.sVarName = pChildSymDef->GetName(); /*aCodeCompleteData.sVarName = pChildSymDef->GetName();
aCodeCompleteData.sVarParent = pSymDef->GetName(); aCodeCompleteData.sVarParent = pSymDef->GetName();
aCodeCompleteData.sVarType = pParser->aGblStrings.Find( pChildSymDef->GetTypeId() ); aCodeCompleteData.sVarType = pParser->aGblStrings.Find( pChildSymDef->GetTypeId() );
if(!aCodeCompleteData.sVarType.isEmpty()) if(!aCodeCompleteData.sVarType.isEmpty())*/
aRet.push_back(aCodeCompleteData); 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; delete pParser;
return aRet; //return aRet;
return aCache;
} }
SbxArrayRef SbModule::GetMethods() SbxArrayRef SbModule::GetMethods()
......
/* -*- 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: */
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <deque> #include <deque>
#include <boost/utility.hpp> #include <boost/utility.hpp>
#include "basicdllapi.h" #include "basicdllapi.h"
#include <basic/codecompletecache.hxx>
class SbMethod; class SbMethod;
class SbProperty; class SbProperty;
...@@ -44,6 +45,7 @@ class ModuleInitDependencyMap; ...@@ -44,6 +45,7 @@ class ModuleInitDependencyMap;
struct ClassModuleRunInitItem; struct ClassModuleRunInitItem;
struct SbClassData; struct SbClassData;
/*
struct CodeCompleteData struct CodeCompleteData
{ {
OUString sVarName; OUString sVarName;
...@@ -59,7 +61,7 @@ struct CodeCompleteData ...@@ -59,7 +61,7 @@ struct CodeCompleteData
{ {
return ( sVarParent == OUString("") ); return ( sVarParent == OUString("") );
} }
}; };*/
class BASIC_DLLPUBLIC SbModule : public SbxObject, private ::boost::noncopyable class BASIC_DLLPUBLIC SbModule : public SbxObject, private ::boost::noncopyable
{ {
...@@ -150,7 +152,8 @@ public: ...@@ -150,7 +152,8 @@ public:
void RemoveVars(); void RemoveVars();
::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule();
bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
std::vector< CodeCompleteData > GetCodeCompleteDataFromParse(); //std::vector< CodeCompleteData > GetCodeCompleteDataFromParse();
CodeCompleteDataCache GetCodeCompleteDataFromParse();
SbxArrayRef GetMethods(); SbxArrayRef GetMethods();
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment