8M1 OpenApi Changes: PsiManager.getInstance(project).getSearchHelper()

Our plug-in code uses

PsiVariable variable = ...
PsiReference[] references = PsiManager.getInstance(project).getSearchHelper().findReferences(variable, variable.getUseScope(), false);


What is the 8M1 replacement for this? I could not find it at
http://www.jetbrains.net/confluence/display/IDEADEV/DianaPluginMigration+Guide

--
Thanks in advance,
Tom

8 comments
Comment actions Permalink

Hello Tom,

Our plug-in code uses

>> PsiVariable variable = ...
>> PsiReference[] references =
>> PsiManager.getInstance(project).getSearchHelper().findReferences(vari
>> able, variable.getUseScope(), false);

What is the 8M1 replacement for this? I could not find it at
http://www.jetbrains.net/confluence/display/IDEADEV/DianaPluginMigra
tion+Guide


Use ReferencesSearch.search(). (This API is actually available both in Selena
and Diana.)

I've updated the migration guide to include this information.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks. Next question: we
>
PsiManager.getInstance(project).getElementFactory().createCodeBlockCodeFragment(code,
firstReference, false);

and

PsiManager.getInstance(project).getElementFactory().createTypeByFQClassName(className, element.getResolveScope())


What's the replacements for those?

--
Thanks in advance,
Tom

0
Comment actions Permalink

Hello Tom,

Thanks. Next question: we

PsiManager.getInstance(project).getElementFactory().createCodeBlockCod
eFragment(code, firstReference, false);

and

>> PsiManager.getInstance(project).getElementFactory().createTypeByFQCla
>> ssName(className, element.getResolveScope())
>>

What's the replacements for those?


JavaPsiFacade.getInstance().getParserFacade().create*

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thank you for the speedy response.

--
Tom

0
Comment actions Permalink

The old method

PsiManager.getInstance(project).getElementFactory().createCodeBlockCodeFragment(...)


returned a PsiCodeFragment (we are generating a couple of lines containing a
method call), but now using

JavaPsiFacade.getInstance(project).getParserFacade().createCodeBlockFromText(...)


a PsiCodeBlock is returned.

When debugging, our code is executed fine, even the editor shows the correct
result. Nevertheless, IDEA reports following internal error:

Assertion failed: IDENTIFIER
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.psi.impl.source.parsing.StatementParsing.a(StatementParsing.java:547)
at com.intellij.psi.impl.source.parsing.StatementParsing.parseCodeBlockText(StatementParsing.java:297)
at com.intellij.psi.impl.source.parsing.StatementParsing.parseCodeBlockText(StatementParsing.java:147)
at com.intellij.psi.impl.PsiJavaParserFacadeImpl.createCodeBlockFromText(PsiJavaParserFacadeImpl.java:134)
at com.intellij.psi.impl.PsiElementFactoryImpl.createCodeBlockFromText(PsiElementFactoryImpl.java:171)
at com.syntevo.visuallayout.VisualLayoutWriteActionHandler.executeWriteAction(VisualLayoutWriteActionHandler.java:116)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:51)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:222)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execute(EditorWriteActionHandler.java:35)
at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:60)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:143)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:67)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:46)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:7)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:1)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:233)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:251)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:143)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:224)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)


--
Tom

0
Comment actions Permalink

Hello Tom,

The old method

>> PsiManager.getInstance(project).getElementFactory().createCodeBlockCo
>> deFragment(...)
>>

returned a PsiCodeFragment (we are generating a couple of lines
containing a method call), but now using

>> JavaPsiFacade.getInstance(project).getParserFacade().createCodeBlockF
>> romText(...)
>>

a PsiCodeBlock is returned.


The old method is actually still available: JavaPsiFacade.getInstance(project).getElementFactory().createCodeBlockCodeFragment(0

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thank you. That seems to have solved the problem.

Tom

0

Please sign in to leave a comment.