Menu

#18 Error event is logged for log calls in util class.

v1.0.11
open
None
2
2012-07-06
2012-07-06
No

An error event is logged when using a log(i|e|w|d) template inside a static utility class that does not yet contain a logger field and when the cursor is at an position where method invocations are invalid. The expected result would be that no error is thrown.

Example:

MyUtil {

static myUtilMethod() {
}

logd + TAB
}

=> Causes the following exception to get logged, instead of doing nothing:

com.intellij.psi.impl.source.tree.java.PsiIdentifierImpl:IDENTIFIER / com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl:JAVA_CODE_REFERENCE / com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl:JAVA_CODE_REFERENCE: com.intellij.psi.impl.source.tree.java.PsiIdentifierImpl:IDENTIFIER / com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl:JAVA_CODE_REFERENCE / com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl:JAVA_CODE_REFERENCE
com.intellij.psi.PsiInvalidElementAccessException: com.intellij.psi.impl.source.tree.java.PsiIdentifierImpl:IDENTIFIER / com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl:JAVA_CODE_REFERENCE / com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl:JAVA_CODE_REFERENCE
at com.intellij.psi.impl.source.tree.LeafPsiElement.a(LeafPsiElement.java:107)
at com.intellij.psi.impl.source.tree.LeafPsiElement.getContainingFile(LeafPsiElement.java:91)
at com.intellij.psi.util.PsiUtil.getTopLevelClass(PsiUtil.java:581)
at net.sf.logsupport.util.LoggerFieldBuilder.classForPlace(LoggerFieldBuilder.java:41)
at net.sf.logsupport.util.LoggerFieldBuilder.access$000(LoggerFieldBuilder.java:36)
at net.sf.logsupport.util.LoggerFieldBuilder$1.run(LoggerFieldBuilder.java:118)
at net.sf.logsupport.livetemplates.TemplatePostProcessor.processText(TemplatePostProcessor.java:85)
at com.intellij.codeInsight.template.impl.TemplateState.a(TemplateState.java:980)
at com.intellij.codeInsight.template.impl.TemplateState.access$2100(TemplateState.java:70)
at com.intellij.codeInsight.template.impl.TemplateState$5.run(TemplateState.java:380)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:902)
at com.intellij.codeInsight.template.impl.TemplateState.doReformat(TemplateState.java:385)
at com.intellij.codeInsight.template.impl.TemplateState$4.run(TemplateState.java:346)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:902)
at com.intellij.codeInsight.template.impl.TemplateState.a(TemplateState.java:336)
at com.intellij.codeInsight.template.impl.TemplateState.start(TemplateState.java:317)
at com.intellij.codeInsight.template.impl.TemplateManagerImpl$6.run(TemplateManagerImpl.java:433)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:110)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:93)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:81)
at com.intellij.codeInsight.template.impl.TemplateManagerImpl.startTemplateWithPrefix(TemplateManagerImpl.java:422)
at com.intellij.codeInsight.template.impl.TemplateManagerImpl$5.run(TemplateManagerImpl.java:363)
at com.intellij.codeInsight.template.impl.TemplateManagerImpl.startTemplate(TemplateManagerImpl.java:128)
at com.intellij.codeInsight.template.impl.editorActions.ExpandLiveTemplateByTabAction$1.executeWriteAction(ExpandLiveTemplateByTabAction.java:35)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:52)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:902)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execute(EditorWriteActionHandler.java:36)
at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:82)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:117)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:93)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:67)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:542)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:590)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:458)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:206)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:524)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:420)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:378)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Discussion


Log in to post a comment.