From 48bad00efe58c665c64238c17d013956b40859e2 Mon Sep 17 00:00:00 2001 From: maxfilatov Date: Sun, 5 Jun 2016 15:34:28 +0300 Subject: [PATCH] #18 prevent access to index while service is dumb --- phpuaca.iml | 2 +- src/com/phpuaca/util/PhpClassResolver.java | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/phpuaca.iml b/phpuaca.iml index c00c22b..fc6f1f4 100644 --- a/phpuaca.iml +++ b/phpuaca.iml @@ -7,7 +7,7 @@ - + diff --git a/src/com/phpuaca/util/PhpClassResolver.java b/src/com/phpuaca/util/PhpClassResolver.java index 967ad36..e1af13f 100644 --- a/src/com/phpuaca/util/PhpClassResolver.java +++ b/src/com/phpuaca/util/PhpClassResolver.java @@ -1,5 +1,6 @@ package com.phpuaca.util; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; @@ -31,13 +32,15 @@ public PhpClass resolveByClassConstantReference(@NotNull ClassConstantReference @Nullable public PhpClass resolveByClassStringLiteralExpression(@NotNull StringLiteralExpression stringLiteralExpression) { - String className = stringLiteralExpression.getContents(); - if (!className.isEmpty()) { - className = className.replace("\\\\", "\\"); - Project project = stringLiteralExpression.getProject(); - Collection phpClasses = PhpIndex.getInstance(project).getAnyByFQN(className); - if (!phpClasses.isEmpty()) { - return phpClasses.iterator().next(); + Project project = stringLiteralExpression.getProject(); + if (!DumbService.getInstance(project).isDumb()) { + String className = stringLiteralExpression.getContents(); + if (!className.isEmpty()) { + className = className.replace("\\\\", "\\"); + Collection phpClasses = PhpIndex.getInstance(project).getAnyByFQN(className); + if (!phpClasses.isEmpty()) { + return phpClasses.iterator().next(); + } } }