[Formatter] Provided ability to skip building injected blocks by setting AbstractBlock "myBuildInjectedBlocks" flag.

[JavaFormatter] If this flag is set no "InjectedLanguageUtil.hasInjections" check will be performed, which dramatically improves performance of formatter-based indent detector.
This commit is contained in:
Yaroslav Lepenkin
2015-06-15 15:02:40 +03:00
parent 77a8d4cee3
commit 3972b9b3d4
4 changed files with 28 additions and 4 deletions
@@ -176,7 +176,8 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
if (isStatement(child, child.getTreeParent())) {
return new CodeBlockBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
}
if (child instanceof PsiComment &&
if (isBuildInjectedBlocks() &&
child instanceof PsiComment &&
child instanceof PsiLanguageInjectionHost &&
InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)child)) {
return new CommentWithInjectionBlock(child, wrap, alignment, indent, settings, javaSettings);