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 #272 from HvyIndustries/feature/improve-suggestion…
Browse files Browse the repository at this point in the history
…s-performance

v0.3.4 - Improve suggestions performance
  • Loading branch information
nevadascout authored Mar 20, 2017
2 parents 5d16537 + 8796744 commit bed620d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 45 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ You can also set `php.suggest.basic` to `false` to disable VS Code's built-in ph

---

## What's new in v0.3.3 (latest release)
## What's new in v0.3.4 (latest release)
- Significant performance improvements when requesting suggestions *(up to 7,500% faster)*

## What's new in v0.3.3
- Document symbol provider - view top level symbols in the current file
- Workspace symbol provider - view top level symbols throughout the workspace
- Performance improvements
Expand Down
5 changes: 4 additions & 1 deletion client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# v0.3.3 (latest release)
# v0.3.4 (latest release)
- Significant performance improvements when requesting suggestions *(up to 7,500% faster)*

# v0.3.3
- Document symbol provider - view top level symbols in the current file
- Workspace symbol provider - view top level symbols throughout the workspace
- Performance improvements
Expand Down
5 changes: 4 additions & 1 deletion client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ You can also set `php.suggest.basic` to `false` to disable VS Code's built-in ph

---

## What's new in v0.3.3 (latest release)
## What's new in v0.3.4 (latest release)
- Significant performance improvements when requesting suggestions *(up to 7,500% faster)*

## What's new in v0.3.3
- Document symbol provider - view top level symbols in the current file
- Workspace symbol provider - view top level symbols throughout the workspace
- Performance improvements
Expand Down
2 changes: 1 addition & 1 deletion 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.3",
"version": "0.3.4",
"publisher": "HvyIndustries",
"engines": {
"vscode": "^1.8.0"
Expand Down
1 change: 1 addition & 0 deletions client/phpTest/demo/baseInclude.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

$dbh = new ConnectionDB();
$dbh->openDbConnection();

2 changes: 1 addition & 1 deletion 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.3",
"version": "1.1.4",
"author": "HVY Industries",
"license": "MIT",
"engines": {
Expand Down
30 changes: 8 additions & 22 deletions server/src/suggestionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,14 @@ export class SuggestionBuilder

// Remove duplicated (overwritten) items
var filtered = [];
var cache = {};

for (var i = 0, l = toReturn.length; i < l; i++) {
var item = toReturn[i];

var found = false;

for (var j = 0, sl = filtered.length; j < sl; j++) {
var subItem = filtered[j];

if (subItem.label == item.label) {
found = true;
}
}

if (!found) {
if (!(item.label in cache)) {
filtered.push(item);
cache[item.label] = true;
}
}

Expand Down Expand Up @@ -996,20 +988,14 @@ export class SuggestionBuilder

// Remove duplicated (overwritten) items
var filtered = [];
for (var i = 0, l:number = toReturn.length; i < l; i++) {
let item = toReturn[i];
var cache = {};

var found = false;
for (var j = 0, sl:number = filtered.length; j < sl; j++) {
let subItem = filtered[j];

if (subItem.label == item.label) {
found = true;
}
}
for (var i = 0, l = toReturn.length; i < l; i++) {
var item = toReturn[i];

if (!found) {
if (!(item.label in cache)) {
filtered.push(item);
cache[item.label] = true;
}
}

Expand Down
33 changes: 15 additions & 18 deletions server/src/util/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,36 @@ export class Files
{
public static getPathFromUri(uri: string) : string
{
var path = uri;
path = path.replace("file:///", "");
path = path.replace("%3A", ":");
uri = uri.replace("file:///", "");

var decoded = decodeURIComponent(uri);

// Handle Windows and Unix paths
switch (process.platform) {
case 'darwin':
case 'linux':
path = "/" + path;
break;
return "/" + decoded;

case 'win32':
path = path.replace(/\//g, "\\");
break;
decoded = decoded.replace(/\//g, "\\");
return decoded;
}

return path;
}

public static getUriFromPath(path: string) : string
{
path = path.replace(":", "%3A");
let pathStart = "file://";

// Handle Windows paths with backslashes
switch (process.platform) {
case 'win32':
path = path.replace(/\\/g, "\/");
pathStart = "file:///";
break;
if (process.platform == "win32") {
path = path.replace(/\\/g, "\/");
pathStart = "file:///";
}

path = pathStart + path;
let encoded = encodeURI(path);

// Handle colons specially as encodeURI does not encode them
encoded = encoded.replace(":", "%3A");

return path;
return pathStart + encoded;
}
}

0 comments on commit bed620d

Please sign in to comment.