Offline inspections across multiple versions, problem with cache/indexes?
Hi all,
I'm trying to use the offline inspections support to get some basic stats for a project across multiple versions.
Basically writing a script which uses the command documented at that link, then loops over the generated XML output to get some basic stats for the project, eg:
$ ./inspectproject --projectdir ~/Work/test/ --inspection ./PHPOnly.xml [Revision] => 7874 /Applications/PhpStorm.app/Contents/bin/inspect.sh /Users/paulm/Work/test/ ./PHPOnly.xml /Users/paulm/PHPStormInspections/test.7874 -v1 Could not create DisplayChangeHandler to plug mem leaks due to display changes: java.awt.HeadlessException Apr 15 17:14:14 dev-007-mac-lt phpstorm[7035] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. Apr 15 17:14:14 dev-007-mac-lt phpstorm[7035] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. Apr 15 17:14:14 dev-007-mac-lt phpstorm[7035] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. Apr 15 17:14:14 dev-007-mac-lt phpstorm[7035] <Warning>: Invalid Connection ID 0 java.class.path: /Applications/PhpStorm.app/Contents/lib/bootstrap.jar:/Applications/PhpStorm.app/Contents/lib/extensions.jar:/Applications/PhpStorm.app/Contents/lib/util.jar:/Applications/PhpStorm.app/Contents/lib/jdom.jar:/Applications/PhpStorm.app/Contents/lib/log4j.jar:/Applications/PhpStorm.app/Contents/lib/trove4j.jar:/Applications/PhpStorm.app/Contents/lib/jna.jar java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java path.separator: : Starting up PhpStorm 8.0.2 ...done. Opening project...done. Initializing project...Using default project profile done. Inspecting with profile 'PHPOnly' Analyzing code ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ Done. [ERROR] => 365 [WARNING] => 3300 [WEAK WARNING] => 599
That seems to work as I want, but it's with the version of the code that is already checked out in PHPStorm.
I want to be able (from the command line) to do the process on a different revision of the code, eg be able to run
$ ./inspectproject --projectdir ~/Work/test/ --inspection ./PHPOnly.xml --revision 7000
which would effectively do an
$ svn update ~Work/test --revision 7000
before doing the same procedure.
PHP Storm does not seem to like this, part way through the inspection it throws an exception:
[ 35255] ERROR - ex.GlobalInspectionContextImpl - In file: PHP file java.lang.AssertionError: Stub and PSI element type mismatch in tes.php: stub PhpFieldStubImpl, AST Class method; Element(Class method) file=PHP file, modStamp=0 stub debugInfo=created from index; with backReference document before=null latestIndexedStub=com.intellij.psi.stubs.StubTree@26f61af3 same size=true debugInfo=created from index; with backReference viewProvider=PhpFileViewProvider{myVirtualFile=file:///Users/paul/Work/test/test.php, content=DocumentContent{size=47375}} viewProvider stamp: 273; file stamp: 273; file modCount: 1429083137000 doc saved: true; doc stamp: 273; doc size: 47375; committed: true ------------ at com.intellij.psi.impl.source.PsiFileImpl.reportStubAstMismatch(PsiFileImpl.java:336) at com.intellij.psi.impl.source.PsiFileImpl$1.visitNode(PsiFileImpl.java:280) at com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor.visitComposite(RecursiveTreeElementWalkingVisitor.java
etc..
etc..
I'm guessing that PHP Storm doesn't notice that I've switched the code version when it wasn't looking, and that the inspection is breaking because it's based on some cache/indexes it has that are no longer valid.
I guess I need to either
a) Update the source tree in a way the PHP Storm is more comfortable with.
b) Force PHP Storm to invalidate it's cache/index and hope it'll build a new one.
Does anyone have any ideas?
There doesn't seem to be much point in being able to do offline inspections if you have to set up exaclty what you want to inspect in the UI first.
请先登录再写评论。