GSOC work, code complete option, menu entry fixes
Menu entry is added under View->Enable Code Completition when in Experimental mode. Fixed the call of funtion SbModule::GetCodeCompleteDataFromParse() to be called only when code completition is enabled. Replaced the occurences of SvtMiscOptions to CodeCompleteOptions. Change-Id: If0520123ab5f612d7d24fb98f8e9bf6881af76cb
This commit is contained in:
@@ -35,6 +35,13 @@ shell basctl_Shell
|
|||||||
StateMethod = GetState;
|
StateMethod = GetState;
|
||||||
ExecMethod = ExecuteCurrent;
|
ExecMethod = ExecuteCurrent;
|
||||||
]
|
]
|
||||||
|
|
||||||
|
SID_BASICIDE_CODECOMPLETITION
|
||||||
|
[
|
||||||
|
StateMethod = GetState;
|
||||||
|
ExecMethod = ExecuteCurrent;
|
||||||
|
]
|
||||||
|
|
||||||
SID_BASICIDE_HIDECURPAGE
|
SID_BASICIDE_HIDECURPAGE
|
||||||
[
|
[
|
||||||
ExecMethod = ExecuteCurrent;
|
ExecMethod = ExecuteCurrent;
|
||||||
@@ -138,12 +145,6 @@ shell basctl_Shell
|
|||||||
StateMethod = GetState;
|
StateMethod = GetState;
|
||||||
]
|
]
|
||||||
|
|
||||||
SID_BASICIDE_CODECOMPLETITION
|
|
||||||
[
|
|
||||||
ExecMethod = ExecuteCurrent;
|
|
||||||
StateMethod = GetState;
|
|
||||||
]
|
|
||||||
|
|
||||||
SID_BASICIDE_LIBSELECTED
|
SID_BASICIDE_LIBSELECTED
|
||||||
[
|
[
|
||||||
ExecMethod = ExecuteGlobal;
|
ExecMethod = ExecuteGlobal;
|
||||||
|
@@ -52,6 +52,8 @@
|
|||||||
#include <toolkit/helper/vclunohelper.hxx>
|
#include <toolkit/helper/vclunohelper.hxx>
|
||||||
#include <vcl/msgbox.hxx>
|
#include <vcl/msgbox.hxx>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <basic/codecompletecache.hxx>
|
||||||
|
#include <svtools/miscopt.hxx>
|
||||||
|
|
||||||
namespace basctl
|
namespace basctl
|
||||||
{
|
{
|
||||||
@@ -1011,7 +1013,8 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq)
|
|||||||
break;
|
break;
|
||||||
case SID_BASICIDE_CODECOMPLETITION:
|
case SID_BASICIDE_CODECOMPLETITION:
|
||||||
{
|
{
|
||||||
std::cerr << "code completition enabled" << std::endl;
|
SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), false);
|
||||||
|
CodeCompleteOptions::SetCodeCompleteOn( pItem && pItem->GetValue() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SID_CUT:
|
case SID_CUT:
|
||||||
@@ -1160,6 +1163,21 @@ void ModulWindow::GetState( SfxItemSet &rSet )
|
|||||||
rSet.Put(SfxBoolItem(nWh, bSourceLinesEnabled));
|
rSet.Put(SfxBoolItem(nWh, bSourceLinesEnabled));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SID_BASICIDE_CODECOMPLETITION:
|
||||||
|
{
|
||||||
|
SvtMiscOptions aMiscOptions;
|
||||||
|
if( aMiscOptions.IsExperimentalMode() )
|
||||||
|
{
|
||||||
|
rSet.Put(SfxBoolItem( nWh, CodeCompleteOptions::IsCodeCompleteOn() ));
|
||||||
|
std::cerr <<"code complete set to: " << CodeCompleteOptions::IsCodeCompleteOn() << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rSet.Put( SfxVisibilityItem(nWh, false) );
|
||||||
|
//CodeCompleteOptions::SetCodeCompleteOn( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,6 @@
|
|||||||
#include <vcl/help.hxx>
|
#include <vcl/help.hxx>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <svtools/miscopt.hxx>
|
|
||||||
#include "com/sun/star/reflection/XIdlReflection.hpp"
|
#include "com/sun/star/reflection/XIdlReflection.hpp"
|
||||||
#include <comphelper/namedvaluecollection.hxx>
|
#include <comphelper/namedvaluecollection.hxx>
|
||||||
#include <comphelper/processfactory.hxx>
|
#include <comphelper/processfactory.hxx>
|
||||||
@@ -492,7 +491,6 @@ bool EditorWindow::ImpCanModify()
|
|||||||
|
|
||||||
void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
||||||
{
|
{
|
||||||
SvtMiscOptions aMiscOptions;
|
|
||||||
if ( !pEditView ) // Happens in Win95
|
if ( !pEditView ) // Happens in Win95
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -507,7 +505,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
// see if there is an accelerator to be processed first
|
// see if there is an accelerator to be processed first
|
||||||
bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
|
bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
|
||||||
|
|
||||||
if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && aMiscOptions.IsExperimentalMode() )
|
if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && CodeCompleteOptions::IsCodeCompleteOn() )
|
||||||
{
|
{
|
||||||
rModulWindow.UpdateModule();
|
rModulWindow.UpdateModule();
|
||||||
TextSelection aSel = GetEditView()->GetSelection();
|
TextSelection aSel = GetEditView()->GetSelection();
|
||||||
@@ -835,15 +833,21 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
|
|||||||
{
|
{
|
||||||
ParagraphInsertedDeleted( rTextHint.GetValue(), true );
|
ParagraphInsertedDeleted( rTextHint.GetValue(), true );
|
||||||
DoDelayedSyntaxHighlight( rTextHint.GetValue() );
|
DoDelayedSyntaxHighlight( rTextHint.GetValue() );
|
||||||
|
if( CodeCompleteOptions::IsCodeCompleteOn() )
|
||||||
|
{
|
||||||
rModulWindow.UpdateModule();
|
rModulWindow.UpdateModule();
|
||||||
aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
|
aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED )
|
else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED )
|
||||||
{
|
{
|
||||||
ParagraphInsertedDeleted( rTextHint.GetValue(), false );
|
ParagraphInsertedDeleted( rTextHint.GetValue(), false );
|
||||||
|
if( CodeCompleteOptions::IsCodeCompleteOn() )
|
||||||
|
{
|
||||||
rModulWindow.UpdateModule();
|
rModulWindow.UpdateModule();
|
||||||
aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
|
aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED )
|
else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED )
|
||||||
{
|
{
|
||||||
DoDelayedSyntaxHighlight( rTextHint.GetValue() );
|
DoDelayedSyntaxHighlight( rTextHint.GetValue() );
|
||||||
@@ -856,7 +860,7 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
|
|||||||
pBindings->Invalidate( SID_COPY );
|
pBindings->Invalidate( SID_COPY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( rTextHint.GetId() == TEXT_HINT_MODIFIED )
|
else if( rTextHint.GetId() == TEXT_HINT_MODIFIED && CodeCompleteOptions::IsCodeCompleteOn() )
|
||||||
{
|
{
|
||||||
rModulWindow.UpdateModule();
|
rModulWindow.UpdateModule();
|
||||||
aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
|
aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
|
||||||
|
@@ -19,10 +19,42 @@
|
|||||||
|
|
||||||
#include <basic/codecompletecache.hxx>
|
#include <basic/codecompletecache.hxx>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <rtl/instance.hxx>
|
||||||
|
|
||||||
const OUString CodeCompleteDataCache::GLOB_KEY = OUString("global key");
|
const OUString CodeCompleteDataCache::GLOB_KEY = OUString("global key");
|
||||||
const OUString CodeCompleteDataCache::NOT_FOUND = OUString("not found");
|
const OUString CodeCompleteDataCache::NOT_FOUND = OUString("not found");
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class theCodeCompleteOptions: public ::rtl::Static< CodeCompleteOptions, theCodeCompleteOptions >{};
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeCompleteOptions::CodeCompleteOptions()
|
||||||
|
: bIsCodeCompleteOn( false )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CodeCompleteOptions::IsCodeCompleteOn()
|
||||||
|
{
|
||||||
|
/*if( !theCodeCompleteOptions::get().aMiscOptions.IsExperimentalMode() )
|
||||||
|
return false;
|
||||||
|
else*/
|
||||||
|
return theCodeCompleteOptions::get().aMiscOptions.IsExperimentalMode() && theCodeCompleteOptions::get().bIsCodeCompleteOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CodeCompleteOptions::SetCodeCompleteOn( const bool& b )
|
||||||
|
{
|
||||||
|
if( !theCodeCompleteOptions::get().aMiscOptions.IsExperimentalMode() )
|
||||||
|
theCodeCompleteOptions::get().bIsCodeCompleteOn = false;
|
||||||
|
else
|
||||||
|
theCodeCompleteOptions::get().bIsCodeCompleteOn = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CodeCompleteOptions::IsExtendedTypeDeclaration()
|
||||||
|
{
|
||||||
|
return CodeCompleteOptions::IsCodeCompleteOn();
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache)
|
std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache)
|
||||||
{
|
{
|
||||||
for( CodeCompleteVarScopes::const_iterator aIt = aCache.aVarScopes.begin(); aIt != aCache.aVarScopes.end(); ++aIt )
|
for( CodeCompleteVarScopes::const_iterator aIt = aCache.aVarScopes.begin(); aIt != aCache.aVarScopes.end(); ++aIt )
|
||||||
|
@@ -1783,7 +1783,6 @@ IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/)
|
|||||||
CodeCompleteDataCache SbModule::GetCodeCompleteDataFromParse()
|
CodeCompleteDataCache SbModule::GetCodeCompleteDataFromParse()
|
||||||
{
|
{
|
||||||
CodeCompleteDataCache aCache;
|
CodeCompleteDataCache aCache;
|
||||||
|
|
||||||
ErrorHdlResetter aErrHdl;
|
ErrorHdlResetter aErrHdl;
|
||||||
SbxBase::ResetError();
|
SbxBase::ResetError();
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp"
|
#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp"
|
||||||
#include "com/sun/star/reflection/XIdlMethod.hpp"
|
#include "com/sun/star/reflection/XIdlMethod.hpp"
|
||||||
#include "com/sun/star/uno/Exception.hpp"
|
#include "com/sun/star/uno/Exception.hpp"
|
||||||
|
#include <basic/codecompletecache.hxx>
|
||||||
|
|
||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
using namespace ::com::sun::star::uno;
|
using namespace ::com::sun::star::uno;
|
||||||
@@ -207,7 +208,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
|
|||||||
bool bSwitchPool = false;
|
bool bSwitchPool = false;
|
||||||
bool bPersistantGlobal = false;
|
bool bPersistantGlobal = false;
|
||||||
SbiToken eFirstTok = eCurTok;
|
SbiToken eFirstTok = eCurTok;
|
||||||
SvtMiscOptions aMiscOptions;
|
|
||||||
if( pProc && ( eCurTok == GLOBAL || eCurTok == PUBLIC || eCurTok == PRIVATE ) )
|
if( pProc && ( eCurTok == GLOBAL || eCurTok == PUBLIC || eCurTok == PRIVATE ) )
|
||||||
Error( SbERR_NOT_IN_SUBR, eCurTok );
|
Error( SbERR_NOT_IN_SUBR, eCurTok );
|
||||||
if( eCurTok == PUBLIC || eCurTok == GLOBAL )
|
if( eCurTok == PUBLIC || eCurTok == GLOBAL )
|
||||||
@@ -404,9 +405,18 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
|
|||||||
if( !bCompatible && !pDef->IsNew() )
|
if( !bCompatible && !pDef->IsNew() )
|
||||||
{
|
{
|
||||||
OUString aTypeName( aGblStrings.Find( pDef->GetTypeId() ) );
|
OUString aTypeName( aGblStrings.Find( pDef->GetTypeId() ) );
|
||||||
if( rTypeArray->Find( aTypeName, SbxCLASS_OBJECT ) == NULL && (aMiscOptions.IsExperimentalMode() && !IsUnoInterface(aTypeName)))
|
/*std::cerr <<"CodeCompleteOptions::IsExtendedTypeDeclaration():" << CodeCompleteOptions::IsExtendedTypeDeclaration() << std::endl;
|
||||||
|
std::cerr << "IsUnoInterface("<<aTypeName<<"):"<< IsUnoInterface(aTypeName) << std::endl;
|
||||||
|
std::cerr << "finally: " << (CodeCompleteOptions::IsExtendedTypeDeclaration() && !IsUnoInterface(aTypeName)) << std::endl;*/
|
||||||
|
if( rTypeArray->Find( aTypeName, SbxCLASS_OBJECT ) == NULL )
|
||||||
{
|
{
|
||||||
|
if(!CodeCompleteOptions::IsExtendedTypeDeclaration())
|
||||||
Error( SbERR_UNDEF_TYPE, aTypeName );
|
Error( SbERR_UNDEF_TYPE, aTypeName );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!IsUnoInterface(aTypeName))
|
||||||
|
Error( SbERR_UNDEF_TYPE, aTypeName );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ class SbiParser;
|
|||||||
class SbModule;
|
class SbModule;
|
||||||
#include "opcodes.hxx"
|
#include "opcodes.hxx"
|
||||||
#include "buffer.hxx"
|
#include "buffer.hxx"
|
||||||
|
#include <basic/codecompletecache.hxx>
|
||||||
|
|
||||||
class SbiCodeGen {
|
class SbiCodeGen {
|
||||||
SbiParser* pParser; // for error messages, line, column etc.
|
SbiParser* pParser; // for error messages, line, column etc.
|
||||||
|
@@ -26,12 +26,31 @@
|
|||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
|
#include <svtools/miscopt.hxx>
|
||||||
|
|
||||||
typedef boost::unordered_map< OUString, OUString, OUStringHash > CodeCompleteVarTypes;
|
typedef boost::unordered_map< OUString, OUString, OUStringHash > CodeCompleteVarTypes;
|
||||||
/* variable name, type */
|
/* variable name, type */
|
||||||
typedef boost::unordered_map< OUString, CodeCompleteVarTypes, OUStringHash > CodeCompleteVarScopes;
|
typedef boost::unordered_map< OUString, CodeCompleteVarTypes, OUStringHash > CodeCompleteVarScopes;
|
||||||
/* procedure, CodeCompleteVarTypes */
|
/* procedure, CodeCompleteVarTypes */
|
||||||
|
|
||||||
|
class BASIC_DLLPUBLIC CodeCompleteOptions
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* class to store basic code completition
|
||||||
|
* options
|
||||||
|
* */
|
||||||
|
private:
|
||||||
|
bool bIsCodeCompleteOn;
|
||||||
|
SvtMiscOptions aMiscOptions;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CodeCompleteOptions();
|
||||||
|
|
||||||
|
static bool IsCodeCompleteOn();
|
||||||
|
static void SetCodeCompleteOn( const bool& b );
|
||||||
|
static bool IsExtendedTypeDeclaration();
|
||||||
|
};
|
||||||
|
|
||||||
class BASIC_DLLPUBLIC CodeCompleteDataCache
|
class BASIC_DLLPUBLIC CodeCompleteDataCache
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -48,7 +67,7 @@ public:
|
|||||||
CodeCompleteDataCache(){}
|
CodeCompleteDataCache(){}
|
||||||
virtual ~CodeCompleteDataCache(){}
|
virtual ~CodeCompleteDataCache(){}
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache);
|
friend BASIC_DLLPUBLIC std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache);
|
||||||
|
|
||||||
void SetVars( const CodeCompleteVarScopes& aScopes );
|
void SetVars( const CodeCompleteVarScopes& aScopes );
|
||||||
const CodeCompleteVarScopes& GetVars() const;
|
const CodeCompleteVarScopes& GetVars() const;
|
||||||
|
Reference in New Issue
Block a user