WidgetState (@Nullable VirtualFile file, @Nullable WidgetState lastWidgetState, @Nullable VirtualFile lastFile) { Pair<VirtualFile, Boolean> suppressInfo = mySuppressInfoRef.getAndSet(null); if (myCurrentProgress != null && !myCurrentProgress.isCanceled()) { myCurrentProgress.cancel(); } if (file == null) { return WidgetState.HIDDEN; } WidgetStatus status = getWidgetStatus(getProject(), file); if (status == WidgetStatus.DISABLED) { return WidgetState.HIDDEN; } FileType fileType = file.getFileType(); Language language = fileType instanceof LanguageFileType ? ((LanguageFileType)fileType).getLanguage() : null; boolean isJsonFile = language instanceof JsonLanguage; if (DumbService.getInstance(getProject()).isDumb()) { return getDumbModeState(isJsonFile); } if (status == WidgetStatus.MAYBE_SUPPRESSED) { if (suppressInfo == null || !Comparing.equal(suppressInfo.first, file)) { myCurrentProgress = new EmptyProgressIndicator(); scheduleSuppressCheck(file, myCurrentProgress); // show 'loading' only when switching between files and previous state was not hidden, otherwise the widget will "jump" if (!Comparing.equal(lastFile, file) && lastWidgetState != null && lastWidgetState != WidgetState.HIDDEN) { return new WidgetState(JsonBundle.message("schema.widget.checking.state.tooltip"), JsonBundle.message("schema.widget.checking.state.text", isJsonFile ? JsonBundle.message("schema.widget.prefix.json.files") : JsonBundle.message("schema.widget.prefix.other.files")), false); } else { return WidgetState.NO_CHANGE; } } else if (Boolean.TRUE == suppressInfo.second) { return WidgetState.HIDDEN; } } return doGetWidgetState(file, isJsonFile); }