Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Python Code Completion
MortenMacFly:
--- Quote from: dmoore on October 18, 2012, 10:06:51 pm ---Realize this is a bit of a hack, but it will do the job until we refactor parts of CC to the SDK.
--- End quote ---
No problem - I'll try. What makes me wonder is that this is needed in so many places?! :o
MortenMacFly:
...going through all my email again, I found the patch of the Fortran guy again. NOtice that its indeed better to query filegroups and masks, because of customisation of the file extensions that are rather common in the Fortran world.
--- Code: ---Index: codecompletion.cpp
===================================================================
--- codecompletion.cpp (revision 7604)
+++ codecompletion.cpp (working copy)
@@ -57,6 +57,7 @@
#include "parser/tokenizer.h"
#include "selectincludefile.h"
#include "ccdebuginfo.h"
+#include "filegroupsandmasks.h"
#define CC_CODECOMPLETION_DEBUG_OUTPUT 0
@@ -809,6 +810,12 @@
if (type == mtEditorManager)
{
+ if (cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor())
+ {
+ if (IsFortranFile(ed->GetShortName()))
+ return;
+ }
+
wxString NameUnderCursor;
bool IsInclude = false;
const bool nameUnderCursor = EditorHasNameUnderCursor(NameUnderCursor, IsInclude);
@@ -930,6 +937,21 @@
m_NativeParser.CreateClassBrowser();
+ // determine Fortran Source file group index
+ m_FortranGroupIdx = -1;
+ const FilesGroupsAndMasks* fgam = Manager::Get()->GetProjectManager()->GetFilesGroupsAndMasks();
+ if (fgam)
+ {
+ for (unsigned int i = 0; i < fgam->GetGroupsCount(); i++)
+ {
+ if (fgam->GetGroupName(i).Lower().Contains(_T("fortran")))
+ {
+ m_FortranGroupIdx = i;
+ break;
+ }
+ }
+ }
+
// hook to editors
EditorHooks::HookFunctorBase* myhook = new EditorHooks::HookFunctor<CodeCompletion>(this, &CodeCompletion::EditorEventHook);
m_EditorHookId = EditorHooks::RegisterHook(myhook);
@@ -1505,6 +1527,9 @@
if (!ed)
return;
+ if (IsFortranFile(ed->GetShortName()))
+ return;
+
// calculate the size of the calltips window
int pos = ed->GetControl()->GetCurrentPos();
wxPoint p = ed->GetControl()->PointFromPosition(pos); // relative point
@@ -1745,6 +1770,9 @@
if (!ed)
return;
+ if (IsFortranFile(ed->GetShortName()))
+ return;
+
cbStyledTextCtrl* control = ed->GetControl();
const int pos = control->GetCurrentPos();
const int style = control->GetStyleAt(pos);
@@ -2593,6 +2621,12 @@
return;
}
+ if (IsFortranFile(ed->GetShortName()))
+ {
+ event.Skip();
+ return;
+ }
+
if (ed->GetControl()->CallTipActive())
ed->GetControl()->CallTipCancel();
// CCLogger::Get()->DebugLog(F(_T("CodeCompletion::OnValueTooltip: %p"), ed));
@@ -3174,6 +3208,12 @@
return;
}
+ if (IsFortranFile(editor->GetShortName()))
+ {
+ event.Skip();
+ return;
+ }
+
cbStyledTextCtrl* control = editor->GetControl();
// if (event.GetEventType() == wxEVT_SCI_CHARADDED)
@@ -3493,3 +3533,19 @@
if (m_NativeParser.ReparseFile(project, m_LastFile))
CCLogger::Get()->DebugLog(_T("Reparsing when typing for editor ") + m_LastFile);
}
+
+bool CodeCompletion::IsFortranFile(wxString fileName)
+{
+ bool isFort = false;
+ if (m_FortranGroupIdx != -1)
+ {
+ const FilesGroupsAndMasks* fgam = Manager::Get()->GetProjectManager()->GetFilesGroupsAndMasks();
+ if (fgam)
+ {
+ if ( fileName.Find('.',true) != wxNOT_FOUND &&
+ fgam->MatchesMask(fileName.AfterLast('.').Prepend(_T(".")), m_FortranGroupIdx) )
+ isFort = true;
+ }
+ }
+ return isFort;
+}
Index: codecompletion.h
===================================================================
--- codecompletion.h (revision 7604)
+++ codecompletion.h (working copy)
@@ -235,6 +235,9 @@
/** delayed running of editor activated event, only the last activated editor should be considered*/
void OnEditorActivatedTimer(wxTimerEvent& event);
+ /** determines if file is Fortran file */
+ bool IsFortranFile(wxString fileName);
+
/** Not used*/
int m_PageIndex;
/** Indicates CC's initialization is done*/
@@ -329,6 +332,9 @@
typedef std::map<cbProject*, wxArrayString> ReparsingMap;
ReparsingMap m_ReparsingMap;
+ /** index of Fortran Source file group */
+ int m_FortranGroupIdx;
+
DECLARE_EVENT_TABLE()
};
--- End code ---
oBFusCATed:
This patch looks rather ugly. C++ CC must not care about other file types.
The check should be something like If file is C/C++ process it otherwise do nothing.
MortenMacFly:
--- Quote from: oBFusCATed on October 19, 2012, 09:16:20 am ---The check should be something like If file is C/C++ process it otherwise do nothing.
--- End quote ---
I didn't mean to apply it, I was showing it for reference. In the end in your patch, don't you check for other "filetypes" than C/C+, too? What I meant is not only to trust the editor style - this might be wrong.
oBFusCATed:
--- Quote from: MortenMacFly on October 19, 2012, 10:04:21 am ---What I meant is not only to trust the editor style - this might be wrong.
--- End quote ---
Do we have a function we could trust?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version