summaryrefslogtreecommitdiffstats
path: root/basic
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-29 22:27:41 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-02 18:16:52 +0200
commitc149c96cf4c42820f15a0fea14cb7a4927ae4b1e (patch)
tree03e4e409130cf775a137545a300c1a64ad1f3b78 /basic
parentGSOC work, listbox appearance fix (diff)
downloadcore-c149c96cf4c42820f15a0fea14cb7a4927ae4b1e.tar.gz
core-c149c96cf4c42820f15a0fea14cb7a4927ae4b1e.zip
GSOC work, "autocomplete procedures" fix + new feature
Fixed the procedure autoclose function. Now, autoclose is based on the syntax higlighter: if finds an opening token, starts searching forward to a close token. If there is another sub/function keyword, or EOF is reached, the procedure is considered incomplete. If the end token is found, the procedure is considered to be closed. Added function autocorrect symbol spelling, wich corrects the ascii case of the keywords, and corrects the spelling of the extended types. Change-Id: Ibd17f319a6d6ff5c3f91f4adb7a10dc701f0468a
Diffstat (limited to 'basic')
-rw-r--r--basic/source/classes/codecompletecache.cxx37
-rw-r--r--basic/source/classes/sbxmod.cxx26
2 files changed, 36 insertions, 27 deletions
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index 0c757df4b2c5..f48952f36394 100644
--- a/basic/source/classes/codecompletecache.cxx
+++ b/basic/source/classes/codecompletecache.cxx
@@ -27,10 +27,11 @@ namespace
}
CodeCompleteOptions::CodeCompleteOptions()
-: bIsCodeCompleteOn( true ),
+: bIsCodeCompleteOn( false ),
bIsProcedureAutoCompleteOn( false ),
bIsAutoCloseQuotesOn( false ),
-bIsAutoCloseParenthesisOn( false )
+bIsAutoCloseParenthesisOn( false ),
+bIsAutoCorrectSpellingOn( false )
{
}
@@ -79,6 +80,16 @@ void CodeCompleteOptions::SetAutoCloseParenthesisOn( const bool& b )
theCodeCompleteOptions::get().bIsAutoCloseParenthesisOn = b;
}
+bool CodeCompleteOptions::IsAutoCorrectSpellingOn()
+{
+ return theCodeCompleteOptions::get().aMiscOptions.IsExperimentalMode() && theCodeCompleteOptions::get().bIsAutoCorrectSpellingOn;
+}
+
+void CodeCompleteOptions::SetAutoCorrectSpellingOn( const bool& b )
+{
+ theCodeCompleteOptions::get().bIsAutoCorrectSpellingOn = b;
+}
+
std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache)
{
aStream << "Global variables" << std::endl;
@@ -164,4 +175,26 @@ OUString CodeCompleteDataCache::GetVarType( const OUString& sVarName ) const
return OUString(""); //not found
}
+OUString CodeCompleteDataCache::GetCorrectCaseVarName( const OUString& sVarName ) const
+{
+ for( CodeCompleteVarScopes::const_iterator aIt = aVarScopes.begin(); aIt != aVarScopes.end(); ++aIt )
+ {
+ CodeCompleteVarTypes aTypes = aIt->second;
+ for( CodeCompleteVarTypes::const_iterator aOtherIt = aTypes.begin(); aOtherIt != aTypes.end(); ++aOtherIt )
+ {
+ if( aOtherIt->first.equalsIgnoreAsciiCase( sVarName ) )
+ {
+ return aOtherIt->first;
+ }
+ }
+ }
+ //not a local, search global scope
+ for( CodeCompleteVarTypes::const_iterator aIt = aGlobalVars.begin(); aIt != aGlobalVars.end(); ++aIt )
+ {
+ if( aIt->first.equalsIgnoreAsciiCase( sVarName ) )
+ return aIt->first;
+ }
+ return OUString(""); //not found
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index fa04809b7c54..989f5f547dae 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -894,10 +894,7 @@ void SbModule::SetSource32( const OUString& r )
StartDefinitions();
SbiTokenizer aTok( r );
aTok.SetCompatible( IsVBACompat() );
- if( CodeCompleteOptions::IsProcedureAutoCompleteOn() )
- {
- aIncompleteProcs.clear();
- }
+
while( !aTok.IsEof() )
{
SbiToken eEndTok = NIL;
@@ -941,15 +938,12 @@ void SbModule::SetSource32( const OUString& r )
}
// Definition of the method
SbMethod* pMeth = NULL;
- OUString sMethName;
if( eEndTok != NIL )
{
sal_uInt16 nLine1 = aTok.GetLine();
if( aTok.Next() == SYMBOL )
{
OUString aName_( aTok.GetSym() );
- //std::cerr << "method name: " << aName_ << std::endl;
- sMethName = aName_;
SbxDataType t = aTok.GetType();
if( t == SbxVARIANT && eEndTok == ENDSUB )
{
@@ -973,36 +967,18 @@ void SbModule::SetSource32( const OUString& r )
if( aTok.Next() == eEndTok )
{
pMeth->nLine2 = aTok.GetLine();
- //std::cerr << "there is end for "<< sMethName << std::endl;
break;
}
}
if( aTok.IsEof() )
{
pMeth->nLine2 = aTok.GetLine();
- if( CodeCompleteOptions::IsProcedureAutoCompleteOn() )
- {
- IncompleteProcData aProcData;
- aProcData.sProcName = sMethName;
- aProcData.nLine = pMeth->nLine2;
-
- if( eEndTok == ENDSUB )
- aProcData.aType = ACSUB;
- if( eEndTok == ENDFUNC )
- aProcData.aType = ACFUNC;
- aIncompleteProcs.push_back(aProcData);
- }
}
}
}
EndDefinitions( sal_True );
}
-IncompleteProcedures SbModule::GetIncompleteProcedures() const
-{
- return aIncompleteProcs;
-}
-
// Broadcast of a hint to all Basics
static void _SendHint( SbxObject* pObj, sal_uIntPtr nId, SbMethod* p )