Skip to content

Commit

Permalink
#18 prevent access to index while service is dumb
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfilatov committed Jun 5, 2016
1 parent 1a4f91b commit 48bad00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion phpuaca.iml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/out" />
</content>
<orderEntry type="jdk" jdkName="PhpStorm PS-145.1616.3" jdkType="IDEA JDK" />
<orderEntry type="jdk" jdkName="PhpStorm PS-145.258.2" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" scope="PROVIDED" name="php" level="project" />
<orderEntry type="library" exported="" scope="PROVIDED" name="php-openapi" level="project" />
Expand Down
17 changes: 10 additions & 7 deletions src/com/phpuaca/util/PhpClassResolver.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<PhpClass> 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<PhpClass> phpClasses = PhpIndex.getInstance(project).getAnyByFQN(className);
if (!phpClasses.isEmpty()) {
return phpClasses.iterator().next();
}
}
}

Expand Down

0 comments on commit 48bad00

Please sign in to comment.