summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-25 19:12:37 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-02 18:16:49 +0200
commit9a7b942a0a3bb113cf356f2642766f7a9f909bd6 (patch)
treeddc5cfca7dbd2fedaa03d2bc620ba6e75aac9496 /basic
parentd5aa9c3b23f6c9b5ff0b6af11ff6d6827c5f24bd (diff)
GSOC work, procedure autoclose implementation
Now, function procedure autoclose is working. Created a struct named IncompleteProcData to store the line number, type and name of the inclomplete procedure. Procedures are store in a vector (IncompleteProcedures), and are as a member in SbModule. I've created a function called SbModule::GetIncompleteProcedures() to extract the data. Data extraction uses SbModule::SetSource32, beacuse that one tokenizes sthe source file, and recognizes procedures. Closing procedures is triggered ky pressing the Enter key when typing. It checks the actual sub, and if it's incomplete, adds the correct ending( End Sub/End Function). There is only one problem: function SbModule::SetSource32 is not too often calle, maybe extraction should be done by a timer. Change-Id: Id88daaef329e8b5c194b765c5261d356bfb3a0c9
Diffstat (limited to 'basic')
-rw-r--r--basic/source/classes/codecompletecache.cxx2
-rw-r--r--basic/source/classes/sbxmod.cxx29
2 files changed, 20 insertions, 11 deletions
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index 952e4ee7538a..51eee1c84c0a 100644
--- a/basic/source/classes/codecompletecache.cxx
+++ b/basic/source/classes/codecompletecache.cxx
@@ -28,7 +28,7 @@ namespace
CodeCompleteOptions::CodeCompleteOptions()
: bIsCodeCompleteOn( false ),
-bIsProcedureAutoCompleteOn( false )
+bIsProcedureAutoCompleteOn( true )
{
}
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 694fbf338fe0..fa04809b7c54 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -894,6 +894,10 @@ void SbModule::SetSource32( const OUString& r )
StartDefinitions();
SbiTokenizer aTok( r );
aTok.SetCompatible( IsVBACompat() );
+ if( CodeCompleteOptions::IsProcedureAutoCompleteOn() )
+ {
+ aIncompleteProcs.clear();
+ }
while( !aTok.IsEof() )
{
SbiToken eEndTok = NIL;
@@ -976,24 +980,29 @@ void SbModule::SetSource32( const OUString& r )
if( aTok.IsEof() )
{
pMeth->nLine2 = aTok.GetLine();
- std::cerr << "EOF reached, no end for "<< sMethName <<", line " << aTok.GetLine() << std::endl;
- //std::cerr << "write end to: " << aOUSource.getLength() / pMeth->nLine2 << std::endl;
- sal_Int32 nPos=0;
- sal_Int32 nCounter = 0;
- std::cerr << "source length: " << aOUSource.getLength() << std::endl;
- for(sal_uInt32 i=0; i < aOUSource.getLength() ; ++i)
+ if( CodeCompleteOptions::IsProcedureAutoCompleteOn() )
{
- nPos++;
- if( aOUSource[i] == '\n' && nCounter != aTok.GetLine() )
- nCounter++;
+ 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);
}
- std::cerr << "newline index: " << nPos << std::endl;
}
}
}
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 )