Closed sanishmfod closed 6 years ago
I confirm the problem on my NetBeans IDE 8.2 installation (Build 201610071157)
Confirmed on NB 8.2
I'll take a look at this sometime soon. Can someone assign this to me or give me issue permissions so I can do it myself?
Confirmed on NB 8.2 MacOS
Hey @emabrey, thanks for being so proactive! I sent you an invite for collaboration on this project. Once you accept it, I can assign this issue to you.
π Thanks @bennyn
You are welcome. Happy to see you here with a "Collaborator" badge. π
I think I may have fixed this problem locally, but I haven't really figured out what was causing it. I replaced the @LookupProvider.Registration
annotation with a @ProjectServiceProvider
annotation (including an additional service = LookupProvider.class
parameter) within ProjectHookLookup
and that seemed to fix the problem. This is the relevant log output from running my modified version locally using Netbeans 8.2:
[INFO] WARNING [org.netbeans.modules.versioning.util.Utils]: associateEncoding() no file object available for C:\Users\emily\AppData\Local\Temp\vcs-1486718692557\vcs-1486718846845\.editorconfig
[INFO] INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Resolving dependencies took: 7 ms
[INFO] INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Complete indexing of 0 binary roots took: 1 ms
[INFO] INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Complete indexing of 0 source roots took: 0 ms (New or modified files: 0, Deleted files: 0) [Adding listeners took: 0 ms]
[INFO] WARNING [org.openide.util.WeakListenerImpl]: Can't remove java.beans.PropertyChangeListener using method org.netbeans.modules.csl.core.GsfDocument.removePropertyChangeListener from org.netbeans.modules.csl.core.GsfDocument@3da3138b, mimeType='text/x-editorconfig', kitClass=null, length=666, version=1, file=com.welovecoding.nbeditorconfig.filetype.EditorConfigDataObject@1b936a79[C:\Users\emily\github_repos\editorconfig-netbeans\target\GUIFormExamples\.editorconfig@e5ffd697:4a28ae79]
[INFO] INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Resolving dependencies took: 94 ms
[INFO] WARNING [org.netbeans.modules.versioning.util.Utils]: associateEncoding() no file object available for C:\Users\emily\AppData\Local\Temp\vcs-1486718692557\vcs-1486718863007\.editorconfig
[INFO] INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Complete indexing of 21 binary roots took: 2,681 ms
[INFO] INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Indexing of: C:\Users\emily\github_repos\editorconfig-netbeans\target\GUIFormExamples\test took: 1 ms (New or modified files: 0, Deleted files: 0) [Adding listeners took: 0 ms]
[INFO] INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Indexing of: C:\Users\emily\github_repos\editorconfig-netbeans\target\GUIFormExamples\src took: 258 ms (New or modified files: 0, Deleted files: 0) [Adding listeners took: 5 ms]
[INFO] INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Complete indexing of 2 source roots took: 259 ms (New or modified files: 0, Deleted files: 0) [Adding listeners took: 5 ms]
[INFO] WARNING [org.netbeans.core.TimableEventQueue]: too much time in AWT thread org.netbeans.modules.sampler.InternalSampler@60a77bb0
[INFO] INFO [org.netbeans.core.netigso.Netigso]: bundle org.eclipse.osgi@3.9.1.v20140110-1610 256
[INFO] INFO [org.netbeans.core.netigso.Netigso]: bundle org.eclipse.osgi@3.9.1.v20140110-1610 stopped
[INFO] INFO [org.netbeans.core.netigso.Netigso]: bundle org.eclipse.osgi@3.9.1.v20140110-1610 stopped
[INFO] Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
[INFO] Java HotSpot(TM) 64-Bit Server VM warning: CMSFullGCsBeforeCompaction is deprecated and will likely be removed in a future release.
[INFO] Redirecting output to win32trace remote collector
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
The problem is that I don't quite understand why this is fixing the bug. Can someone chime in an explain if this makes any sense that this would stop the error, or perhaps am I just not able to reproduce the error for some reason?
@emabrey I think the base issue is caused by NB platform 81 and 82 moving ProjectOpenedHook to a different dependency, so I think for NB 8.1 and 8.2 and beyond, currently the fix is:
pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.api.version>RELEASE81</netbeans.api.version>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-projectuiapi-base</artifactId>
<version>${netbeans.api.version}</version>
</dependency>
So, this is in a different dependency which isn't available in 801 which the plugin depends on.
Too, I think some of the actions are run on background threads, and thus this may be needed in ProjectHookLookup.java:
@LookupProvider.Registration(projectType = {
"org-netbeans-modules-ant-freeform",
"org-netbeans-modules-apisupport-project",
"org-netbeans-modules-apisupport-project-suite",
"org-netbeans-modules-j2ee-archiveproject",
"org-netbeans-modules-j2ee-clientproject",
"org-netbeans-modules-j2ee-earproject",
"org-netbeans-modules-j2ee-ejbjarproject",
"org-netbeans-modules-java-j2seproject",
"org-netbeans-modules-maven",
"org-netbeans-modules-php-project",
"org-netbeans-modules-web-clientproject",
"org-netbeans-modules-web-project"
})
/**
* Listener for newly opened Projects.
*/
public class ProjectHookLookup implements LookupProvider {
private static final Logger LOG = Logger.getLogger(ProjectHookLookup.class.getName());
static {
LOG.setLevel(LISTENER_LOG_LEVEL);
}
@Override
public Lookup createAdditionalLookup(Lookup lookup) {
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(ProjectHookLookup.class.getClassLoader());
final Project project = lookup.lookup(Project.class);
String projectName = project.getProjectDirectory().getName();
LOG.log(Level.INFO, "Setup hooks for: {0}", projectName);
final ProjectOpenCloseListener listener = new ProjectOpenCloseListener(project);
return Lookups.fixed(listener);
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
}
Notice the setContextClassLoader
bit. I can build with mvn clean install -DskipTests
at the moment, as the dependencies make tests fail too, so more to figure out, but as a start, I think that is a base. Hope it helps.
I can report back though things seem to be working locally with the above changes as I built skipping the tests. There do seem to be issues in that I needed a restart after installing, though after install NB didn't say that, and too, it seems there is some caching of .editorconfig data as I have deleted the file, restarted, and saving doesn't reformat, but using reformat will reformat a file even though .editorconfig file is gone from the project I was using to test. My guess is there are some ways I can contribute to this as I need to use this plugin, and recently discovered it when I ran into this bug in 8.2.
Tried to install plugin v0.10.1-SNAPSHOT from branch master, then plugin v0.10.1 from tag v0.10.1 Tag v0.10.1 points to v0.1.1 so I installed this version When I tried to install plugins I got the following exception for both versions (v0.10.1-SNAPSHOT and v0.1.1) when attempting to open any projects :
Product Version: NetBeans IDE 8.2 (Build 201609300101) Java: 1.8.0_25; Java HotSpot(TM) 64-Bit Server VM 25.25-b02 Runtime: Java(TM) SE Runtime Environment 1.8.0_25-b17 System: Linux version 3.13.0-48-generic running on amd64; UTF-8; it_IT (nb) Plugin Versions : v0.10.1-SNAPSHOT v0.1.1
java.lang.NoClassDefFoundError: com/welovecoding/nbeditorconfig/listener/ProjectOpenCloseListener at com.welovecoding.nbeditorconfig.listener.ProjectHookLookup.createAdditionalLookup(ProjectHookLookup.java:53) at org.netbeans.spi.project.support.DelegatingLookupImpl.doDelegate(DelegatingLookupImpl.java:139) at org.netbeans.spi.project.support.DelegatingLookupImpl.<init>(DelegatingLookupImpl.java:91) at org.netbeans.spi.project.support.LookupProviderSupport.createCompositeLookup(LookupProviderSupport.java:111) at org.netbeans.modules.maven.NbMavenProjectImpl.<init>(NbMavenProjectImpl.java:266) at org.netbeans.modules.maven.NbMavenProjectFactory.loadProject(NbMavenProjectFactory.java:118) at org.netbeans.modules.projectapi.nb.NbProjectManager.createProject(NbProjectManager.java:401) at org.netbeans.modules.projectapi.nb.NbProjectManager.access$300(NbProjectManager.java:94) at org.netbeans.modules.projectapi.nb.NbProjectManager$2.run(NbProjectManager.java:314) at org.netbeans.modules.projectapi.nb.NbProjectManager$2.run(NbProjectManager.java:243) at org.netbeans.modules.openide.util.DefaultMutexImplementation.readAccess(DefaultMutexImplementation.java:209) at org.openide.util.Mutex.readAccess(Mutex.java:250) at org.netbeans.modules.projectapi.nb.NbProjectManager.findProject(NbProjectManager.java:243) at org.netbeans.api.project.ProjectManager.findProject(ProjectManager.java:167) at org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation.getOwner(SimpleFileOwnerQueryImplementation.java:161) at org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation.getOwner(SimpleFileOwnerQueryImplementation.java:113) at org.netbeans.api.project.FileOwnerQuery.getOwner(FileOwnerQuery.java:150) at org.netbeans.modules.projectapi.ProjectSharabilityQuery2.getSharability(ProjectSharabilityQuery2.java:63) at org.netbeans.api.queries.SharabilityQuery.getSharability(SharabilityQuery.java:177) at org.netbeans.modules.git.utils.GitUtils.isIgnored(GitUtils.java:250) at org.netbeans.modules.git.FileStatusCache.checkForIgnore(FileStatusCache.java:619) at org.netbeans.modules.git.FileStatusCache.refreshStatusesBatch(FileStatusCache.java:593) at org.netbeans.modules.git.FileStatusCache.refreshAllRoots(FileStatusCache.java:274) at org.netbeans.modules.git.FileStatusCache.refreshAllRoots(FileStatusCache.java:193) at org.netbeans.modules.git.FilesystemInterceptor$RefreshTask.run(FilesystemInterceptor.java:692) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443) at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68) at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
Based on @wadechandler comment I was able to fix build and tests on NetBeans 8.2. You can see it here: https://github.com/Jenselme/editorconfig-netbeans/tree/netbeans-82
After some quick testing, it looks like formatting is broken for some JSON files (eg this one) and indentation is not enforced in YAML and SQL files. Don't know if it was before.
@Jenselme It's great that you push "editorconfig-netbeans" forward! π
@Yserz and I were always hoping to get it into the official NetBeans Plugin Portal one day...
You can download older versions of the "editorconfig-netbeans" plugin from the Releases page to verify if the JSON formatting bug already existed. From my knowledge it was okay.
I can open a pull request for my work if you want.
It's great that you push "editorconfig-netbeans" forward!
I don't know how much I'll be able to push the project forward since I have many other projects (including the Python plugin for NetBeans).
You can download older versions of the "editorconfig-netbeans" plugin from the Releases page to verify if the JSON formatting bug already existed.
I tried on 8.0.1 and 8.0.2: the indentation was not respected but the formatting of the file was not completely broken.
I confirm the bug on this, unfortunately, I don't see any fix on this?? Do you have a workaround ?
Thx
Regards
@MimiXav you can clone my fork git clone --branch netbeans-82 git@github.com:Jenselme/editorconfig-netbeans.git
then build the NBMs from source with nvm clean install
. Will be in target/editorconfig-0.10.1-SNAPSHOT.nbm
.
Cool, I do this
Ok, I did, but unfortunately, My netbeans is freeze after a alt + shit + f ??? Do you have any idea? my netbeans is: Product Version: NetBeans IDE 8.2 (Build 201705191307)
Regards
I don't. I haven't used this plugin much yet.
What kind of project to you use?
Maven project, and java files
Is this plugin currently usable on the latest NetBeans 8.2 after all? I don't want to waste time downloading and installing (possibly multiple versions of) this plugin and finding that it doesn't work at all.
I'd say its unstable. You can build it from the source and install the resulting NBM as decribed previously. However, I experienced formatting errors while using it. So my recommendation is: wait until these issues are addressed and a proper release for 8.2 (or even 9.0) is made.
Can someone of you please make a PR to fix this bug? Would be great.
When installing this plugin (v0.10.1) I get the following exception when attempting to open any projects :
v0.10.0 Works as expected
Product Version: NetBeans IDE 8.2 (Build 201609300101) Java: 1.8.0_101; Java HotSpot(TM) 64-Bit Server VM 25.101-b13 Runtime: Java(TM) SE Runtime Environment 1.8.0_101-b13 System: Linux version 4.4.0-47-generic running on amd64; UTF-8; en_GB (nb) Plugin Version : v0.10.1