Is it possible to run PyDev code analysis from the command line? - eclipse

I'm trying to run a headless eclipse build but I'm getting stuck. My context is that I want to use the PyDev code analysis without having to fire up the eclipse gui. I am aware of the other command line tools to do code analysis (pyflakes, pylint, etc).
The command I have so far is:
java -jar /path/to/eclipse/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar -noSplash -data "/path/to/workspace" -application org.eclipse.jdt.apt.core.aptBuild
My java version 1.6.0_31, my eclipse version is 3.7.2, and my pydev version is 2.5.0.
When I run the command, it looks like it is working, but it never catches any errors or warnings.
...
PyDev: Analyzing 29 of 33 (forms.py)
PyDev: Analyzing 29 of 33 (forms.py)
PyDev: Analyzing 29 of 33 (forms.py)
PyDev: Analyzing 29 of 33 (forms.py)
...
If I tail -f /path/to/workspace/.metadata/.log, I get a huge stack trace:
!ENTRY org.eclipse.equinox.preferences 4 2 2012-07-30 17:48:39.612
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.equinox.preferences".
!STACK 0
java.lang.ExceptionInInitializerError
at org.eclipse.debug.internal.ui.DebugUIPreferenceInitializer.setDefault(DebugUIPreferenceInitializer.java:186)
at org.eclipse.debug.internal.ui.DebugUIPreferenceInitializer.setThemeBasedPreferences(DebugUIPreferenceInitializer.java:204)
at org.eclipse.debug.internal.ui.DebugUIPreferenceInitializer.initializeDefaultPreferences(DebugUIPreferenceInitializer.java:79)
at org.eclipse.core.internal.preferences.PreferenceServiceRegistryHelper$1.run(PreferenceServiceRegistryHelper.java:281)
..... TRUNCATED ......
!ENTRY org.eclipse.osgi 4 0 2012-07-30 17:48:39.622
!MESSAGE An error occurred while automatically activating bundle org.eclipse.debug.ui (42).
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.debug.internal.ui.DebugUIPlugin.start() of bundle org.eclipse.debug.ui.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
..... TRUNCATED .......
java.lang.IllegalStateException: Workbench has not been created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
at org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager.startup(LaunchingResourceManager.java:546)
at org.eclipse.debug.internal.ui.DebugUIPlugin.getLaunchingResourceManager(DebugUIPlugin.java:315)
at org.eclipse.debug.internal.ui.DebugUIPlugin.start(DebugUIPlugin.java:516)
..... TRUNCATED ......
!ENTRY org.eclipse.osgi 4 0 2012-07-30 17:48:39.624
!MESSAGE An error occurred while automatically activating bundle org.eclipse.debug.core (41).
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.debug.core.DebugPlugin.start() of bundle org.eclipse.debug.core.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
..... TRUNCATED ......
My suspicion is that PyDev needs the gui to render the errors/warnings.

PyDev needs the gui to render errors/warnings and in general it was not done to be used in the command line... now, having said that, it does have unit-tests that run the code-analysis without requiring a gui (nor even eclipse loaded), but you have to configure the interpreter/projects in-memory for that to work.
See:
https://github.com/aptana/Pydev/blob/development/plugins/com.python.pydev.analysis/tests/com/python/pydev/analysis/OccurrencesAnalyzerTest.java
https://github.com/aptana/Pydev/blob/development/plugins/com.python.pydev.analysis/tests/com/python/pydev/analysis/AnalysisTestsBase.java
for tests that do code-analysis without requiring the eclipse workbench to be loaded at all (i.e.: doesn't even need eclipse to be run headless -- it could be run as a simple java program, but you still have to do the java main([]) using PyDev in the CLASSPATH and using its API to properly set the interpreter used in PyDev as well as the projects/pythonpath).
You can take a look at the setUp of the tests (i.e.: don't forget to also look superclasses such as CodeCompletionTestsBase/AnalysisTestsBase).
Note: if you do create such a main([]), please provide a patch for PyDev as it may be used by others...
As an implementation note, such a main should probably gather all the current PYTHONPATH entries from the shell being launched and configure all of those in the interpreter... Also, it should probably receive a directory as a parameter so that it analyzes all files in the tree (the startup is probably going to take the most of your time to configure things, so, ideally analyze as much files as you can from a single run, as the PyDev code-analysis was done to cache lots of things in the startup and then use the information from RAM -- or maybe create a server process that's always live?).

Related

Problem updating eclipse rcp application from 4.16 to 4.22

I am updating my eclipse rcp application from 4.16 to 4.22.
If I run my updated eclipse rcp application in an entirely new workspace, it works.
If I run my updated eclipse rcp application on top of an existing workspace that previously ran the 4.16 version, there is this error about not finding an icon (this is the project explorer icon that changed from a gif to a png file):
!ENTRY org.eclipse.jface 4 0 2022-01-31 08:37:13.602
!MESSAGE /icons/full/eview16/resource_persp.gif
!STACK 0
java.io.FileNotFoundException: /icons/full/eview16/resource_persp.gif
at org.eclipse.osgi.storage.url.bundleentry.Handler.findBundleEntry(Handler.java:55)
I tried deleting everything in the workspace except the workpace/.metadata/.plugins/org.eclpse.core.resources
directory before launching my updated application, but it displays an empty application window with the following general error:
!ENTRY org.eclipse.osgi 4 0 2022-01-31 08:47:03.042
!MESSAGE An error occurred while automatically activating bundle com.xxx.xxx.xxx.xx.xxx (15).
!STACK 0
org.osgi.framework.BundleException: Error loading bundle activator.
If I close my application and launch a second time, everything works. The workspace somehow fixes itself.
Any ideas on how to fix my existing workspace before the first launch of my updated application? I do have an installer, so can perform some sort of one time fix.
Other things I have tried that result in a failed first launch, but fixed second launch:
Deleting the workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi file
Modifying the workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi file to reference resource_persp.png instead of resource_persp.gif

java.lang.NumberFormatException on Eclipse start

When I start Eclipse, I sometimes get the following error:
!SESSION Wed Dec 16 09:31:26 EST 2015 ------------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2015-12-16 09:31:26.409
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.NumberFormatException: null
at java.lang.Long.parseLong(Long.java:404)
at java.lang.Long.parseLong(Long.java:483)
at org.eclipse.equinox.launcher.Main.getLastKnownConfigIniBaseTimestamp(Main.java:1966)
at org.eclipse.equinox.launcher.Main.processConfiguration(Main.java:1905)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
A similar error with a different call stack and cause is described here.
The problem is that my Linux machine was forgetting its username database (due to some obscure Winbind problem). As a result, Eclipse can't look up my user information and (presumably) can't find my home directory to load and parse its configuration.
(A symptom is that, when run under strace, I could see that Eclipse was looking under ? for its .eclipse configuration directory.)
Fixing the username database so that Eclipse can find my user account fixed the problem. (This has also been logged on Eclipse's Bugzilla.)

InconsistenProjectHierarchyException

I have a project with sub-projects (https://github.com/i23098/Collections) that compiles correctly on the command-line. When I try to import the project in Eclipse I get an error and tells me to check the log... Checking it, it has:
!ENTRY org.springsource.ide.eclipse.gradle.core 4 0 2014-11-09 17:03:13.404
!MESSAGE Gradle project hierarchy is inconsistent for '/home/ralmeida/workspace-collections/Collections'
!STACK 0
java.lang.reflect.InvocationTargetException
at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:113)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: org.springsource.ide.eclipse.gradle.core.InconsistenProjectHierarchyException: Gradle project hierarchy is inconsistent for '/home/ralmeida/workspace-collections/Collections'
at org.springsource.ide.eclipse.gradle.core.util.ExceptionUtil.inconsistentProjectHierachy(ExceptionUtil.java:82)
at org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.getCachedModel(GradleModelProvider.java:339)
at org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:634)
at org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:653)
at org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:105)
... 1 more
Root exception:
org.springsource.ide.eclipse.gradle.core.InconsistenProjectHierarchyException: Gradle project hierarchy is inconsistent for '/home/ralmeida/workspace-collections/Collections'
at org.springsource.ide.eclipse.gradle.core.util.ExceptionUtil.inconsistentProjectHierachy(ExceptionUtil.java:82)
at org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.getCachedModel(GradleModelProvider.java:339)
at org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:634)
at org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:653)
at org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:105)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Eclipse IDE for Java EE Developers 4.4.1.20140925-1820
Gradle IDE 3.6.2.201410090835-RELEASE (configured to use gradle wrapper at http://services.gradle.org/distributions/gradle-2.1-bin.zip)
Any ideas?
I just spontaneously ran into this problem myself with a working project. After a bit of investigation, I found that an incorrect value was written into file:
projectDir/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs
for the key:
org.springsource.ide.eclipse.gradle.rootprojectloc=
I found simply deleting the bogus value corrected the problem in my case

Cannot run Eclipse

This morning, I'm not able do run Eclipse Indigo whereas yesterday it was working.
I receive this message :
An error has occured. See the log file E:\workspaces\sim.metadata.log
And my .log file displays :
!STACK 0
!MESSAGE An error occurred while automatically activating bundle org.eclipse.core.resources (103).
...
Caused by: java.lang.ClassFormatError: Illegal constant pool index 7436 for method signature in class file org/eclipse/core/internal/resources/MarkerManager
...
!STACK 1
java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer
...
Caused by: org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter$TerminatingClassNotFoundException: An error occurred while automatically activating bundle org.eclipse.core.resources (103).
...
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources.
I ran Eclipse with the clean argument but it's the same.
Thanks for any help
It looks like your eclipse crashed sometime before and is unable to restore the workspace.
You can delete .metadata/.plugins/org.eclipse.core.resources/.snap .
Or
Try using a new workspace. Change the settings in \configuration.settings\org.eclipse.ui.ide.prefs and set SHOW_WORKSPACE_SELECTION_DIALOG to true
After that import all your projects to your workspace.
Try reinstalling Eclipse. The message regarding an illegal constant pool index sounds like a broken .class file. Your settings and workspace should remain intact, but you may need to re-install your plugins (if any).
I suppose you still have your workspace intact.The best and fastest option would be to reinstall eclipse and replace the new workspace with the older one.

my eclipse stopped working today

Today I was running into problems with eclipse, like every time I closed a project a window popped up saying something like "error saving workspace" and complaining about apache xerces.
I decided to download a fresh install, and now it won't even start. I tried many variants (classic, javase, c++), hoping there was some distribution issues, but nothing worked. Eclipse starts saying "an error has occurred, see configurationlog ..."
Any idea? Are there some cached files in the system that might have become corrupted? I tried doing a "find / | grep eclipse" but found nothing interesting.
Thanks a lot for your help, I'm quite in trouble without it
Regards,
Nicola Montecchio
p.s. I tried also with 32 bit jvm but nothing changed
[edit] here is relevant bits of the log produced when starting:
!ENTRY org.eclipse.osgi 4 0 2010-07-23 21:35:16.835
!MESSAGE An unexpected runtime error has occurred.
!STACK 0
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
!ENTRY org.eclipse.osgi 4 0 2010-07-23 21:35:16.839
!MESSAGE
!STACK 0
org.osgi.framework.ServiceException: Exception in org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorHook$ParsingService.getService()
!ENTRY org.eclipse.equinox.registry 4 0 2010-07-23 21:35:16.840
!MESSAGE Could not parse XML contribution for "org.eclipse.ant.core//plugin.xml". Any contributed extensions and extension points will be ignored.
!STACK 0
org.xml.sax.SAXException: Could not acquire XML parsing service.
and several other mostly related to xml ...
Sounds like your current workspace is severely broken. Create a new workspace and import the projects from the old locations (File -> Import), and see if that helps.
Things I'd try are renaming your workspace (so Eclipse will use a fresh one when starting up) or running Eclipse with the -clean parameter (in the console with ./eclipse -clean in your eclipse/ folder).