Skip to content

Commit 1bad4a7

Browse files
committed
Merge branch 'nb81'
2 parents c6acaf5 + c71ed85 commit 1bad4a7

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ https://github.com/FriendsOfPHP/PHP-CS-Fixer
1515
## Settings
1616

1717
### Global
18-
`Tools > Options > PHP > PHP CS Fixer`
18+
`Tools > Options > PHP > Framework & Tools > PHP CS Fixer`
1919
- set PHP CS Fixer path
2020
- set fix command options
2121

manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Manifest-Version: 1.0
22
OpenIDE-Module: org.netbeans.modules.php.phpcsfixer
33
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/phpcsfixer/Bundle.properties
4-
OpenIDE-Module-Specification-Version: 0.5.2
4+
OpenIDE-Module-Specification-Version: 0.5.3

nbproject/project.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@
8686
<specification-version>1.65.1.8</specification-version>
8787
</run-dependency>
8888
</dependency>
89+
<dependency>
90+
<code-name-base>org.netbeans.modules.projectuiapi.base</code-name-base>
91+
<build-prerequisite/>
92+
<compile-dependency/>
93+
<run-dependency>
94+
<release-version>1</release-version>
95+
<specification-version>1.83.1.9</specification-version>
96+
</run-dependency>
97+
</dependency>
8998
<dependency>
9099
<code-name-base>org.openide.awt</code-name-base>
91100
<build-prerequisite/>

src/org/netbeans/modules/php/phpcsfixer/ui/actions/PhpCsFixerActionsFactory.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@
4545
import javax.swing.AbstractAction;
4646
import javax.swing.JMenu;
4747
import javax.swing.JMenuItem;
48+
import org.netbeans.api.project.FileOwnerQuery;
49+
import org.netbeans.api.project.Project;
4850
import org.netbeans.modules.php.api.phpmodule.PhpModule;
4951
import org.netbeans.modules.php.api.util.StringUtils;
5052
import org.netbeans.modules.php.phpcsfixer.options.PhpCsFixerOptions;
53+
import org.netbeans.spi.project.ui.support.ProjectConvertors;
5154
import org.openide.awt.ActionID;
5255
import org.openide.awt.ActionReference;
5356
import org.openide.awt.ActionReferences;
@@ -68,10 +71,10 @@
6871
@ActionRegistration(
6972
displayName = "#PhpCsFixerActionsFactory.name", lazy = false)
7073
@ActionReferences({
71-
@ActionReference(path = "Loaders/folder/any/Actions", position = 1600),
72-
@ActionReference(path = "Loaders/text/x-php5/Actions", position = 1600),
73-
@ActionReference(path = "Editors/text/x-php5/Popup", position = 600),
74-
@ActionReference(path = "Projects/org-netbeans-modules-php-project/Actions", position = 1100)
74+
@ActionReference(path = "Loaders/folder/any/Actions", position = 1690),
75+
@ActionReference(path = "Loaders/text/x-php5/Actions", position = 1690),
76+
@ActionReference(path = "Editors/text/x-php5/Popup", position = 590),
77+
@ActionReference(path = "Projects/org-netbeans-modules-php-project/Actions", position = 1090)
7578
})
7679
@NbBundle.Messages("PhpCsFixerActionsFactory.name=PHP CS Fixer")
7780
public class PhpCsFixerActionsFactory extends AbstractAction implements Presenter.Popup {
@@ -87,7 +90,7 @@ public void actionPerformed(ActionEvent e) {
8790
@Override
8891
public JMenuItem getPopupPresenter() {
8992
if (!isInPhpModule()) {
90-
return null;
93+
return new JMenuItem();
9194
}
9295
String phpCsFixerPath = PhpCsFixerOptions.getInstance().getPhpCsFixerPath();
9396
if (StringUtils.isEmpty(phpCsFixerPath)) {
@@ -107,7 +110,21 @@ private boolean isInPhpModule() {
107110
if (target == null) {
108111
return false;
109112
}
110-
PhpModule phpModule = PhpModule.Factory.forFileObject(target);
113+
if (!target.isFolder()) {
114+
return true;
115+
}
116+
Project nonConvertorOwner = ProjectConvertors.getNonConvertorOwner(target);
117+
if (nonConvertorOwner == null) {
118+
nonConvertorOwner = FileOwnerQuery.getOwner(target);
119+
if (nonConvertorOwner == null) {
120+
return false;
121+
}
122+
}
123+
PhpModule phpModule = PhpModule.Factory.lookupPhpModule(nonConvertorOwner);
124+
if (phpModule != null) {
125+
return true;
126+
}
127+
phpModule = PhpModule.Factory.forFileObject(target);
111128
return phpModule != null;
112129
}
113130

0 commit comments

Comments
 (0)