Correct code style
parent
5f8e37be9e
commit
b99fb94840
|
@ -148,7 +148,7 @@ class LanguageServer extends \AdvancedJsonRpc\Dispatcher
|
|||
}
|
||||
else {
|
||||
$duration = (int)(microtime(true) - $startTime);
|
||||
$mem = (int)(memory_get_usage(true)/(1024*1024));
|
||||
$mem = (int)(memory_get_usage(true) / (1024 * 1024));
|
||||
$this->client->window->logMessage(3, "All PHP files parsed in $duration seconds. $mem MiB allocated.");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -72,8 +72,7 @@ class PhpDocument
|
|||
$errors = [];
|
||||
try {
|
||||
$stmts = $this->parser->parse($this->content);
|
||||
}
|
||||
catch(\PhpParser\Error $e) {
|
||||
} catch(\PhpParser\Error $e) {
|
||||
// Lexer can throw errors. e.g for unterminated comments
|
||||
// unfortunately we don't get a location back
|
||||
$errors[] = $e;
|
||||
|
|
|
@ -47,7 +47,7 @@ class Project
|
|||
public function getDocument(string $uri)
|
||||
{
|
||||
$uri = urldecode($uri);
|
||||
if (!isset($this->documents[$uri])){
|
||||
if (!isset($this->documents[$uri])) {
|
||||
$this->documents[$uri] = new PhpDocument($uri, $this, $this->client, $this->parser);
|
||||
}
|
||||
return $this->documents[$uri];
|
||||
|
|
|
@ -84,5 +84,4 @@ class TextDocument
|
|||
{
|
||||
return $this->project->getDocument($textDocument->uri)->getFormattedText();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,12 +39,12 @@ class SymbolFinder extends NodeVisitorAbstract
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $nameStack = array();
|
||||
private $nameStack = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $nodeStack = array();
|
||||
private $nodeStack = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
|
@ -58,26 +58,21 @@ class SymbolFinder extends NodeVisitorAbstract
|
|||
|
||||
public function enterNode(Node $node)
|
||||
{
|
||||
array_push($this->nodeStack, $node);
|
||||
$this->nodeStack[] = $node;
|
||||
$containerName = end($this->nameStack);
|
||||
|
||||
// If we enter a named node, push its name onto name stack.
|
||||
// Else push the current name onto stack.
|
||||
if (!empty($node->name) && (is_string($node->name) || method_exists($node->name, '__toString')) && !empty((string)$node->name)) {
|
||||
if (!empty($node->name) && !empty((string)$node->name)) {
|
||||
if (empty($containerName)) {
|
||||
array_push($this->nameStack, (string)$node->name);
|
||||
$this->nameStack[] = (string)$node->name;
|
||||
} else if ($node instanceof Node\Stmt\ClassMethod) {
|
||||
$this->nameStack[] = $containerName . '::' . (string)$node->name;
|
||||
} else {
|
||||
$this->nameStack[] = $containerName . '\\' . (string)$node->name;
|
||||
}
|
||||
else {
|
||||
if ($node instanceof Node\Stmt\ClassMethod) {
|
||||
array_push($this->nameStack, $containerName . '::' . (string)$node->name);
|
||||
}
|
||||
else {
|
||||
array_push($this->nameStack, $containerName . '\\' . (string)$node->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
array_push($this->nameStack, $containerName);
|
||||
} else {
|
||||
$this->nameStack[] = $containerName;
|
||||
}
|
||||
|
||||
$class = get_class($node);
|
||||
|
|
|
@ -13,8 +13,8 @@ function findFilesRecursive(string $path, string $pattern): array {
|
|||
$dir = new \RecursiveDirectoryIterator($path);
|
||||
$ite = new \RecursiveIteratorIterator($dir);
|
||||
$files = new \RegexIterator($ite, $pattern, \RegexIterator::GET_MATCH);
|
||||
$fileList = array();
|
||||
foreach($files as $file) {
|
||||
$fileList = [];
|
||||
foreach ($files as $file) {
|
||||
$fileList = array_merge($fileList, $file);
|
||||
}
|
||||
return $fileList;
|
||||
|
@ -29,5 +29,5 @@ function findFilesRecursive(string $path, string $pattern): array {
|
|||
function pathToUri(string $filepath): string {
|
||||
$filepath = trim(str_replace('\\', '/', $filepath), '/');
|
||||
$filepath = implode('/', array_map('urlencode', explode('/', $filepath)));
|
||||
return 'file:///'.$filepath;
|
||||
return 'file:///' . $filepath;
|
||||
}
|
|
@ -21,8 +21,8 @@ class FileUriTest extends TestCase
|
|||
$uri = \LanguageServer\pathToUri('/usr/local/bin');
|
||||
$this->assertEquals('file:///usr/local/bin', $uri);
|
||||
|
||||
$uri = \LanguageServer\pathToUri('a/b/c/');
|
||||
$this->assertEquals('file:///a/b/c', $uri);
|
||||
$uri = \LanguageServer\pathToUri('a/b/c/test.txt');
|
||||
$this->assertEquals('file:///a/b/c/test.txt', $uri);
|
||||
|
||||
$uri = \LanguageServer\pathToUri('/d/e/f');
|
||||
$this->assertEquals('file:///d/e/f', $uri);
|
||||
|
|
Loading…
Reference in New Issue