forked from bazelbuild/intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: avoid scanning convenience symlink directories during initial i…
…mport (bazelbuild#6094) Prior to this change, IntelliJ excluded convenience symlinks by using the `addExcludeFolder` method. Its drawback was that it didn't work perfectly when the file didn't exist during exclusion. This might cause a race condition where some IntelliJ indexers detected new file creation in these directories while the exclusion mechanism hadn't detected the existence of the symlinks themselves. This issue is addressed by using 'exclusion patterns' instead of 'excluded folders'. Patterns do not require the files to actually exist. However, their drawback is that they will catch files named `bazel-bin` and `bazel-out` nested deep inside the directory hierarchy, not just the top-level ones. To address this, a project view setting has been added to disable the new behavior. Fixes bazelbuild#6082
- Loading branch information
Tomasz Pasternak
authored
Feb 21, 2024
1 parent
72ed436
commit 8b64eb5
Showing
6 changed files
with
123 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
base/src/com/google/idea/blaze/base/projectview/section/sections/BooleanSectionParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2024 The Bazel Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.idea.blaze.base.projectview.section.sections; | ||
|
||
import com.google.idea.blaze.base.projectview.parser.ParseContext; | ||
import com.google.idea.blaze.base.projectview.parser.ProjectViewParser; | ||
import com.google.idea.blaze.base.projectview.section.ScalarSection; | ||
import com.google.idea.blaze.base.projectview.section.ScalarSectionParser; | ||
import com.google.idea.blaze.base.projectview.section.SectionKey; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
class BooleanSectionParser | ||
extends ScalarSectionParser<Boolean> { | ||
private final String quickDocs; | ||
|
||
BooleanSectionParser(SectionKey<Boolean, ScalarSection<Boolean>> key, String quickDocs) { | ||
super(key, ':'); | ||
this.quickDocs = quickDocs; | ||
} | ||
|
||
@Override | ||
@Nullable | ||
protected Boolean parseItem(ProjectViewParser parser, ParseContext parseContext, String text) { | ||
if (text.equals("true")) { | ||
return true; | ||
} | ||
if (text.equals("false")) { | ||
return false; | ||
} | ||
String key = super.getSectionKey().getName(); | ||
parseContext.addError( | ||
"'" + key + "' must be set to 'true' or 'false' (e.g." | ||
+ " '" + key + ": true')"); | ||
return null; | ||
} | ||
|
||
@Override | ||
protected void printItem(StringBuilder sb, Boolean item) { | ||
sb.append(item); | ||
} | ||
|
||
@Override | ||
public ItemType getItemType() { | ||
return ItemType.Other; | ||
} | ||
|
||
@Override | ||
public String quickDocs() { | ||
return quickDocs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../com/google/idea/blaze/base/projectview/section/sections/UseExclusionPatternsSection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2024 The Bazel Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.idea.blaze.base.projectview.section.sections; | ||
|
||
import com.google.idea.blaze.base.projectview.section.ScalarSection; | ||
import com.google.idea.blaze.base.projectview.section.SectionKey; | ||
import com.google.idea.blaze.base.projectview.section.SectionParser; | ||
|
||
/** 'use_exclusion_pattern' section. */ | ||
public class UseExclusionPatternsSection { | ||
public static final SectionKey<Boolean, ScalarSection<Boolean>> KEY = | ||
SectionKey.of("use_exclusion_patterns"); | ||
|
||
public static final SectionParser PARSER = new BooleanSectionParser( | ||
KEY, | ||
""" | ||
Add an exclusion pattern for all directories that are supposed to be excluded from the project. | ||
It might significantly improve first import performance, but if your project contains files | ||
that are typically ignored (`bazel-bin`, `bazel-out`, `.ijwb` etc.) they will be excluded, even | ||
if they do noy lay in the root directory. In these cases, please disable exclusion patterns (set | ||
to false). By default the exclusion patterns are enabled. For more info please check | ||
https://www.jetbrains.com/help/idea/content-roots.html#exclude_folders | ||
"""); | ||
|
||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters