Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #258 from HvyIndustries/feature/ast-based-suggesti…
Browse files Browse the repository at this point in the history
…on-builder

v0.3.2
  • Loading branch information
nevadascout authored Mar 11, 2017
2 parents b59e43c + ecd7d24 commit cc9dc9b
Show file tree
Hide file tree
Showing 15 changed files with 518 additions and 101 deletions.
45 changes: 25 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,22 @@ For the best development experience, make sure you have the PHP linter enabled i

You can also set `php.suggest.basic` to `false` to disable VS Code's built-in php code completion and avoid duplicate suggestions.

## Demo

![](https://i.imgur.com/a9j3V9u.gif)

---

## What's new in v0.3.1 (latest release)
## What's new in v0.3.2 (latest release)
- **Added go to definition on classes, traits & interfaces**
- Fix several bugs introduced in v0.3.1
- Namespace insert text should be prefixed with a backslash _(Thanks @TheColorRed for pointing out this mistake!)_
- Crane no longer adds the fully qualified namespace to a class if the class is in the same namespace
- Fixed issue where there were no suggestions for properties and methods defined in traits
- Disabled Crane suggestions when typing on a single line comment
- Bug report link now prefills basic information including vscode version, crane version and platform (win/linux/macos)

## What's new in v0.3.1

- **Improved namespace support**
- Crane will now suggest scope-aware namespace parts in `namespace` and `use` statements
Expand All @@ -38,28 +51,24 @@ You can also set `php.suggest.basic` to `false` to disable VS Code's built-in ph
- Removed the Crane version indicator from the bottom right of the status bar
- Fixed a bug where the indexing statusbar item would be hidden if you disabled the bug report link

## What's new in v0.2.2

- Added new setting `crane.ignoredPaths` that gives users the ability to ignore files/folders for parsing _(workaround for parser crashing issue)_
- Added "what's new" section to readme to highlight new features/bug fixes

---

## Current Features

- Code-completion _(in progress, not quite 100% complete yet)_
- Code-completion _(work in progress)_
- For user created code
- Optionally for built-in PHP functions and classes (such as PDO)
- **Go to definition** on classes, interfaces and traits
- Peek definition on classes, interfaces and traits

## Planned Features:

* **Go to definition** (pressing F12)
* **Find references**
* Signature provider to show method parameter suggestions
* Hover provider to show information about symbol under the cursor
* Peek definition
* List symbols
* PhpDoc support (both for reading and writing documentation)
- Find references
- Signature provider to show method parameter suggestions
- Hover provider to show information about symbol under the cursor
- Full go-to/Peek definition on variables, methods, properties, etc
- List symbols
- PhpDoc support (both for reading and writing documentation)

## User Feedback

Expand All @@ -81,16 +90,12 @@ You can also set `php.suggest.basic` to `false` to disable VS Code's built-in ph
> 👌👌👌 super awesome.
> [яєαℓιѕт נανѕтαн](https://twitter.com/RHJOfficial/status/719630044310740992)
## Demo

![](http://i.imgur.com/7128zNV.png)
![](http://i.imgur.com/CT2S3yX.gif)

## Known Issues

* There may be duplicate suggestions for functions or variables. This is because VS Code has it's own (very limited) code-completion support for PHP, and there is currently no way to turn this off.
* If you get duplicate suggestions for variables, etc. you can disable VS Code's built-in php code-completion by setting `php.suggest.basic` to `false` in your settings.
* There can be strange behaviour when working with PHP and HTML in the same file.
* If you have a syntax error in a file, you may not get a full list of suggestions for that file.
* Go to definition only works on classes, traits and interfaces

## Links

Expand Down
11 changes: 10 additions & 1 deletion client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# v0.3.1 (latest release)
# v0.3.2 (latest release)
- **Added go to definition on classes, traits & interfaces**
- Fix several bugs introduced in v0.3.1
- Namespace insert text should be prefixed with a backslash _(Thanks @TheColorRed for pointing out this mistake!)_
- Crane no longer adds the fully qualified namespace to a class if the class is in the same namespace
- Fixed issue where there were no suggestions for properties and methods defined in traits
- Disabled Crane suggestions when typing on a single line comment
- Bug report link now prefills basic information including vscode version, crane version and platform (win/linux/macos)

# v0.3.1
- **Improved namespace support**
- Crane will now suggest scope-aware namespace parts in `namespace` and `use` statements
- Crane will now suggest classes that have been aliased in `use` statements
Expand Down
45 changes: 25 additions & 20 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,22 @@ For the best development experience, make sure you have the PHP linter enabled i

You can also set `php.suggest.basic` to `false` to disable VS Code's built-in php code completion and avoid duplicate suggestions.

## Demo

![](https://i.imgur.com/a9j3V9u.gif)

---

## What's new in v0.3.1 (latest release)
## What's new in v0.3.2 (latest release)
- **Added go to definition on classes, traits & interfaces**
- Fix several bugs introduced in v0.3.1
- Namespace insert text should be prefixed with a backslash _(Thanks @TheColorRed for pointing out this mistake!)_
- Crane no longer adds the fully qualified namespace to a class if the class is in the same namespace
- Fixed issue where there were no suggestions for properties and methods defined in traits
- Disabled Crane suggestions when typing on a single line comment
- Bug report link now prefills basic information including vscode version, crane version and platform (win/linux/macos)

## What's new in v0.3.1

- **Improved namespace support**
- Crane will now suggest scope-aware namespace parts in `namespace` and `use` statements
Expand All @@ -38,28 +51,24 @@ You can also set `php.suggest.basic` to `false` to disable VS Code's built-in ph
- Removed the Crane version indicator from the bottom right of the status bar
- Fixed a bug where the indexing statusbar item would be hidden if you disabled the bug report link

## What's new in v0.2.2

- Added new setting `crane.ignoredPaths` that gives users the ability to ignore files/folders for parsing _(workaround for parser crashing issue)_
- Added "what's new" section to readme to highlight new features/bug fixes

---

## Current Features

- Code-completion _(in progress, not quite 100% complete yet)_
- Code-completion _(work in progress)_
- For user created code
- Optionally for built-in PHP functions and classes (such as PDO)
- **Go to definition** on classes, interfaces and traits
- Peek definition on classes, interfaces and traits

## Planned Features:

* **Go to definition** (pressing F12)
* **Find references**
* Signature provider to show method parameter suggestions
* Hover provider to show information about symbol under the cursor
* Peek definition
* List symbols
* PhpDoc support (both for reading and writing documentation)
- Find references
- Signature provider to show method parameter suggestions
- Hover provider to show information about symbol under the cursor
- Full go-to/Peek definition on variables, methods, properties, etc
- List symbols
- PhpDoc support (both for reading and writing documentation)

## User Feedback

Expand All @@ -81,16 +90,12 @@ You can also set `php.suggest.basic` to `false` to disable VS Code's built-in ph
> 👌👌👌 super awesome.
> [яєαℓιѕт נανѕтαн](https://twitter.com/RHJOfficial/status/719630044310740992)
## Demo

![](http://i.imgur.com/7128zNV.png)
![](http://i.imgur.com/CT2S3yX.gif)

## Known Issues

* There may be duplicate suggestions for functions or variables. This is because VS Code has it's own (very limited) code-completion support for PHP, and there is currently no way to turn this off.
* If you get duplicate suggestions for variables, etc. you can disable VS Code's built-in php code-completion by setting `php.suggest.basic` to `false` in your settings.
* There can be strange behaviour when working with PHP and HTML in the same file.
* If you have a syntax error in a file, you may not get a full list of suggestions for that file.
* Go to definition only works on classes, traits and interfaces

## Links

Expand Down
10 changes: 7 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"icon": "images/php-256.png",
"license": "MIT",
"version": "0.3.1",
"version": "0.3.2",
"publisher": "HvyIndustries",
"engines": {
"vscode": "^1.8.0"
Expand All @@ -34,7 +34,10 @@
"hvy",
"productivity",
"code-completion",
"intellisense"
"intellisense",
"go-to-definition",
"definition",
"suggestion"
],
"galleryBanner": {
"theme": "dark",
Expand Down Expand Up @@ -126,9 +129,10 @@
"dependencies": {
"fstream": "^1.0.9",
"mkdirp": "^0.5.1",
"php-parser": "^2.0.1",
"php-parser": "^2.0.2",
"rimraf": "^2.5.2",
"unzip": "^0.1.11",
"opn": "^4.0.2",
"vscode-languageclient": "^3.1.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);

namespace Hvy\CraneDemo;

class ConnectionDB
{

private $dbhost = "localhost";
private $dbuser = "user";
private $dbpass = "pass";
private $dbname = "dbname";

/** @var PDO */
public $conn;

public function openDbConnection()
{
try
{
$this->dbhost;
$this->dbhost = "127.0.0.1";
$this->conn = new PDO("mysql:host=$this->dbhost;dbname=$this->dbname;", $this->dbuser, $this->dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"));
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
Expand All @@ -37,4 +37,4 @@ public function closeDbConnection()
echo $e->getMessage();
}
}
}
}
6 changes: 6 additions & 0 deletions client/phpTest/demo/baseInclude.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

use Hvy\CraneDemo\ConnectionDB;

$dbh = new ConnectionDB();
$dbh->openDbConnection();
65 changes: 45 additions & 20 deletions client/src/crane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@
import {
Disposable, workspace, window, TextDocument,
TextEditor, StatusBarAlignment, StatusBarItem,
FileSystemWatcher
FileSystemWatcher, version as vsCodeVersion
} from 'vscode';
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
import { ThrottledDelayer } from './utils/async';
import { Cranefs } from './utils/Cranefs';
import { Debug } from './utils/Debug';
import { Config } from './utils/Config';

const exec = require('child_process').exec;
const opn = require('opn');
const util = require('util');

let craneSettings = workspace.getConfiguration("crane");
const cranefs: Cranefs = new Cranefs();

console.log(process.platform)

export default class Crane
{
public static langClient: LanguageClient;
Expand Down Expand Up @@ -183,25 +181,52 @@ export default class Crane
}

public reportBug() {
Crane.openLinkInBrowser("https://github.com/HvyIndustries/crane/issues");
let message = '';
message = 'Platform : ' + process.platform + '\n';
message += 'VSCode Version : ' + vsCodeVersion + '\n';
message += 'Crane Version : ' + Config.version + '\n';
message += '---\n\n';
message += '_Please explain here what you intended to do, the expected behaviour, and the observed results or errors._\n\n';
message += '_In order to help us to fix it, try to explain how to reproduce the error, and give us code samples that can help us to reproduce the same behaviour_';
Crane.openLinkInBrowser(
"https://github.com/HvyIndustries/crane/issues/new", {
body: message
}
);
}

public static openLinkInBrowser(link: string) {
var openCommand: string = "";

switch (process.platform) {
case 'darwin':
case 'linux':
openCommand = 'open ';
break;
case 'win32':
openCommand = 'start ';
break;
default:
return;
/**
* Opens the specified URL and appends the specified object (if defined)
* as query string parameters
*/
public static openLinkInBrowser(link: string, args?: any, hash?: string): Thenable<void> {
let qs = [];
if (args) {
// check arguments
for(let name in args) {
if (args.hasOwnProperty(name)) {
qs.push(
name + '=' + encodeURIComponent(args[name])
);
}
}
}

exec(openCommand + link);
// append the query string if defined
if (qs.length > 0) {
if (link.indexOf('?') > -1) {
link += '&' + qs.join('&');
} else {
link += '?' + qs.join('&');
}
}
// appends the hash directive
if (hash) {
if (hash[0] != '#') {
hash = '#' + hash;
}
link += hash;
}
return opn(link);
}

public handleFileSave() {
Expand Down
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "crane-lang-server",
"description": "The language server for Crane",
"version": "1.1.1",
"version": "1.1.2",
"author": "HVY Industries",
"license": "MIT",
"engines": {
Expand All @@ -14,7 +14,7 @@
"dependencies": {
"filequeue": "^0.5.0",
"glob": "7.0.3",
"php-parser": "^2.0.1",
"php-parser": "^2.0.2",
"vscode-languageserver": "^3.1.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion server/src/hvy/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// - handle autoloaded files


class BaseNode
export class BaseNode
{
constructor(name = "") {
this.name = name;
Expand Down
Loading

0 comments on commit cc9dc9b

Please sign in to comment.