@Override public void actionPerformed(AnActionEvent e) { final Project project = e.getRequiredData(CommonDataKeys.PROJECT); final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR); final PsiFile psiFile = e.getRequiredData(CommonDataKeys.PSI_FILE); CommandProcessor.getInstance().executeCommand(project, () -> { try { MultiHighlightHandler.invoke(project, editor, psiFile); } catch (IndexNotReadyException ex) { DumbService.getInstance(project) .showDumbModeNotification("MultiHighlight requires indices " + "and cannot be performed until they are built"); } }, "MultiHighlight", null); }
@Nullable @Override public TextRange getExpressionRangeAtOffset(final Project project, final Document document, final int offset, final boolean sideEffectsAllowed) { final Ref<TextRange> currentRange = Ref.create(null); PsiDocumentManager.getInstance(project).commitAndRunReadAction(() -> { try { PsiElement elementAtCursor = XDebuggerUtil.getInstance().findContextElement(PsiDocumentManager .getInstance(project).getPsiFile(document).getVirtualFile(), offset, project, false); if (elementAtCursor == null) return; Pair<PsiElement, TextRange> pair = findExpression(elementAtCursor, sideEffectsAllowed); if (pair != null) { currentRange.set(pair.getSecond()); } } catch (IndexNotReadyException ignored) {} }); return currentRange.get(); }
private static boolean isImplementingLambdaMethod(PsiClass baseClass) { if (!baseClass.hasModifierProperty(PsiModifier.ABSTRACT)) return false; for (final PsiMethod method : baseClass.getMethods()) { if (method.hasModifierProperty(PsiModifier.ABSTRACT)) { return true; } } try { return !OverrideImplementExploreUtil.getMethodSignaturesToImplement(baseClass).isEmpty(); } catch (IndexNotReadyException e) { return false; } }
@Nullable @Override public TextRange getExpressionRangeAtOffset(final Project project, final Document document, final int offset, final boolean sideEffectsAllowed) { final Ref<TextRange> currentRange = Ref.create(null); PsiDocumentManager.getInstance(project).commitAndRunReadAction(new Runnable() { @Override public void run() { try { PsiElement elementAtCursor = DebuggerUtilsEx.findElementAt(PsiDocumentManager.getInstance(project).getPsiFile(document), offset); if (elementAtCursor == null) { return; } Pair<PsiElement, TextRange> pair = findExpression(elementAtCursor, sideEffectsAllowed); if (pair != null) { currentRange.set(pair.getSecond()); } } catch (IndexNotReadyException ignored) {} } }); return currentRange.get(); }
public PsiField getPsiField() { final SourcePosition sourcePosition = getSourcePosition(); try { final PsiField field = ApplicationManager.getApplication().runReadAction(new Computable<PsiField>() { @Override public PsiField compute() { final PsiClass psiClass = getPsiClassAt(sourcePosition); return psiClass != null ? psiClass.findFieldByName(getFieldName(), true) : null; } }); if (field != null) { return field; } } catch (IndexNotReadyException ignored) {} return PositionUtil.getPsiElementAt(getProject(), PsiField.class, sourcePosition); }
@Override public void visitMethodCallExpression(PsiMethodCallExpression expression) { if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkEnumSuperConstructorCall(expression)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkSuperQualifierType(myFile.getProject(), expression)); // in case of JSP synthetic method call, do not check if (myFile.isPhysical() && !myHolder.hasErrorResults()) { try { myHolder.add(HighlightMethodUtil.checkMethodCall(expression, myResolveHelper, myLanguageLevel,myJavaSdkVersion)); } catch (IndexNotReadyException ignored) { } } if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkConstructorCallMustBeFirstStatement(expression)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkSuperAbstractMethodDirectCall(expression)); if (!myHolder.hasErrorResults()) visitExpression(expression); }
@Override public void visitNewExpression(PsiNewExpression expression) { final PsiType type = expression.getType(); final PsiClass aClass = PsiUtil.resolveClassInType(type); myHolder.add(HighlightUtil.checkUnhandledExceptions(expression, null)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkAnonymousInheritFinal(expression)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkQualifiedNew(expression, type, aClass)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkCreateInnerClassFromStaticContext(expression, type, aClass)); if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkTypeParameterInstantiation(expression)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkInstantiationOfAbstractClass(aClass, expression)); try { if (!myHolder.hasErrorResults()) HighlightMethodUtil.checkNewExpression(expression, type, myHolder, myJavaSdkVersion); } catch (IndexNotReadyException ignored) { } if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkEnumInstantiation(expression, aClass)); if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkGenericArrayCreation(expression, type)); if (!myHolder.hasErrorResults()) registerConstructorCall(expression); if (!myHolder.hasErrorResults()) visitExpression(expression); }
private boolean isReassigned(@NotNull PsiVariable variable) { try { boolean reassigned; if (variable instanceof PsiParameter) { reassigned = myReassignedParameters.get((PsiParameter)variable) == 2; } else { reassigned = HighlightControlFlowUtil.isReassigned(variable, myFinalVarProblems); } return reassigned; } catch (IndexNotReadyException e) { return false; } }
static HighlightInfo checkUnreachableStatement(@Nullable PsiCodeBlock codeBlock) { if (codeBlock == null) return null; // do not compute constant expressions for if() statement condition // see JLS 14.20 Unreachable Statements try { AllVariablesControlFlowPolicy policy = AllVariablesControlFlowPolicy.getInstance(); final ControlFlow controlFlow = ControlFlowFactory.getInstance(codeBlock.getProject()).getControlFlow(codeBlock, policy, false, false); final PsiElement unreachableStatement = ControlFlowUtil.getUnreachableStatement(controlFlow); if (unreachableStatement != null) { String description = JavaErrorMessages.message("unreachable.statement"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(unreachableStatement).descriptionAndTooltip(description).create(); } } catch (AnalysisCanceledException e) { // incomplete code } catch (IndexNotReadyException ignored) { } return null; }
public static int getClassPosition(final PsiClass aClass) { if (aClass == null || !aClass.isValid()) { return 0; } try { int pos = aClass instanceof JspClass ? ElementPresentationUtil.CLASS_KIND_JSP : ElementPresentationUtil.getClassKind(aClass); //abstract class before concrete if (pos == ElementPresentationUtil.CLASS_KIND_CLASS || pos == ElementPresentationUtil.CLASS_KIND_EXCEPTION) { boolean isAbstract = aClass.hasModifierProperty(PsiModifier.ABSTRACT) && !aClass.isInterface(); if (isAbstract) { pos --; } } return pos; } catch (IndexNotReadyException e) { return 0; } }
@NotNull private AnAction showSettings() { final ConfigurableUsageTarget configurableUsageTarget = getConfigurableTarget(myTargets); String description = null; try { description = configurableUsageTarget == null ? null : "Show settings for "+configurableUsageTarget.getLongDescriptiveName(); } catch (IndexNotReadyException ignored) { } if (description == null) { description = "Show find usages settings dialog"; } return new AnAction("Settings...", description, AllIcons.General.ProjectSettings) { { KeyboardShortcut shortcut = configurableUsageTarget == null ? getShowUsagesWithSettingsShortcut() : configurableUsageTarget.getShortcut(); if (shortcut != null) { registerCustomShortcutSet(new CustomShortcutSet(shortcut), getComponent()); } } @Override public void actionPerformed(AnActionEvent e) { FindManager.getInstance(getProject()).showSettingsAndFindUsages(myTargets); } }; }
public ApplyAction() { super(CommonBundle.getApplyButtonText()); final Runnable updateRequest = new Runnable() { @Override public void run() { if (!isShowing()) return; try { setEnabled(myConfigurable != null && myConfigurable.isModified()); } catch (IndexNotReadyException ignored) { } addUpdateRequest(this); } }; // invokeLater necessary to make sure dialog is already shown so we calculate modality state correctly. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { addUpdateRequest(updateRequest); } }); }
public void update(AnActionEvent event) { Presentation presentation = event.getPresentation(); Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { presentation.setEnabled(false); // make it invisible only in main menu to avoid initial invisibility in toolbars presentation.setVisible(!ActionPlaces.isMainMenuOrActionSearch(event.getPlace())); return; } OccurenceNavigator navigator = getNavigator(event.getDataContext()); if (navigator == null) { presentation.setEnabled(false); // make it invisible only in main menu to avoid initial invisibility in toolbars presentation.setVisible(!ActionPlaces.isMainMenuOrActionSearch(event.getPlace())); return; } presentation.setVisible(true); try { presentation.setEnabled(hasOccurenceToGo(navigator)); presentation.setText(getDescription(navigator)); } catch (IndexNotReadyException e) { presentation.setEnabled(false); } }
@Nullable public static VcsSelection getSelection(VcsContext context) { VcsSelection selectionFromEditor = getSelectionFromEditor(context); if (selectionFromEditor != null) { return selectionFromEditor; } for(VcsSelectionProvider provider: Extensions.getExtensions(VcsSelectionProvider.EP_NAME)) { try { final VcsSelection vcsSelection = provider.getSelection(context); if (vcsSelection != null) return vcsSelection; } catch (IndexNotReadyException ignored) { } } return null; }
@Nullable("For the case the search has been cancelled") protected PsiElement[] searchDefinitions(final PsiElement element, final Editor editor) { final PsiElement[][] result = new PsiElement[1][]; if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { try { result[0] = DefinitionsScopedSearch.search(element, getSearchScope(element, editor)).toArray(PsiElement.EMPTY_ARRAY); } catch (IndexNotReadyException e) { dumbModeNotification(element); result[0] = null; } } }, SEARCHING_FOR_IMPLEMENTATIONS, true, element.getProject())) { return null; } return result[0]; }
@Override public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) { PsiDocumentManager.getInstance(project).commitAllDocuments(); DumbService.getInstance(project).setAlternativeResolveEnabled(true); try { int offset = editor.getCaretModel().getOffset(); PsiElement[] symbolTypes = findSymbolTypes(editor, offset); if (symbolTypes == null || symbolTypes.length == 0) return; if (symbolTypes.length == 1) { navigate(project, symbolTypes[0]); } else { NavigationUtil.getPsiElementPopup(symbolTypes, CodeInsightBundle.message("choose.type.popup.title")).showInBestPositionFor(editor); } } catch (IndexNotReadyException e) { DumbService.getInstance(project).showDumbModeNotification("Navigation is not available here during index update"); } finally { DumbService.getInstance(project).setAlternativeResolveEnabled(false); } }
@Override @NotNull public DocInfo getInfo() { return ApplicationManager.getApplication().runReadAction(new Computable<DocInfo>() { @Override public DocInfo compute() { try { return generateInfo(myTargetElement, myElementAtPointer); } catch (IndexNotReadyException e) { showDumbModeNotification(myTargetElement.getProject()); return DocInfo.EMPTY; } } }); }
private void doExecute(@NotNull PsiFile file, int offset) { final Info info; try { info = getInfoAt(myEditor, file, offset, myBrowseMode); if (info == null) return; } catch (IndexNotReadyException e) { showDumbModeNotification(myProject); return; } ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { if (myDisposed || myEditor.isDisposed() || !myEditor.getComponent().isShowing()) return; showHint(info); } }); }
private static boolean isAvailableHere(Editor editor, PsiFile psiFile, PsiElement psiElement, boolean inProject, IntentionAction action) { try { Project project = psiFile.getProject(); if (action instanceof SuppressIntentionActionFromFix) { final ThreeState shouldBeAppliedToInjectionHost = ((SuppressIntentionActionFromFix)action).isShouldBeAppliedToInjectionHost(); if (editor instanceof EditorWindow && shouldBeAppliedToInjectionHost == ThreeState.YES) { return false; } if (!(editor instanceof EditorWindow) && shouldBeAppliedToInjectionHost == ThreeState.NO) { return false; } } if (action instanceof PsiElementBaseIntentionAction) { if (!inProject || psiElement == null || !((PsiElementBaseIntentionAction)action).isAvailable(project, editor, psiElement)) return false; } else if (!action.isAvailable(project, editor, psiFile)) { return false; } } catch (IndexNotReadyException e) { return false; } return true; }
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); Project project = e.getData(CommonDataKeys.PROJECT); if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())) { presentation.setDescription(ExecutionBundle.message("choose.run.configuration.action.description")); } try { if (project == null || project.isDisposed() || !project.isInitialized()) { updatePresentation(null, null, null, presentation); presentation.setEnabled(false); } else { updatePresentation(ExecutionTargetManager.getActiveTarget(project), RunManagerEx.getInstanceEx(project).getSelectedConfiguration(), project, presentation); presentation.setEnabled(true); } } catch (IndexNotReadyException e1) { presentation.setEnabled(false); } }
private static void setConfigurationIcon(final Presentation presentation, final RunnerAndConfigurationSettings settings, final Project project) { try { Icon icon = RunManagerEx.getInstanceEx(project).getConfigurationIcon(settings); ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project); List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(new Condition<RunnerAndConfigurationSettings>() { @Override public boolean value(RunnerAndConfigurationSettings s) { return s == settings; } }); if (runningDescriptors.size() == 1) { icon = ExecutionUtil.getLiveIndicator(icon); } if (runningDescriptors.size() > 1) { icon = IconUtil.addText(icon, String.valueOf(runningDescriptors.size())); } presentation.setIcon(icon); } catch (IndexNotReadyException ignored) { } }
@NotNull @Override public Icon evaluate() { Icon result; try { result = nonNull(myEvaluator.fun(myParam)); } catch (IndexNotReadyException e) { result = EMPTY_ICON; } if (Holder.CHECK_CONSISTENCY) { checkDoesntReferenceThis(result); } return result; }
private void perform(List<DependenciesBuilder> builders) { try { PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot(); for (AnalysisScope scope : myScopes) { builders.add(createDependenciesBuilder(scope)); } for (DependenciesBuilder builder : builders) { builder.analyze(); } snapshot.logResponsivenessSinceCreation("Dependency analysis"); } catch (IndexNotReadyException e) { DumbService.getInstance(myProject).showDumbModeNotification("Analyze dependencies is not available until indices are ready"); throw new ProcessCanceledException(); } }
public int getFileCount(PsiDirectory directory) { Iterator<PsiFile> iterator = myBuilder.getFiles(directory); int count = 0; try { while (iterator.hasNext()) { PsiFile psiFile = iterator.next(); if (getStructure().accept(psiFile)) { count++; } } } catch (IndexNotReadyException e) { return count; } return count; }
/** * Initializes the builder. Subclasses should don't forget to call this method after constructor has * been invoked. */ public final void init() { TodoTreeStructure todoTreeStructure = createTreeStructure(); setTreeStructure(todoTreeStructure); todoTreeStructure.setTreeBuilder(this); try { rebuildCache(); } catch (IndexNotReadyException ignore) {} initRootNode(); Object selectableElement = todoTreeStructure.getFirstSelectableElement(); if (selectableElement != null) { buildNodeForElement(selectableElement); DefaultMutableTreeNode node = getNodeForElement(selectableElement); if (node != null) { getTree().getSelectionModel().setSelectionPath(new TreePath(node.getPath())); } } FileStatusManager.getInstance(myProject).addFileStatusListener(myFileStatusListener); }
@NotNull private static Collection<PsiClass> findInheritors(@NotNull final Module module, @NotNull final String name) { if (!ApplicationManager.getApplication().isReadAccessAllowed()) { return ApplicationManager.getApplication().runReadAction(new Computable<Collection<PsiClass>>() { @Override public Collection<PsiClass> compute() { return findInheritors(module, name); } }); } Project project = module.getProject(); try { PsiClass base = JavaPsiFacade.getInstance(project).findClass(name, GlobalSearchScope.allScope(project)); if (base != null) { GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, false); return ClassInheritorsSearch.search(base, scope, true).findAll(); } } catch (IndexNotReadyException ignored) { } return Collections.emptyList(); }
private static boolean isFieldUnreferenced(final PsiField field) { try { return ReferencesSearch.search(field).forEach(new Processor<PsiReference>() { public boolean process(final PsiReference t) { PsiFile f = t.getElement().getContainingFile(); if (f != null && f.getFileType().equals(StdFileTypes.GUI_DESIGNER_FORM)) { return true; } PsiMethod method = PsiTreeUtil.getParentOfType(t.getElement(), PsiMethod.class); if (method != null && method.getName().equals(AsmCodeGenerator.SETUP_METHOD_NAME)) { return true; } return false; } }); } catch (IndexNotReadyException e) { return false; } }
private File getSourceFileForClass(String className) { return ApplicationManager.getApplication() .runReadAction( (Computable<File>) () -> { try { PsiClass psiClass = JavaPsiFacade.getInstance(project) .findClass(className, GlobalSearchScope.projectScope(project)); if (psiClass == null) { return null; } return VfsUtilCore.virtualToIoFile( psiClass.getContainingFile().getVirtualFile()); } catch (IndexNotReadyException ignored) { // We're in dumb mode. Abort! Abort! return null; } }); }
/** * Finds all fragment definition across files in the project * * @return a list of known fragment definitions, or an empty list if the index is not yet ready */ public List<JSGraphQLFragmentDefinitionPsiElement> getKnownFragmentDefinitions() { try { final List<JSGraphQLFragmentDefinitionPsiElement> fragmentDefinitions = Lists.newArrayList(); PsiSearchHelper.SERVICE.getInstance(myProject).processElementsWithWord((psiElement, offsetInElement) -> { if (psiElement.getNode().getElementType() == JSGraphQLTokenTypes.KEYWORD && psiElement.getParent() instanceof JSGraphQLFragmentDefinitionPsiElement) { final JSGraphQLFragmentDefinitionPsiElement fragmentDefinition = (JSGraphQLFragmentDefinitionPsiElement) psiElement.getParent(); final String fragmentName = fragmentDefinition.getName(); if (fragmentName != null) { fragmentDefinitions.add(fragmentDefinition); } } return true; }, searchScope, "fragment", UsageSearchContext.IN_CODE, true, true); return fragmentDefinitions; } catch (IndexNotReadyException e) { // can't search yet (e.g. during project startup) } return Collections.emptyList(); }
private void visitParentReference(PsiElement parent) { if (parent instanceof PsiJavaCodeReferenceElement && !(parent.getParent() instanceof PsiJavaCodeReferenceElement) && !((PsiJavaCodeReferenceElement)parent).isQualified()) { PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)parent; JavaResolveResult result; try { result = ref.advancedResolve(true); } catch (IndexNotReadyException e) { return; } myHolder.add(HighlightUtil.checkReference(ref, result, myFile, myLanguageLevel)); if (myRefCountHolder != null) { myRefCountHolder.registerReference(ref, result); } } }
@Override public void visitNewExpression(PsiNewExpression expression) { myHolder.add(HighlightUtil.checkUnhandledExceptions(expression, null)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkAnonymousInheritFinal(expression)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkQualifiedNew(expression)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkCreateInnerClassFromStaticContext(expression)); if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkTypeParameterInstantiation(expression)); try { if (!myHolder.hasErrorResults()) HighlightMethodUtil.checkNewExpression(expression, myHolder, myJavaSdkVersion); } catch (IndexNotReadyException ignored) { } if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkEnumInstantiation(expression)); if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkGenericArrayCreation(expression, expression.getType())); if (!myHolder.hasErrorResults()) registerConstructorCall(expression); if (!myHolder.hasErrorResults()) visitExpression(expression); }
public static HighlightInfo checkUnreachableStatement(PsiCodeBlock codeBlock) { if (codeBlock == null) return null; // do not compute constant expressions for if() statement condition // see JLS 14.20 Unreachable Statements try { final ControlFlow controlFlow = getControlFlowNoConstantEvaluate(codeBlock); final PsiElement unreachableStatement = ControlFlowUtil.getUnreachableStatement(controlFlow); if (unreachableStatement != null) { String description = JavaErrorMessages.message("unreachable.statement"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(unreachableStatement).descriptionAndTooltip(description).create(); } } catch (AnalysisCanceledException e) { // incomplete code } catch (IndexNotReadyException ignored) { } return null; }
public ApplyAction() { super(CommonBundle.getApplyButtonText()); final Runnable updateRequest = new Runnable() { public void run() { if (!SingleConfigurableEditor.this.isShowing()) return; try { ApplyAction.this.setEnabled(myConfigurable != null && myConfigurable.isModified()); } catch (IndexNotReadyException ignored) { } addUpdateRequest(this); } }; // invokeLater necessary to make sure dialog is already shown so we calculate modality state correctly. SwingUtilities.invokeLater(new Runnable() { public void run() { addUpdateRequest(updateRequest); } }); }
@Override public void actionPerformed(AnActionEvent e) { final Editor editor = PlatformDataKeys.EDITOR.getData(e.getDataContext()); final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); if (editor == null || project == null) return; String commandName = getTemplatePresentation().getText(); if (commandName == null) commandName = ""; CommandProcessor.getInstance().executeCommand( project, new Runnable() { @Override public void run() { PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); try { HighlightUsagesHandler.invoke(project, editor, psiFile); } catch (IndexNotReadyException ex) { DumbService.getInstance(project).showDumbModeNotification(ActionsBundle.message("action.HighlightUsagesInFile.not.ready")); } } }, commandName, null ); }
@Nullable("For the case the search has been cancelled") protected PsiElement[] searchDefinitions(final PsiElement element) { final PsiElement[][] result = new PsiElement[1][]; if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { try { result[0] = DefinitionsSearch.search(element).toArray(PsiElement.EMPTY_ARRAY); } catch (IndexNotReadyException e) { dumbModeNotification(element); result[0] = null; } } }, SEARCHING_FOR_IMPLEMENTATIONS, true, element.getProject())) { return null; } return result[0]; }
private void doExecute(PsiFile file, int offset) { final Info info; try { info = getInfoAt(myEditor, file, offset, myBrowseMode); } catch (IndexNotReadyException e) { showDumbModeNotification(myProject); return; } if (info == null) return; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (myDisposed || myEditor.isDisposed() || !myEditor.getComponent().isShowing()) return; showHint(info); } }); }
@Override public void doApplyInformationToEditor() { Runnable runnable; synchronized (this) { runnable = myRunnable; } if (runnable != null){ try { runnable.run(); } catch (IndexNotReadyException ignored) { } } if (InjectedLanguageManager.getInstance(myFile.getProject()).getTopLevelFile(myFile) == myFile) { clearFirstTimeFlag(myFile, myEditor, THE_FIRST_TIME); } }