I'm not a desktop programmer, so I have no idea if this is even doable (although I think it is.)
Here is an explanation of my problem:
I use CodeIgniter which follows a Model-View-Controller approach.
A controller is just a Class with different methods that represent pages on website. So a controller might consist of an index() method, add_user() method, edit_user() method, and so on.
In one of those methods, I can call
$this->load->model('UserModel'). UserModel is just another class.
After I load UsersModel, I could access it in my controller like this:
$this->UserModel->add_user().
What I think would be awesome is for PHPEd to provide me some Code Insight when I type in
$this->UserModel->.
Naturally, its not capable of doing so because it isn't aware of CodeIgniter's (or any other framework's) way of loading classes.
What I thought would be cool is if PHPEd had a user-defined hooks file..
This would allow users of about any framework to write a "plugin" so PHPEd can provide Code Insight for it...
Since I don't know squat about whatever language PHPEd was developed in, I'll post what I was thinking in a "mostly" PHP format.
// Example PHP file where code insight is used...
class MyClass
{
var $user = 'Bob';
function method()
{
$this->user //-->There is a classvar $user, so CodeInsight works correctly as you type this.
// Either way of loading a model below is acceptable in CodeIgniter.
$this->load->model('RoleModel');
$this->RoleModel-> //-->There is no classvar $RoleModel, so PHPEd needs to run any registered "noinsight" hooks.
$this->load->model('RoleModel', 'role'); //--> Assigns RoleModel to a classvar named "role"
$this->role-> //-->There is no classvar $role, so PHPEd needs to run any registered "noinsight" hooks.
}
}
/////////////////////////////
// code_insight_hooks.cfg
/////////////////////////////
// My custom array to hold pairs of PseudoClassNames (role) to RealClassNames (RoleModel)
$ci_classmap = array();
// Run this on each individual file the PHPEd scans to get its Code Explorer tree.
function my_treegen_hook($ci_classmap)
{
// Look for calls to $this->load->model() that contain 2 arguments.
// For each call found, append an element to $ci_classmap
$ci_classmap[$argument1] = $argument2; //--> $ci_classmap['RoleModel'] = 'role';
// It is imperative that we return the modified array, because it will be used by my_noinsight_hook.
return $ci_classmap;
}
// Run this if no CodeInsight is found as the user types.
function my_noinsight_hook($my_ci_classmap)
{
// As user types out $this->RoleModel->
// Look for a class in Code Explorer tree named "RoleModel".
// If found, show user CodeInsight of that class and return true.
// If "RoleModel" not found in Code Explorer tree...
// Look for element in $my_ci_classmap whose value (PseudoClassName) == "RoleModel".
// If element exists, get its key (RealClassName), show user CodeInsight of RealClassName, and return true.
// As user types out $this->role->
// Look for a class in Code Explorer tree named "role".
// If found, show user CodeInsight of that class and return true.
// If "role" not found in Code Explorer tree...
// Look for element in $my_ci_classmap whose value (PseudoClassName) == "role".
// If element exists, get its key (RealClassName), show user CodeInsight of RealClassName, and return true.
// Still no CodeInsight to show the user.
return false;
}
/*
Both of the methods below accept multiple arguments.
argument1: Function to call.
argument2+: Variables to pass to function.
*/
PHPEd->add_no_insight_hook('my_noinsight_hook', $my_ci_classmap);
PHPEd->add_treegen_hook('my_treegen_hook', $my_ci_classmap);
|
Hope you understand it.
