summaryrefslogtreecommitdiff
path: root/basctl/source/basicide/baside2b.cxx
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-06-21 14:10:31 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-06-21 14:10:31 +0200
commit035be6eb0de0b02796ee73940817278f5007e112 (patch)
tree1de5a9cb21e183bc6efc3f3dae39afcfcf9bcd52 /basctl/source/basicide/baside2b.cxx
parent809edacfabfbb5b6cc0bac335aa8f62367948b4b (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/source/basicide/baside2b.cxx')
-rw-r--r--basctl/source/basicide/baside2b.cxx53
1 files changed, 53 insertions, 0 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 7b7e3c7396dd..afde04026ee0 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
{
@@ -424,7 +431,11 @@ void EditorWindow::MouseButtonUp( const MouseEvent &rEvt )
{
pEditView->MouseButtonUp( rEvt );
if (SfxBindings* pBindings = GetBindingsPtr())
+ {
+ pBindings->Invalidate( SID_COPY );
+ pBindings->Invalidate( SID_CUT );
pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+ }
}
}
@@ -469,6 +480,7 @@ bool EditorWindow::ImpCanModify()
void EditorWindow::KeyInput( const KeyEvent& rKEvt )
{
+ SvtMiscOptions aMiscOptions;
if ( !pEditView ) // Happens in Win95
return;
@@ -482,7 +494,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() &&
@@ -511,15 +547,20 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
{
if (SfxBindings* pBindings = GetBindingsPtr())
{
+ pBindings->Invalidate( SID_CUT );
+ pBindings->Invalidate( SID_COPY );
pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+
if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR )
pBindings->Update( SID_BASICIDE_STAT_POS );
+
if ( !bWasModified && pEditEngine->IsModified() )
{
pBindings->Invalidate( SID_SAVEDOC );
pBindings->Invalidate( SID_DOC_MODIFIED );
pBindings->Invalidate( SID_UNDO );
}
+
if ( rKEvt.GetKeyCode().GetCode() == KEY_INSERT )
pBindings->Invalidate( SID_ATTR_INSERT );
}
@@ -737,14 +778,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 )
{