Skip to content

Commit 2be2426

Browse files
committed
add new isEnabledForIndex check, to not force re-indexing for new projects, after enabling plugin
1 parent d577306 commit 2be2426

11 files changed

+32
-10
lines changed

src/fr/adrienbrault/idea/symfony2plugin/Symfony2ProjectComponent.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,28 @@ public static boolean isEnabled(Project project) {
194194
return Settings.getInstance(project).pluginEnabled;
195195
}
196196

197+
/**
198+
* If plugin is not enabled on first project start/indexing we will never get a filled
199+
* index until a forced cache rebuild, we check also for vendor path
200+
*/
201+
public static boolean isEnabledForIndex(Project project) {
202+
203+
if(Settings.getInstance(project).pluginEnabled) {
204+
return true;
205+
}
206+
207+
if(VfsUtil.findRelativeFile(project.getBaseDir(), "vendor", "symfony") != null) {
208+
return true;
209+
}
210+
211+
// drupal8; this should not really here
212+
if(VfsUtil.findRelativeFile(project.getBaseDir(), "core", "vendor", "symfony") != null) {
213+
return true;
214+
}
215+
216+
return false;
217+
}
218+
197219
public static boolean isEnabled(@Nullable PsiElement psiElement) {
198220
return psiElement != null && isEnabled(psiElement.getProject());
199221
}

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/AnnotationRoutesStubIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public Map<String, Void> map(FileContent inputData) {
4747
final Map<String, Void> map = new THashMap<String, Void>();
4848

4949
PsiFile psiFile = inputData.getPsiFile();
50-
if(!Symfony2ProjectComponent.isEnabled(psiFile.getProject())) {
50+
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
5151
return map;
5252
}
5353

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/ContainerParameterStubIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public Map<String, String> map(FileContent inputData) {
4242
Map<String, String> map = new HashMap<String, String>();
4343

4444
PsiFile psiFile = inputData.getPsiFile();
45-
if(!Symfony2ProjectComponent.isEnabled(psiFile.getProject())) {
45+
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
4646
return map;
4747
}
4848

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/ServicesDefinitionStubIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public Map<String, String[]> map(FileContent inputData) {
4747
Map<String, String[]> map = new THashMap<String, String[]>();
4848

4949
PsiFile psiFile = inputData.getPsiFile();
50-
if(!Symfony2ProjectComponent.isEnabled(psiFile.getProject())) {
50+
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
5151
return map;
5252
}
5353
if (!isValidForIndex(inputData, psiFile)) {

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/ServicesTagStubIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Map<String, String[]> map(FileContent inputData) {
4848
Map<String, String[]> map = new THashMap<String, String[]>();
4949

5050
PsiFile psiFile = inputData.getPsiFile();
51-
if(!Symfony2ProjectComponent.isEnabled(psiFile.getProject())) {
51+
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
5252
return map;
5353
}
5454

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/TwigExtendsStubIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public Map<String, Void> map(FileContent inputData) {
4242
Map<String, Void> map = new THashMap<String, Void>();
4343

4444
PsiFile psiFile = inputData.getPsiFile();
45-
if(!Symfony2ProjectComponent.isEnabled(psiFile.getProject())) {
45+
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
4646
return map;
4747
}
4848

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/TwigIncludeStubIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public Map<String, Void> map(FileContent inputData) {
4444
final Map<String, Void> map = new THashMap<String, Void>();
4545

4646
PsiFile psiFile = inputData.getPsiFile();
47-
if(!Symfony2ProjectComponent.isEnabled(psiFile.getProject())) {
47+
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
4848
return map;
4949
}
5050

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/TwigMacroFromStubIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Map<String, Void> map(FileContent inputData) {
4343
final Map<String, Void> map = new THashMap<String, Void>();
4444

4545
PsiFile psiFile = inputData.getPsiFile();
46-
if(!Symfony2ProjectComponent.isEnabled(psiFile.getProject())) {
46+
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
4747
return map;
4848
}
4949

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/TwigMacroFunctionStubIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public Map<String, Void> map(FileContent inputData) {
4545
final Map<String, Void> map = new THashMap<String, Void>();
4646

4747
PsiFile psiFile = inputData.getPsiFile();
48-
if(!Symfony2ProjectComponent.isEnabled(psiFile.getProject())) {
48+
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
4949
return map;
5050
}
5151

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/YamlRoutesStubIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public Map<String, Void> map(FileContent inputData) {
4242
Map<String, Void> map = new THashMap<String, Void>();
4343

4444
PsiFile psiFile = inputData.getPsiFile();
45-
if(!Symfony2ProjectComponent.isEnabled(psiFile.getProject())) {
45+
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
4646
return map;
4747
}
4848

0 commit comments

Comments
 (0)