diff options
author | Gergo Mocsi <gmocsi91@gmail.com> | 2013-06-21 14:10:31 +0200 |
---|---|---|
committer | Gergo Mocsi <gmocsi91@gmail.com> | 2013-09-02 18:16:42 +0200 |
commit | 025e7ff3e16650097097b6a17cd259170979ef3c (patch) | |
tree | 48dead1451a86797889d73a347048418faceb9a7 /basctl | |
parent | f97d794654cbf80afa0e4a60cda8147e94c11908 (diff) |
GSOC work week 2, getting infromation from variables and print on terminal
This is an early version. I use the BASIC parser to parse the source,
then the infromation is extracted from the symbol table built by parser.
Error reporting is suppressed, beacuse it is not needed fro code completition.
I placed my function inside SbModule, and created a struct called CodeCompletitionData, which holds the object's name, it's parent, and it's type name.
This function, SbMethod::GetCodeCompleteDataFromParse() is called from Basic IDE's Notify function, which updates a cache(actually, reassigns a viariable :) ).
Later, in the EditorWindow::KeyInput function there is a check wheteher dot key is pressed. After that, the actual variable (or word) is being looked up in the vector that holds code completition data. And finally, if it is found, it's methods are printed on the terminal.
Change-Id: Idaf19baa8f720b8b117a76dc3cc2f90dd04fd155
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 2 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 44 |
2 files changed, 45 insertions, 1 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index c02f502e7a58..fb48ae3202d4 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -67,7 +67,6 @@ DBG_NAMEEX( ModulWindow ) OUString getTextEngineText (ExtTextEngine&); void setTextEngineText (ExtTextEngine&, OUString const&); - class EditorWindow : public Window, public SfxListener { private: @@ -109,6 +108,7 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface(sal_Bool bCreate = true); + std::vector< CodeCompleteData > aCodeCompleteCache; protected: virtual void Paint( const Rectangle& ); diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 2347616bdb48..b6ddc4d6dd4d 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -48,6 +48,13 @@ #include <vcl/help.hxx> #include <vector> +#include <svtools/miscopt.hxx> +#include "com/sun/star/reflection/XIdlReflection.hpp" +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/configurationhelper.hxx> +#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp" +#include "com/sun/star/reflection/XIdlMethod.hpp" namespace basctl { @@ -479,6 +486,7 @@ bool EditorWindow::ImpCanModify() void EditorWindow::KeyInput( const KeyEvent& rKEvt ) { + SvtMiscOptions aMiscOptions; if ( !pEditView ) // Happens in Win95 return; @@ -492,7 +500,31 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) bool const bWasModified = pEditEngine->IsModified(); // see if there is an accelerator to be processed first bool bDone = SfxViewShell::Current()->KeyInput( rKEvt ); + if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && aMiscOptions.IsExperimentalMode()) + { + TextSelection aSel = GetEditView()->GetSelection(); + sal_uLong nLine = aSel.GetStart().GetPara(); + OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified + OUString aStr = (aLine.lastIndexOf(" ") == -1 ? aLine.replaceFirst(".","") : aLine.copy(aLine.lastIndexOf(" ")).replaceFirst(".","")); + for( unsigned int j = 0; j < aCodeCompleteCache.size(); ++j) + { + if( aCodeCompleteCache[j].sVarName == aStr ) + { + Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW ); + Reference< reflection::XIdlReflection > xRefl( xFactory->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY_THROW ); + Reference< reflection::XIdlClass > xClass = xRefl->forName(aCodeCompleteCache[j].sVarType); + if( !xRefl.is() ) + break; + Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods(); + for(sal_Int32 i = 0; i < aMethods.getLength(); ++i) + { + SAL_WARN("method information",aMethods[i]->getName()); + } + break; + } + } + } if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) ) { if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() && @@ -752,14 +784,26 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { ParagraphInsertedDeleted( rTextHint.GetValue(), true ); DoDelayedSyntaxHighlight( rTextHint.GetValue() ); + OUString sMod = rModulWindow.GetSbModule()->GetSource(); + OUString sActLine = pEditEngine->GetText( rTextHint.GetValue() ); + std::vector< CodeCompleteData > aData = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(); + aCodeCompleteCache = aData; } else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED ) { ParagraphInsertedDeleted( rTextHint.GetValue(), false ); + OUString sMod = rModulWindow.GetSbModule()->GetSource(); + OUString sActLine = pEditEngine->GetText( rTextHint.GetValue() ); + std::vector< CodeCompleteData > aData = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(); + aCodeCompleteCache = aData; } else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) { DoDelayedSyntaxHighlight( rTextHint.GetValue() ); + OUString sMod = rModulWindow.GetSbModule()->GetSource(); + OUString sActLine = pEditEngine->GetText( rTextHint.GetValue() ); + std::vector< CodeCompleteData > aData = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(); + aCodeCompleteCache = aData; } else if( rTextHint.GetId() == TEXT_HINT_VIEWSELECTIONCHANGED ) { |