LightPsi parser in standalone project blocks programm completion
Hi,
When I run my simple example the program is still running. How can I close it programmatically? Is there something like .close() or .disconnect() I am not aware of? Or is System.exit(0); the way to go (which would be bad in my case)?
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
public static void main(String[] args){
try {
File file = new File(CountKeywords.class.getResource("/example.x").getFile());
PsiFile psiFile = XStandaloneParser.parse(file);
PsiElement root = psiFile.getNode().getPsi();
Collection<PsiElement> keywords = PsiTreeUtil.findChildrenOfType(root, XKeyword.class);
System.out.println("There are " + keywords.size() + " keywords.");
}catch (IOException ex){
ex.printStackTrace();
}
}
import com.intellij.psi.PsiFile;
import org.intellij.grammar.LightPsi;
import java.io.File;
import java.io.IOException;
public class XStandaloneParser {
public static PsiFile parse(File file) throws IOException {
try {
return LightPsi.parseFile(file, new XParserDefinition());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
}
Thread Dump:
"ApplicationImpl pooled thread 1@1377" prio=4 tid=0x10 nid=NA waiting
java.lang.Thread.State: WAITING
at sun.misc.Unsafe.park(Unsafe.java:-1)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:458)
at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:362)
at java.util.concurrent.SynchronousQueue.take(SynchronousQueue.java:924)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"Periodic tasks thread@1168" prio=5 tid=0xd nid=NA waiting
java.lang.Thread.State: WAITING
at sun.misc.Unsafe.park(Unsafe.java:-1)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
at java.util.concurrent.DelayQueue.take(DelayQueue.java:223)
at com.intellij.util.concurrency.AppDelayQueue$1.run(AppDelayQueue.java:42)
at java.lang.Thread.run(Thread.java:745)
"AWT-Shutdown@1172" prio=5 tid=0xe nid=NA waiting
java.lang.Thread.State: WAITING
at java.lang.Object.wait(Object.java:-1)
at java.lang.Object.wait(Object.java:502)
at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:295)
at java.lang.Thread.run(Thread.java:745)
"Finalizer@1381" daemon prio=8 tid=0x3 nid=NA waiting
java.lang.Thread.State: WAITING
at java.lang.Object.wait(Object.java:-1)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)
"Reference Handler@1382" daemon prio=10 tid=0x2 nid=NA waiting
java.lang.Thread.State: WAITING
at java.lang.Object.wait(Object.java:-1)
at java.lang.Object.wait(Object.java:502)
at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)
"DestroyJavaVM@1375" prio=5 tid=0xf nid=NA runnable
java.lang.Thread.State: RUNNABLE
"Signal Dispatcher@1380" daemon prio=9 tid=0x4 nid=NA runnable
java.lang.Thread.State: RUNNABLE
Thank you in advance!
Best Regards
Please sign in to leave a comment.
What are these XStandaloneParser, LightPsi and other mentioned classes?
A thread dump will most likely help understanding what threads are working.
Hi,
Thank you for your reply. I provided additional information to my post.
Best Regards
Hi,
I solved the issue. Multiple dependencies were missing. But I don't know why there came no ClassNotFoundException etc.
Greetings