com.intellij.openapi.extensions.Extensions Java Examples
The following examples show how to use
com.intellij.openapi.extensions.Extensions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PantsExternalMetricsListenerExtensionTest.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
public void testNoopMetrics() throws Throwable { class NoopMetricsListener extends EmptyMetricsTestListener { private boolean lastWasNoop; @Override public void logIsPantsNoopCompile(boolean isNoop) throws Throwable { lastWasNoop = isNoop; } } NoopMetricsListener listener = new NoopMetricsListener(); Extensions.getRootArea().getExtensionPoint(PantsExternalMetricsListener.EP_NAME).registerExtension(listener); doImport("examples/tests/scala/org/pantsbuild/example/hello/welcome"); // The first compile has to execute. assertPantsCompileExecutesAndSucceeds(pantsCompileProject()); assertFalse("Last compile should not be noop, it was.", listener.lastWasNoop); // Second compile without any change should be lastWasNoop. assertPantsCompileNoop(pantsCompileProject()); assertTrue("Last compile should be noop, but was not.", listener.lastWasNoop); }
Example #2
Source File: LaravelLightCodeInsightFixtureTestCase.java From idea-php-laravel-plugin with MIT License | 6 votes |
private void assertNavigationMatch(ElementPattern<?> pattern) { PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Set<String> targetStrings = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets == null || gotoDeclarationTargets.length == 0) { continue; } for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { targetStrings.add(gotoDeclarationTarget.toString()); if(pattern.accepts(gotoDeclarationTarget)) { return; } } } fail(String.format("failed that PsiElement (%s) navigate matches one of %s", psiElement.toString(), targetStrings.toString())); }
Example #3
Source File: InlineRefactoringActionHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override public void invoke(@Nonnull final Project project, Editor editor, PsiFile file, DataContext dataContext) { editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); PsiElement element = dataContext.getData(LangDataKeys.PSI_ELEMENT); if (element == null) { element = BaseRefactoringAction.getElementAtCaret(editor, file); } if (element != null) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElementInEditor(element, editor)) { handler.inlineElement(project, editor, element); return; } } if (invokeInliner(editor, element)) return; String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name")); CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null); } }
Example #4
Source File: ElementPreviewHintProvider.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private static LightweightHint getHint(@Nonnull PsiElement element) { for (PreviewHintProvider hintProvider : Extensions.getExtensions(PreviewHintProvider.EP_NAME)) { JComponent preview; try { preview = hintProvider.getPreviewComponent(element); } catch (Exception e) { LOG.error(e); continue; } if (preview != null) { return new LightweightHint(preview); } } return null; }
Example #5
Source File: BuckClientTest.java From buck with Apache License 2.0 | 6 votes |
@Test public void testConnectDisconnect() { Extensions.registerAreaClass("IDEA_PROJECT", null); MockDisposable mockDisposable = new MockDisposable(); MockApplication application = new MockApplicationEx(mockDisposable); ApplicationManager.setApplication(application, mockDisposable); Project project = new MockProjectEx(new MockDisposable()); TestBuckEventHandler handler = new TestBuckEventHandler(); BuckSocket buckSocket = new BuckSocket(handler); BuckClientManager.getOrCreateClient(project, handler).setBuckSocket(buckSocket); BuckClientManager.getOrCreateClient(project, handler).connect(); buckSocket.onConnect(new MockSession()); BuckClientManager.getOrCreateClient(project, handler).disconnectWithoutRetry(); buckSocket.onClose(0, "FOO"); assertFalse(BuckClientManager.getOrCreateClient(project, handler).isConnected()); }
Example #6
Source File: SvnToolBoxApp.java From SVNToolBox with Apache License 2.0 | 6 votes |
@Override public void initComponent() { myExecutor = Executors.newCachedThreadPool( new ThreadFactoryBuilder() .setDaemon(true) .setNameFormat(getComponentName()+"-pool-%s") .setPriority(Thread.NORM_PRIORITY) .build() ); myScheduledExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder() .setDaemon(true) .setNameFormat(getComponentName() + "-scheduled-pool-%s") .setPriority(Thread.NORM_PRIORITY) .build() ); List<NodeDecorationEP> nodeDecorationEPs = Arrays.asList(Extensions.getExtensions(NodeDecorationEP.POINT_NAME)); Collections.sort(nodeDecorationEPs); for (NodeDecorationEP decorationEP : nodeDecorationEPs) { NodeDecoration decoration = decorationEP.instantiate(); myNodeDecorations.add(decoration); LOG.debug("Added decoration ", decorationEP.priority, " ", decoration); } }
Example #7
Source File: ProjectViewImpl.java From consulo with Apache License 2.0 | 6 votes |
private void ensurePanesLoaded() { if (myExtensionsLoaded) return; myExtensionsLoaded = true; AbstractProjectViewPane[] extensions = Extensions.getExtensions(AbstractProjectViewPane.EP_NAME, myProject); Arrays.sort(extensions, PANE_WEIGHT_COMPARATOR); for (AbstractProjectViewPane pane : extensions) { if (myUninitializedPaneState.containsKey(pane.getId())) { try { pane.readExternal(myUninitializedPaneState.get(pane.getId())); } catch (InvalidDataException e) { // ignore } myUninitializedPaneState.remove(pane.getId()); } if (pane.isInitiallyVisible() && !myId2Pane.containsKey(pane.getId())) { addProjectPane(pane); } } }
Example #8
Source File: SymfonyLightCodeInsightFixtureTestCase.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void assertNavigationMatch(ElementPattern<?> pattern) { PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Set<String> targetStrings = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets == null || gotoDeclarationTargets.length == 0) { continue; } for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { targetStrings.add(gotoDeclarationTarget.toString()); if(pattern.accepts(gotoDeclarationTarget)) { return; } } } fail(String.format("failed that PsiElement (%s) navigate matches one of %s", psiElement.toString(), targetStrings.toString())); }
Example #9
Source File: TemplateState.java From consulo with Apache License 2.0 | 6 votes |
public void considerNextTabOnLookupItemSelected(LookupElement item) { if (item != null) { ExpressionContext context = getCurrentExpressionContext(); for (TemplateCompletionProcessor processor : Extensions.getExtensions(TemplateCompletionProcessor.EP_NAME)) { if (!processor.nextTabOnItemSelected(context, item)) { return; } } } TextRange range = getCurrentVariableRange(); if (range != null && range.getLength() > 0) { int caret = myEditor.getCaretModel().getOffset(); if (caret == range.getEndOffset() || isCaretInsideNextVariable()) { nextTab(); } else if (caret > range.getEndOffset()) { gotoEnd(true); } } }
Example #10
Source File: InlineRefactoringActionHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override public void invoke(@Nonnull Project project, @Nonnull PsiElement[] elements, DataContext dataContext) { LOG.assertTrue(elements.length == 1); if (dataContext == null) { dataContext = DataManager.getInstance().getDataContext(); } final Editor editor = dataContext.getData(PlatformDataKeys.EDITOR); for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElement(elements[0])) { handler.inlineElement(project, editor, elements [0]); return; } } invokeInliner(editor, elements[0]); }
Example #11
Source File: BuckClientTest.java From buck with Apache License 2.0 | 6 votes |
@Test public void hasBuckDisconnectedThenWeReconnectIfSoSpecified() { Extensions.registerAreaClass("IDEA_PROJECT", null); MockDisposable mockDisposable = new MockDisposable(); MockApplication application = new MockApplicationEx(mockDisposable); ApplicationManager.setApplication(application, mockDisposable); Project project = new MockProjectEx(new MockDisposable()); TestBuckEventHandler handler = new TestBuckEventHandler(); BuckSocket buckSocket = new BuckSocket(handler); BuckClientManager.getOrCreateClient(project, handler).setBuckSocket(buckSocket); BuckClientManager.getOrCreateClient(project, handler).connect(); buckSocket.onConnect(new MockSession()); BuckClientManager.getOrCreateClient(project, handler).disconnectWithRetry(); buckSocket.onClose(0, "FOO"); buckSocket.onConnect(new MockSession()); assertTrue(BuckClientManager.getOrCreateClient(project, handler).isConnected()); }
Example #12
Source File: RenameInputValidatorRegistry.java From consulo with Apache License 2.0 | 6 votes |
@javax.annotation.Nullable public static Function<String, String> getInputErrorValidator(final PsiElement element) { for(final RenameInputValidator validator: Extensions.getExtensions(RenameInputValidator.EP_NAME)) { if (!(validator instanceof RenameInputValidatorEx)) continue; final ProcessingContext context = new ProcessingContext(); if (validator.getPattern().accepts(element, context)) { return new Function<String, String>() { @Override public String fun(String newName) { return ((RenameInputValidatorEx)validator).getErrorMessage(newName, element.getProject()); } }; } } return null; }
Example #13
Source File: DrupalLightCodeInsightFixtureTestCase.java From idea-php-drupal-symfony2-bridge with MIT License | 6 votes |
private void assertNavigationMatch(ElementPattern<?> pattern) { PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Set<String> targetStrings = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets == null || gotoDeclarationTargets.length == 0) { continue; } for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { targetStrings.add(gotoDeclarationTarget.toString()); if(pattern.accepts(gotoDeclarationTarget)) { return; } } } fail(String.format("failed that PsiElement (%s) navigate matches one of %s", psiElement.toString(), targetStrings.toString())); }
Example #14
Source File: FavoritesTreeViewPanel.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private PsiDirectory[] getSelectedDirectories() { if (myBuilder == null) return null; final Object[] selectedNodeElements = getSelectedNodeElements(); if (selectedNodeElements.length != 1) return null; for (FavoriteNodeProvider nodeProvider : Extensions.getExtensions(FavoriteNodeProvider.EP_NAME, myProject)) { final PsiElement psiElement = nodeProvider.getPsiElement(selectedNodeElements[0]); if (psiElement instanceof PsiDirectory) { return new PsiDirectory[]{(PsiDirectory)psiElement}; } else if (psiElement instanceof PsiDirectoryContainer) { final String moduleName = nodeProvider.getElementModuleName(selectedNodeElements[0]); GlobalSearchScope searchScope = GlobalSearchScope.projectScope(myProject); if (moduleName != null) { final Module module = ModuleManager.getInstance(myProject).findModuleByName(moduleName); if (module != null) { searchScope = GlobalSearchScope.moduleScope(module); } } return ((PsiDirectoryContainer)psiElement).getDirectories(searchScope); } else if (psiElement != null) { PsiFile file = psiElement.getContainingFile(); if (file != null) { PsiDirectory parent = file.getParent(); if (parent != null) { return new PsiDirectory[]{parent}; } } } } return selectedNodeElements[0] instanceof PsiDirectory ? new PsiDirectory[]{(PsiDirectory)selectedNodeElements[0]} : null; }
Example #15
Source File: BuckClientTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void testMessages() { Extensions.registerAreaClass("IDEA_PROJECT", null); MockDisposable mockDisposable = new MockDisposable(); MockApplication application = new MockApplicationEx(mockDisposable); ApplicationManager.setApplication(application, mockDisposable); Project project = new MockProjectEx(new MockDisposable()); TestBuckEventHandler handler = new TestBuckEventHandler(); BuckClient client = BuckClientManager.getOrCreateClient(project, handler); // Set the socket we control BuckSocket socket = new BuckSocket(handler); client.setBuckSocket(socket); client.connect(); assertEquals("", handler.getLastMessage()); socket.onMessage("some text"); assertEquals("some text", handler.getLastMessage()); socket.onMessage("some text 1"); socket.onMessage("some text 2"); socket.onMessage("some text 3"); socket.onMessage("some text 4"); assertEquals("some text 4", handler.getLastMessage()); }
Example #16
Source File: SelectWordUtil.java From consulo with Apache License 2.0 | 5 votes |
static ExtendWordSelectionHandler[] getExtendWordSelectionHandlers() { if (!ourExtensionsLoaded) { ourExtensionsLoaded = true; for (ExtendWordSelectionHandler handler : Extensions.getExtensions(ExtendWordSelectionHandler.EP_NAME)) { registerSelectioner(handler); } } return SELECTIONERS; }
Example #17
Source File: LanguageCodeStyleSettingsProvider.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Language[] getLanguagesWithCodeStyleSettings() { final ArrayList<Language> languages = new ArrayList<>(); for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) { languages.add(provider.getLanguage()); } return languages.toArray(new Language[0]); }
Example #18
Source File: VcsCherryPickManager.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public VcsCherryPicker getCherryPickerFor(@Nonnull final VcsKey key) { return ContainerUtil.find(Extensions.getExtensions(VcsCherryPicker.EXTENSION_POINT_NAME, myProject), new Condition<VcsCherryPicker>() { @Override public boolean value(VcsCherryPicker picker) { return picker.getSupportedVcs().equals(key); } }); }
Example #19
Source File: DrupalLightCodeInsightFixtureTestCase.java From idea-php-drupal-symfony2-bridge with MIT License | 5 votes |
public void assertNavigationContains(PsiElement psiElement, String targetShortcut) { if(!targetShortcut.startsWith("\\")) { targetShortcut = "\\" + targetShortcut; } Set<String> classTargets = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { if(gotoDeclarationTarget instanceof Method) { String meName = ((Method) gotoDeclarationTarget).getName(); String clName = ((Method) gotoDeclarationTarget).getContainingClass().getPresentableFQN(); if(!clName.startsWith("\\")) { clName = "\\" + clName; } classTargets.add(clName + "::" + meName); } else if(gotoDeclarationTarget instanceof Function) { classTargets.add("\\" + ((Function) gotoDeclarationTarget).getName()); } } } } if(!classTargets.contains(targetShortcut)) { fail(String.format("failed that PsiElement (%s) navigate to %s on %s", psiElement.toString(), targetShortcut, classTargets.toString())); } }
Example #20
Source File: ProjectAbstractTreeStructureBase.java From consulo with Apache License 2.0 | 5 votes |
@Override public List<TreeStructureProvider> getProviders() { if (myProviders == null) { final TreeStructureProvider[] providers = Extensions.getExtensions(TreeStructureProvider.EP_NAME, myProject); myProviders = Arrays.asList(providers); } return myProviders; }
Example #21
Source File: DrupalLightCodeInsightFixtureTestCase.java From idea-php-drupal-symfony2-bridge with MIT License | 5 votes |
public void assertNavigationContainsFile(LanguageFileType languageFileType, String configureByText, String targetShortcut) { myFixture.configureByText(languageFileType, configureByText); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Set<String> targets = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if (gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { if(gotoDeclarationTarget instanceof PsiFile) { targets.add(((PsiFile) gotoDeclarationTarget).getVirtualFile().getUrl()); } } } } // its possible to have memory fields, // so simple check for ending conditions // temp:///src/interchange.en.xlf for (String target : targets) { if(target.endsWith(targetShortcut)) { return; } } fail(String.format("failed that PsiElement (%s) navigate to file %s", psiElement.toString(), targetShortcut)); }
Example #22
Source File: LaravelLightCodeInsightFixtureTestCase.java From idea-php-laravel-plugin with MIT License | 5 votes |
public void assertNavigationContainsFile(LanguageFileType languageFileType, String configureByText, String targetShortcut) { myFixture.configureByText(languageFileType, configureByText); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Set<String> targets = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if (gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { if(gotoDeclarationTarget instanceof PsiFile) { targets.add(((PsiFile) gotoDeclarationTarget).getVirtualFile().getUrl()); } } } } // its possible to have memory fields, // so simple check for ending conditions // temp:///src/interchange.en.xlf for (String target : targets) { if(target.endsWith(targetShortcut)) { return; } } fail(String.format("failed that PsiElement (%s) navigate to file %s", psiElement.toString(), targetShortcut)); }
Example #23
Source File: LaravelLightCodeInsightFixtureTestCase.java From idea-php-laravel-plugin with MIT License | 5 votes |
private void assertNavigationIsEmpty() { PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { fail(String.format("failed that PsiElement (%s) navigate is empty; found target in '%s'", psiElement.toString(), gotoDeclarationHandler.getClass())); } } }
Example #24
Source File: LaravelLightCodeInsightFixtureTestCase.java From idea-php-laravel-plugin with MIT License | 5 votes |
public void assertNavigationContains(PsiElement psiElement, String targetShortcut) { if(!targetShortcut.startsWith("\\")) { targetShortcut = "\\" + targetShortcut; } Set<String> classTargets = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { if(gotoDeclarationTarget instanceof Method) { String meName = ((Method) gotoDeclarationTarget).getName(); String clName = ((Method) gotoDeclarationTarget).getContainingClass().getPresentableFQN(); if(!clName.startsWith("\\")) { clName = "\\" + clName; } classTargets.add(clName + "::" + meName); } else if(gotoDeclarationTarget instanceof Function) { classTargets.add("\\" + ((Function) gotoDeclarationTarget).getName()); } } } } if(!classTargets.contains(targetShortcut)) { fail(String.format("failed that PsiElement (%s) navigate to %s on %s", psiElement.toString(), targetShortcut, classTargets.toString())); } }
Example #25
Source File: MoveFileHandler.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static MoveFileHandler forElement(PsiFile element) { for(MoveFileHandler processor: Extensions.getExtensions(EP_NAME)) { if (processor.canProcessElement(element)) { return processor; } } return DEFAULT; }
Example #26
Source File: BashTestUtils.java From BashSupport with Apache License 2.0 | 5 votes |
public static InspectionProfileEntry findInspectionProfileEntry(Class<? extends LocalInspectionTool> clazz) { LocalInspectionEP[] extensions = Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION); for (LocalInspectionEP extension : extensions) { if (extension.implementationClass.equals(clazz.getCanonicalName())) { extension.enabledByDefault = true; return extension.instantiateTool(); } } throw new IllegalStateException("Unable to find inspection profile entry for " + clazz); }
Example #27
Source File: GenerateByPatternAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { PatternDescriptor[] patterns = new PatternDescriptor[0]; PatternProvider[] extensions = Extensions.getExtensions(PatternProvider.EXTENSION_POINT_NAME); for (PatternProvider extension : extensions) { if (extension.isAvailable(e.getDataContext())) { patterns = ArrayUtil.mergeArrays(patterns, extension.getDescriptors()); } } GenerateByPatternDialog dialog = new GenerateByPatternDialog(e.getProject(), patterns, e.getDataContext()); dialog.show(); if (dialog.isOK()) { dialog.getSelectedDescriptor().actionPerformed(e.getDataContext()); } }
Example #28
Source File: CodeInsightFixtureTestCase.java From silex-idea-plugin with MIT License | 5 votes |
protected void assertSignatureEqualsType(String typeSignature, String phpClassType) { PhpTypeProvider2[] typeAnalyser = Extensions.getExtensions(PhpTypeProvider2.EP_NAME); for (PhpTypeProvider2 provider : typeAnalyser) { if (provider instanceof PimplePhpTypeProvider) { assertEquals(provider.getBySignature(typeSignature, myFixture.getProject()).iterator().next().getType().toString(), phpClassType); } } }
Example #29
Source File: AllFileTemplatesConfigurable.java From consulo with Apache License 2.0 | 5 votes |
private static boolean isInternalTemplateName(final String templateName) { for (InternalTemplateBean bean : Extensions.getExtensions(InternalTemplateBean.EP_NAME)) { if (Comparing.strEqual(templateName, bean.name)) { return true; } } return false; }
Example #30
Source File: SymfonyLightCodeInsightFixtureTestCase.java From idea-php-toolbox with MIT License | 5 votes |
public void assertNavigationContainsFile(LanguageFileType languageFileType, String configureByText, String targetShortcut) { myFixture.configureByText(languageFileType, configureByText); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Set<String> targets = new HashSet<>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if (gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { if(gotoDeclarationTarget instanceof PsiFile) { targets.add(((PsiFile) gotoDeclarationTarget).getVirtualFile().getUrl()); } } } } // its possible to have memory fields, // so simple check for ending conditions // temp:///src/interchange.en.xlf for (String target : targets) { if(target.endsWith(targetShortcut)) { return; } } fail(String.format("failed that PsiElement (%s) navigate to file %s", psiElement.toString(), targetShortcut)); }