tmysik closed pull request #986: [NETBEANS-1507] PHPStan empty inspector Window
URL: https://github.com/apache/incubator-netbeans/pull/986
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/parsers/PHPStanReportParser.java
b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/parsers/PHPStanReportParser.java
index cf2741c826..8a2937d2ff 100644
---
a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/parsers/PHPStanReportParser.java
+++
b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/parsers/PHPStanReportParser.java
@@ -141,7 +141,9 @@ private void processFileEnd() {
private void processResultStart(Attributes attributes) {
assert currentFile != null;
assert currentResult == null : currentResult.getFilePath();
-
+ if (currentFile == null) {
+ return;
+ }
currentResult = new Result(currentFile);
int lineNumber = getInt(attributes, "line"); // NOI18N
// line number can be 0
@@ -173,12 +175,18 @@ private int getInt(Attributes attributes, String name) {
return i;
}
+ @CheckForNull
private String getCurrentFile(String fileName) {
- FileObject parent = root.getParent();
String sanitizedFileName = sanitizeFileName(fileName);
- if (parent.isFolder()) {
- FileObject current = parent.getFileObject(sanitizedFileName);
+ FileObject rootDirectory = root;
+ if (!root.isFolder()) {
+ rootDirectory = root.getParent();
+ }
+ if (rootDirectory.isFolder()) {
+ FileObject current =
rootDirectory.getFileObject(sanitizedFileName);
if (current == null) {
+ LOGGER.log(Level.WARNING, "Cannot get the current file: file
name {0}, root directory {1}", // NOI18N
+ new Object[]{fileName,
FileUtil.toFile(rootDirectory).getAbsolutePath()});
return null;
}
return FileUtil.toFile(current).getAbsolutePath();
diff --git
a/php/php.code.analysis/test/unit/data/phpstan/phpstan-log-with-other-output.xml
b/php/php.code.analysis/test/unit/data/phpstan/phpstan-log-with-other-output.xml
index b5a4c8858f..b8acdea065 100644
---
a/php/php.code.analysis/test/unit/data/phpstan/phpstan-log-with-other-output.xml
+++
b/php/php.code.analysis/test/unit/data/phpstan/phpstan-log-with-other-output.xml
@@ -1,7 +1,7 @@
Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements; and to You under the Apache License, Version 2.0.
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle>
-<file name="PHPStanSupport/HelloWorld.php">
+<file name="HelloWorld.php">
<error line="5" column="1" severity="error" message="Parameter $date of
method HelloWorld::sayHello() has invalid typehint type DateTimeImutable." />
<error line="7" column="1" severity="error" message="Call to method format()
on an unknown class DateTimeImutable." />
</file>
diff --git a/php/php.code.analysis/test/unit/data/phpstan/phpstan-log.xml
b/php/php.code.analysis/test/unit/data/phpstan/phpstan-log.xml
index 3f26206988..3dd1b61683 100644
--- a/php/php.code.analysis/test/unit/data/phpstan/phpstan-log.xml
+++ b/php/php.code.analysis/test/unit/data/phpstan/phpstan-log.xml
@@ -20,14 +20,14 @@
-->
<checkstyle>
-<file name="PHPStanSupport/HelloWorld.php">
+<file name="HelloWorld.php">
<error line="5" column="1" severity="error" message="Parameter $date of
method HelloWorld::sayHello() has invalid typehint type DateTimeImutable." />
<error line="7" column="1" severity="error" message="Call to method format()
on an unknown class DateTimeImutable." />
</file>
-<file
name="PHPStanSupport/vendor/nette/php-generator/src/PhpGenerator/Traits/CommentAware.php
(in context of class Nette\PhpGenerator\ClassType)">
+<file
name="vendor/nette/php-generator/src/PhpGenerator/Traits/CommentAware.php (in
context of class Nette\PhpGenerator\ClassType)">
<error line="28" column="1" severity="error" message="Casting to string
something that's already string." />
</file>
-<file
name="PHPStanSupport/vendor/nikic/php-parser/test/PhpParser/Builder/ClassTest.php">
+<file name="vendor/nikic/php-parser/test/PhpParser/Builder/ClassTest.php">
<error line="0" column="1" severity="error" message="Class
PhpParser\Builder\ClassTest was not found while trying to analyse it -
autoloading is probably not configured properly." />
</file>
</checkstyle>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists