summaryrefslogtreecommitdiffstats
path: root/basic
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-19 22:00:29 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-02 18:16:45 +0200
commit6c1854f9f3f7308dce0e326aa063d929f8da5881 (patch)
treeda87e662a0b6c351098265adc96ae860019e4562 /basic
parentGSOC work ListBox show/hide entries when typing function name (diff)
downloadcore-6c1854f9f3f7308dce0e326aa063d929f8da5881.tar.gz
core-6c1854f9f3f7308dce0e326aa063d929f8da5881.zip
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
Diffstat (limited to 'basic')
-rw-r--r--basic/Library_sb.mk1
-rw-r--r--basic/source/classes/codecompletecache.cxx50
-rw-r--r--basic/source/classes/sbxmod.cxx44
3 files changed, 85 insertions, 10 deletions
diff --git a/basic/Library_sb.mk b/basic/Library_sb.mk
index c89214389b8b..b325a159bcb4 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 000000000000..f4831039ed6d
--- /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 7f85be207f14..15774d811bde 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()