GlobalSearchScope () { GlobalSearchScope superScope = super.getSearchScope(); String path = getScriptPath(); if (path == null) return superScope; VirtualFile scriptFile = LocalFileSystem.getInstance().findFileByPath(path); if (scriptFile == null) return superScope; GlobalSearchScope fileScope = GlobalSearchScope.fileScope(getProject(), scriptFile); if (superScope == null) return fileScope; return new DelegatingGlobalSearchScope(fileScope.union(superScope)) { @Override public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) { if (file1.equals(scriptFile)) return 1; if (file2.equals(scriptFile)) return -1; return super.compare(file1, file2); } }; }