hvyindustries / crane Goto Github PK
View Code? Open in Web Editor NEWPHP Intellisense/code-completion for VS Code
Home Page: https://hvy.io/crane
License: Other
PHP Intellisense/code-completion for VS Code
Home Page: https://hvy.io/crane
License: Other
The delayer that kicks off object tree construction is often not fired if you're typing quickly (intentionally).
To counter this, when typing a ;
or }
we should rebuild the object tree for the document, as it's likely that the syntax will be valid.
Also try to build the tree on file save
Deploy v0.1.4 of the extension to the VS Code marketplace.
Like the title, when I type PDO it can't find any references to it.
Hey guys, when using $this, the Intellisence not geting the private variables of the class
Currently the parser throws an exception if it encounters a parser error in the file meaning no AST is returned.
This should be changed so that any AST generated up to the point of the parse error should be returned anyway.
Enable debug mode in user/workspace settings and log everything out to a file.
If you delete a PHP file after it has been parsed, then the suggestions created from that file remain.
We need to watch the workspace and when a file is deleted, remove it from the tree.
The readme is now fairly outdated as several new features and bug fixes have been made since it was originally written.
My suggestion is to generate a simple hash of the workspace directory and use that as the folder name in %APPDATA%
on windows and ~/.crane
on OSX/Linux. For example:
Workspace folder: C:/users/ns/projects/myproject/
Generated hash of the folder string: uef5vbrtfeo8
Cache folder system:
%APPDATA%
\ crane
\ uef5vbrtfeo8
\ tree.cache
\ nyf9psbtd9rg
\ tree.cache
Each workspace that has something to store in the cache gets a separate folder inside the crane directory to store the cache files in.
This prevents needing to update the gitignore and keeps the workspace folder clean. This is especially important because some git tools update diffs whenever any file in a workspace changes, and if we're constantly modifying cache files then this could cause an issue.
Let's add a new command (Rebuild Sources) -- both a command from the palette and a keyboard shortcut Ctrl + Shift + R (?)
I also think this should be enabled by default. Using a folder other than the project workspace to store the cache files makes this less of an issue.
Global variables imported inside a function with global
should be suggested.
When importing a class with composer, it would be nice to have intellisense suggestions for those classes.
We need a way that users can define an "interface" for a class with its properties and methods -- and their access modifier.
As of #35, PDO should be the first custom type definition.
Blocked by #1 (class instance variables have no suggestions)
When pressing F12 on a symbol, the editor should navigate to it's definition.
Build a symbol cache from the treebuilder with the symbol and it's filepath, line and character number for quick access.
Triggered by
Need to ensure that class inheritance/structure is followed
This offers suggestions:
$this->
But this does not:
if ($this->
Somewhere in the treeBuilder This is getting thrown:
[TypeError: Cannot read property '0' of null]
VS Code specific feature - when typing @
in the command palette, we should show a list of symbols available (classes, traits, methods, etc) in the current document
The phpTest
folder is being bundled and packaged with the extension when it goes onto the store.
This folder should really be removed
When typing, after a short pause (250ms) it should built intellisense suggestions.
This seems to not be firing properly
VS Code does have limited support for PHP code completion - namely variables that you've defined in a file.
This has been broken for a while now, but I believe the March update for VS Code will fix this and it'll start showing duplicate top level variable suggestions.
When typing include
or require
we should offer folder and filename suggestions.
For example, typing
require "E
Should suggest ExampleClass.php
and ExampleFolder/
(assuming they are in the same folder as the file we're editing)
If I delete a php file containing a class, that class will still show up in suggestions.
We need to watch the workspace folder for php file changes and rebuild the suggestions list for any changed files.
Include:
I just installed this extension, and ever since my editor has stopped responding. Nothing in particular is causing this, but it is after it "Processes the files" it happens.
Here are the cases that I have had when this happens:
$
and it lockedIndenting code with tabs instead of spaces causes the suggestion engine to not match words correctly.
This is because the tab character \t
is included in the token and causes a mismatch on the comparison.
Need to investigate if a php file with html in it still offers code suggestions.
As a side note to this, we should show suggestions in .phtml
, .phps
and any other valid php files.
bug hello , lower the extension and makes the visual studio code freezes and restarts all the time .. I was interested in trying it but in the end for those problems and everything worked uninstall normal again. Should check that mistake because it is very annoying and frustrating when programming in php
The code is doing a strange validation to get a string to see if it is part of the current class. Workbench has a built in function to get the current word where the cursor is, this could make the code cleaner with smaller if statements. Where this:
if (expression.lastIndexOf("$this", 0) === 0 ||
expression.lastIndexOf("($this", 0) === 0 ||
expression.lastIndexOf("if($this", 0) === 0 ||
expression.lastIndexOf("elseif($this", 0) === 0 ||
expression.lastIndexOf("!$this", 0) === 0)
{
would become this:
if(expression == '$this'){
Testing with the latest version of CodeIgniter, there are no class level suggestions due to the following code in the controller constructor:
class CI_Controller
{
private static $instance;
public function __construct()
{
self::$instance =& $this;
// Assign all the class objects that were instantiated by the
// bootstrap file (CodeIgniter.php) to local class variables
// so that CI can run as one big super object.
foreach (is_loaded() as $var => $class)
{
$this->$var =& load_class($class);
}
$this->load =& load_class('Loader', 'core');
$this->load->initialize();
log_message('info', 'Controller Class Initialized');
}
}
Typing self::
or ClassName::
should offer static methods, properties and consts as completion items
self::
should also suggest static global variables
With the change in #29 (build suggestions even if there are parse errors), suggestion generation is a lot more reliable.
However, it is still not as reliable as it could be. If there is a parse error on line 4, but a variable is defined on line 5, then trying to load suggestions on line 6 will not show the variable from line 5.
This could be solved, by ignoring any lines that have parse errors on them. This would allow building suggestions for the entire file regardless of how many errors there are.
This may introduce some unexpected behaviour, so care should be taken when implementing this feature.
For large projects, the performance of Crane can be pretty shocking.
We need to review the extension and improve the performance as much as possible.
delay until 0.2
delay until 0.2
http://stackoverflow.com/a/30087518/492298
https://hacks.mozilla.org/2012/11/tracking-down-memory-leaks-in-node-js-a-node-js-holiday-season/
https://strongloop.com/node-js/node-js-performance-tips/
When hovering over a symbol, variable or member, we should display information about it.
As much info as possible should be taken from phpdoc comments
Requires #12
$this
// Whether php validation is enabled or not.
"php.validate.enable": true,
// Points to the php executable.
"php.validate.executablePath":"D:/wamp/bin/php/php5.5.12/php.exe",
// Whether the linter is run on save or on type.
"php.validate.run": "onType"
i set the value,but it still doesn't work.
why?
Currently, we cannot build intellisense suggestions if there is a syntax error in the file being worked on, making suggestions very unreliable at the point.
This is a major problem; we should be able to ignore the error and build up as many suggestions as possible.
This will enable:
$this->
without calling a method or property is deemed a synax error)We should be able to Refactor/Rename a symbol by right clicking or pressing F2 on a symbol. It should then allow us to replace all the related symbols in the project (based on scope).
Note: this is closely linked to / depends on #6
When declaring a variable like $instance = new MyClass()
we should offer completion suggestions when typing $instance->
$instance = new MyClass()
)function(MyClass $class) { }
)function something() : MyClass { }
)$this->prop = new MyClass()
) moved to
#68(new MyClass)->myProperty()
) moved to
#68Branch: feature/signatureHelp
First pass merged in #67
Hello,
I would love to see the ability to import use
statements for classes or functions in other namespaces. Ideally, after typing the name of a class, you would hit a hotkey and it would grab the fully-qualified class name and alphabetically add it at the top of the file.
PHPDoc comments on methods, properties, etc should be displayed in the intellisense as extra information.
This feature depends on php-parser adding support for comments.
Type hinting should be included:
/**
* @var string
*/
$test = "test";
Update the treebuilder to store the last doc comment that we find, and then if symbol definition, check the doc comment is the line above the symbol and apply information as required.
@var
@param
@return
@throws
@deprecated
This first pass will enable code completion to use the phpdoc comment typings, but only on top level variables.
Eg.
/** @var SomeClass */
$test = $otherObject;
$test->
// ^ works here
$test->prop->
// ^ won't work here yet
anyway~~thanks 4 ur effort.hope this extension can be better and better
Implement a custom method to add items to the completion list that checks if the item exists already to prevent duplicate entries.
Hello,
Currently running on Ubuntu 14.04 , with keyboard layout set on "Français" ( French AZERTY ).
Whenever I press the dollar-symbol $
key, it's a semicolon ;
which appear instead.
It's the only key that cause trouble. Moreover this bug only occur on PHP files, I can properly type the dollar $
anywhere else.
Crane should show the parameters defined for a function when calling it
$this->
self::
[classname]::
static::
Testing with the latest version of CodeIgniter (3.0.6), I've discovered that there are duplicate variable suggestions, which are also being flagged as parameters even though they are not available in scope.
(This is unrelated to #10)
Might be annoying to have it there, should offer a config option to hide it.
Hello again,
I was trying to play a little with your newest version, so I forked the repo and tried it. VSCode gave me an error on all lines import {...} from 'vscode';
, and refused to run for debugging.
I figured out that your version requirement of the vscode engine is a little too high (0.11.x doesn't exist yet), so the vscode module doesn't download the vscode typings definition.
Going back to 0.10.x and redo a npm install vscode
fixed the problem, and I was able to run the extension with my modifications.
Hope this helps,
Cheers
The parser might fall over if a file contains a namespace... Need to double check this
We should be able to find all references of a symbol in the workspace.
For example, everywhere that we're referencing a certain property on a class
I installed this extension to VS CODE, then it started to freeze. And I have to restart VS code every time.
I have this issue with combination of VS 1.1.0 an this extension. It worked perfectly on previous build. Without the extension I don't have any freezing problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.