9 comments
Comment actions Permalink

nice job!
but there is one problem. if you enable both 'autoscroll to source' and
'autoscroll from source' then as you type the caret starts movings around.
usually if you type some incorrect (yet) code and wait until background parsing
is done then the caret usually moves to the next line.

Andrew Armstrong wrote:

- Fixed assertion when you press Ctrl+End in an editor.
- UI made prettier.

>

http://www.intellij.org/twiki/bin/view/Main/PsiViewerPlugin



--
Dmitry Skavish
-


Boston, MA, USA
tel. +1 781 370-6909
http://www.jzox.com
http://www.flashgap.com

0
Comment actions Permalink

There is a timing problem that causes the caret to jump ahead if you type
too fast. The problem is that we do not call
CodeEditorManager.commitToPsiFile inside the
CaretListener.caretPositionChanged.

But when I do I get this exception if I undo my typing:
1) Use the PsiViewer.jar attached
2) Type really fast more than 20 characters
3) Undo

ERROR - i.command.impl.UndoManagerImpl - Assertion failed:
Undoable actions allowed inside commands only (see
com.intellij.openapi.command.CommandProcessor.executeCommand())
ERROR - i.command.impl.UndoManagerImpl - IntelliJ IDEA 3.0 Build
#682
ERROR - i.command.impl.UndoManagerImpl - JDK: 1.4.1_01
ERROR - i.command.impl.UndoManagerImpl - VM: Java HotSpot(TM)
Client VM
ERROR - i.command.impl.UndoManagerImpl - Vendor: Sun Microsystems
Inc.
ERROR - i.command.impl.UndoManagerImpl - OS: Windows XP
ERROR - i.command.impl.UndoManagerImpl - Last Action: $Undo
ERROR - i.command.impl.UndoManagerImpl -
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:10)
at com.intellij.openapi.command.b.p.a(p.java:37)
at com.intellij.openapi.command.b.q.documentChanged(q.java:6)
at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.intellij.util.EventUtil$1.invoke(EventUtil.java:1)
at $Proxy0.documentChanged(Unknown Source)
at com.intellij.openapi.editor.c.p.a(p.java:128)
at com.intellij.openapi.editor.c.p.replaceString(p.java:18)
at com.intellij.codeEditor.b.a.a(a.java:138)
at com.intellij.codeEditor.b.a.a(a.java:91)
at com.intellij.codeEditor.b.d.run(d.java:7)
at com.intellij.openapi.application.a.e.runWriteAction(e.java:74)
at com.intellij.codeEditor.b.a.a(a.java:126)
at com.intellij.codeEditor.b.a.commitAllToPsiFile(a.java:18)
at com.intellij.codeInsight.l.a.f.a(f.java:152)
at com.intellij.codeInsight.l.a.f.b(f.java:185)
at com.intellij.codeInsight.l.a.f.a(f.java:42)
at com.intellij.codeInsight.l.a.o.run(o.java:0)
at com.intellij.util.Alarm$1.run(Alarm.java:4)
at com.intellij.util.Alarm$2.run(Alarm.java:5)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.intellij.ide.q.a(q.java:108)
at com.intellij.ide.q.dispatchEvent(q.java:76)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Any idea why?
As you know the plugin doesn't modify neither the editor nor the psi tree.

Jacques

"Andrew Armstrong" <andrew_armstrong=intellij@bigpond.com> wrote in message
news:4059852.1038728795480.JavaMail.jrun@is.intellij.net...

- Fixed assertion when you press Ctrl+End in an editor.
- UI made prettier.

>

http://www.intellij.org/twiki/bin/view/Main/PsiViewerPlugin






Attachment(s):
PsiViewer.jar
0
Comment actions Permalink

I have a question for JetBrains developers:
We are using CaretListener.caretPositionChanged and
PsiTreeChangeListener.childrenChanged at the same time.
It seems that there is a timing between both listeners.
Especially is CodeEditorManager.commitAllToPsiFile() asynchronous? Are we
guaranteed that the psi tree will be in sync with the document when the
method returns?
Secondly how in a caretPositionChanged can we determine that it is the
result of a code edit?

Thanks

Jacques

"Andrew Armstrong" <andrew_armstrong=intellij@bigpond.com> wrote in message
news:4059852.1038728795480.JavaMail.jrun@is.intellij.net...

- Fixed assertion when you press Ctrl+End in an editor.
- UI made prettier.

>

http://www.intellij.org/twiki/bin/view/Main/PsiViewerPlugin



0
Comment actions Permalink

"Jacques Morel" <jacmorel@yahoo.com> wrote:

Secondly how in a caretPositionChanged can we determine that it is the
result of a code edit?


Maybe VirtualFileListener.contentsChanged(VirtualFileEvent event) or
DocumentListener.documentChanged(DocumentEvent event) can be used
instead.

The corresponding add methods are:
VirtualFileManager.addVirtualFileListener(VirtualFileListener listener)
Document.addDocumentListener(DocumentListener listener)

-Thomas


0
Comment actions Permalink

Thanks Thomas but the PsiViewer needs to update the tree selection based on
the element under the caret so we need to listen with the CaretListener. The
DocumentListener only listens to document changes.

Jacques

"Thomas Vollmer" <thomas.vollmer@itt.com> wrote in message
news:aseg1u$avh$1@is.intellij.net...

"Jacques Morel" <jacmorel@yahoo.com> wrote:

Secondly how in a caretPositionChanged can we determine that it is the
result of a code edit?

>

Maybe VirtualFileListener.contentsChanged(VirtualFileEvent event) or
DocumentListener.documentChanged(DocumentEvent event) can be used
instead.

>

The corresponding add methods are:
VirtualFileManager.addVirtualFileListener(VirtualFileListener listener)
Document.addDocumentListener(DocumentListener listener)

>

-Thomas

>
>


0
Comment actions Permalink

Jacques,

It seems that there is a timing between both listeners.


Document sometimes can be modified but not commited to psi.

Especially is CodeEditorManager.commitAllToPsiFile() asynchronous?


No, it isn't.

Are we
guaranteed that the psi tree will be in sync with the document when the
method returns?


Yes.

Secondly how in a caretPositionChanged can we determine that it is the
result of a code edit?


Listen documentChanged event. Or compare modificationStamps.

--
Best regards,
Mike Aizatsky.
-


JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


0
Comment actions Permalink

BTW Mike,

What is the difference between commitToPsiFile and commitAllToPsiFile and
when would their side effects be equal and when would they be different?

Jacques
"Mike Aizatsky" <mike@intellij.com> wrote in message
news:asfm17$2sk$1@is.intellij.net...

Jacques,

>

It seems that there is a timing between both listeners.

>

Document sometimes can be modified but not commited to psi.

>

Especially is CodeEditorManager.commitAllToPsiFile() asynchronous?

>

No, it isn't.

>

Are we
guaranteed that the psi tree will be in sync with the document when the
method returns?

>

Yes.

>

Secondly how in a caretPositionChanged can we determine that it is the
result of a code edit?

>

Listen documentChanged event. Or compare modificationStamps.

>

--
Best regards,
Mike Aizatsky.
------------------------------
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"

>
>


0
Comment actions Permalink

Dear JetBrains developers,

Any idea on that exception? Is there enough to file a bug or is it only PSI
related and therefore not supported officially?
I had already several occasions where I believe the plugin really messed up
IDEA to the point I had to kill it (I could not even close it due to
internal errors).

Jacques
"Jacques Morel" <jacmorel@yahoo.com> wrote in message
news:ase0eo$nds$1@is.intellij.net...

There is a timing problem that causes the caret to jump ahead if you type
too fast. The problem is that we do not call
CodeEditorManager.commitToPsiFile inside the
CaretListener.caretPositionChanged.

>

But when I do I get this exception if I undo my typing:
1) Use the PsiViewer.jar attached
2) Type really fast more than 20 characters
3) Undo

>

ERROR - i.command.impl.UndoManagerImpl - Assertion failed:
Undoable actions allowed inside commands only (see
com.intellij.openapi.command.CommandProcessor.executeCommand())
ERROR - i.command.impl.UndoManagerImpl - IntelliJ IDEA 3.0

Build

#682
ERROR - i.command.impl.UndoManagerImpl - JDK: 1.4.1_01
ERROR - i.command.impl.UndoManagerImpl - VM: Java HotSpot(TM)
Client VM
ERROR - i.command.impl.UndoManagerImpl - Vendor: Sun

Microsystems

Inc.
ERROR - i.command.impl.UndoManagerImpl - OS: Windows XP
ERROR - i.command.impl.UndoManagerImpl - Last Action: $Undo
ERROR - i.command.impl.UndoManagerImpl -
java.lang.Throwable
at

com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:10)

at com.intellij.openapi.command.b.p.a(p.java:37)
at com.intellij.openapi.command.b.q.documentChanged(q.java:6)
at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.intellij.util.EventUtil$1.invoke(EventUtil.java:1)
at $Proxy0.documentChanged(Unknown Source)
at com.intellij.openapi.editor.c.p.a(p.java:128)
at com.intellij.openapi.editor.c.p.replaceString(p.java:18)
at com.intellij.codeEditor.b.a.a(a.java:138)
at com.intellij.codeEditor.b.a.a(a.java:91)
at com.intellij.codeEditor.b.d.run(d.java:7)
at com.intellij.openapi.application.a.e.runWriteAction(e.java:74)
at com.intellij.codeEditor.b.a.a(a.java:126)
at com.intellij.codeEditor.b.a.commitAllToPsiFile(a.java:18)
at com.intellij.codeInsight.l.a.f.a(f.java:152)
at com.intellij.codeInsight.l.a.f.b(f.java:185)
at com.intellij.codeInsight.l.a.f.a(f.java:42)
at com.intellij.codeInsight.l.a.o.run(o.java:0)
at com.intellij.util.Alarm$1.run(Alarm.java:4)
at com.intellij.util.Alarm$2.run(Alarm.java:5)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.intellij.ide.q.a(q.java:108)
at com.intellij.ide.q.dispatchEvent(q.java:76)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

>

Any idea why?
As you know the plugin doesn't modify neither the editor nor the psi tree.

>

Jacques

>

"Andrew Armstrong" <andrew_armstrong=intellij@bigpond.com> wrote in

message

news:4059852.1038728795480.JavaMail.jrun@is.intellij.net...

- Fixed assertion when you press Ctrl+End in an editor.
- UI made prettier.

>

http://www.intellij.org/twiki/bin/view/Main/PsiViewerPlugin

>
>
>


0
Comment actions Permalink

JAcques,

commitToPsiFile commits changes in one document only. It's ok to use it if
you don't resolve references etc. commitAllToPsiFile() commits changes in
all modified documents. The latest is preffered in most cases.

public abstract void commitToPsiFile(Document document);
public abstract void commitAllToPsiFile();

--
Best regards,
Mike Aizatsky.
-


JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


0

Please sign in to leave a comment.