Skip to content

Commit

Permalink
fix(formatting): drop PHP CodeSniffer (#504)
Browse files Browse the repository at this point in the history
At this point there are countless issues about the formatting done by CodeSniffer. It plain out doesn't work in many cases, overrides format options that are contributed by other extensions in VS Code and does not reuse any of our AST parsing. For that reason, I am starting to think there is no reason to keep it in here until we have proper pretty-printing support from https://github.com/Microsoft/tolerant-php-parser that actually reuses our ASTs and can work while editing. For people who want to use CodeSniffer to format their code, there could be a standalone CodeSniffer language server (like there is a TSLint language server and ESLint language server). As said, we don't reuse our state anyway.

BREAKING CHANGE: removes formatting support

closes #501
closes #474
closes #473
closes #468
closes #450
closes #445
closes #443
closes #423
closes #343
closes #296
closes #293
closes #499
closes #471
  • Loading branch information
felixfbecker authored Nov 5, 2017
1 parent e9fc97d commit f00fd1b
Show file tree
Hide file tree
Showing 12 changed files with 2 additions and 259 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ For Parameters, it will return the `@param` tag.
The query is matched case-insensitively against the fully qualified name of the symbol.
Non-Standard: An empty query will return _all_ symbols found in the workspace.

### [Document Formatting](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#document-formatting-request)
![Document Formatting demo](images/formatDocument.gif)

### Error reporting through [Publish Diagnostics](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#publishdiagnostics-notification)
![Error reporting demo](images/publishDiagnostics.png)

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"phpdocumentor/reflection-docblock": "^4.0.0",
"sabre/event": "^5.0",
"sabre/uri": "^2.0",
"squizlabs/php_codesniffer": "3.0.0RC3",
"webmozart/glob": "^4.1",
"webmozart/path-util": "^2.3"
},
"require-dev": {
"phpunit/phpunit": "^6.3"
"phpunit/phpunit": "^6.3",
"squizlabs/php_codesniffer": "^3.1"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 0 additions & 20 deletions fixtures/format.php

This file was deleted.

19 changes: 0 additions & 19 deletions fixtures/format_expected.php

This file was deleted.

Binary file removed images/formatDocument.gif
Binary file not shown.
107 changes: 0 additions & 107 deletions src/Formatter.php

This file was deleted.

2 changes: 0 additions & 2 deletions src/LanguageServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,6 @@ public function initialize(ClientCapabilities $capabilities, string $rootPath =
$serverCapabilities->documentSymbolProvider = true;
// Support "Find all symbols in workspace"
$serverCapabilities->workspaceSymbolProvider = true;
// Support "Format Code"
$serverCapabilities->documentFormattingProvider = true;
// Support "Go to definition"
$serverCapabilities->definitionProvider = true;
// Support "Find all references"
Expand Down
13 changes: 0 additions & 13 deletions src/PhpDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,6 @@ public function updateContent(string $content)
$this->sourceFileNode = $treeAnalyzer->getSourceFileNode();
}

/**
* Returns array of TextEdit changes to format this document.
*
* @return \LanguageServer\Protocol\TextEdit[]
*/
public function getFormattedText()
{
if (empty($this->getContent())) {
return [];
}
return Formatter::format($this->getContent(), $this->uri);
}

/**
* Returns this document's text content.
*
Expand Down
14 changes: 0 additions & 14 deletions src/Server/TextDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,6 @@ public function didClose(TextDocumentIdentifier $textDocument)
$this->documentLoader->close($textDocument->uri);
}

/**
* The document formatting request is sent from the server to the client to format a whole document.
*
* @param TextDocumentIdentifier $textDocument The document to format
* @param FormattingOptions $options The format options
* @return Promise <TextEdit[]>
*/
public function formatting(TextDocumentIdentifier $textDocument, FormattingOptions $options)
{
return $this->documentLoader->getOrLoad($textDocument->uri)->then(function (PhpDocument $document) {
return $document->getFormattedText();
});
}

/**
* The references request is sent from the client to the server to resolve project-wide references for the symbol
* denoted by the given text document position.
Expand Down
28 changes: 0 additions & 28 deletions tests/FormatterTest.php

This file was deleted.

1 change: 0 additions & 1 deletion tests/LanguageServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public function testInitialize()
$serverCapabilities->textDocumentSync = TextDocumentSyncKind::FULL;
$serverCapabilities->documentSymbolProvider = true;
$serverCapabilities->workspaceSymbolProvider = true;
$serverCapabilities->documentFormattingProvider = true;
$serverCapabilities->definitionProvider = true;
$serverCapabilities->referencesProvider = true;
$serverCapabilities->hoverProvider = true;
Expand Down
50 changes: 0 additions & 50 deletions tests/Server/TextDocument/FormattingTest.php

This file was deleted.

0 comments on commit f00fd1b

Please sign in to comment.