/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
if (isStatement(child, child.getTreeParent())) {
return new CodeBlockBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
}
- if (isBuildInjectedBlocks() &&
+ if (!isBuildIndentsOnly() &&
child instanceof PsiComment &&
child instanceof PsiLanguageInjectionHost &&
InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)child)) {
@Nullable
protected Wrap createChildWrap() {
- if (!isBuildInjectedBlocks()) {
- return null; //when detecting indent we do not care about wraps
- }
- return myWrapManager.createChildBlockWrap(this, getSettings(), this);
+ //when detecting indent we do not care about wraps
+ return isBuildIndentsOnly() ? null : myWrapManager.createChildBlockWrap(this, getSettings(), this);
}
@Nullable
@Nullable
protected Wrap arrangeChildWrap(final ASTNode child, Wrap defaultWrap) {
- if (!isBuildInjectedBlocks()) {
- return null; //when detecting indent we do not care about wraps
- }
- return myWrapManager.arrangeChildWrap(child, myNode, mySettings, myJavaSettings, defaultWrap, this);
+ //when detecting indent we do not care about wraps
+ return isBuildIndentsOnly() ? null : myWrapManager.arrangeChildWrap(child, myNode, mySettings, myJavaSettings, defaultWrap, this);
}
@NotNull
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.psi.formatter.common.AbstractBlock;
import com.intellij.psi.formatter.common.NewLineBlocksIterator;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
else {
return false;
}
-
+
+ if (block instanceof AbstractBlock) {
+ ((AbstractBlock)block).setBuildIndentsOnly(true);
+ }
List<Block> subBlocks = block.getSubBlocks();
block = subBlocks.isEmpty() ? null : subBlocks.get(0);
}
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private List<Block> mySubBlocks;
private Boolean myIncomplete;
- private boolean myBuildInjectedBlocks = true;
+ private boolean myBuildIndentsOnly = false;
protected AbstractBlock(@NotNull ASTNode node, @Nullable Wrap wrap, @Nullable Alignment alignment) {
myNode = node;
* Prevents from building injected blocks, which allows to build blocks faster
* Initially was made for formatting-based indent detector
*/
- protected void setBuildInjectedBlocks(boolean value) {
- myBuildInjectedBlocks = value;
+ public void setBuildIndentsOnly(boolean value) {
+ myBuildIndentsOnly = value;
}
- protected boolean isBuildInjectedBlocks() {
- return myBuildInjectedBlocks;
+ protected boolean isBuildIndentsOnly() {
+ return myBuildIndentsOnly;
}
@NotNull
private List<Block> buildInjectedBlocks() {
- if (!myBuildInjectedBlocks) {
+ if (myBuildIndentsOnly) {
return EMPTY;
}
if (!(this instanceof SettingsAwareBlock)) {
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.util.TextRange;
-import java.util.*;
-
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Stack;
public class NewLineBlocksIterator implements Iterator<Block> {
private final Document myDocument;
private void pushAll(Block current) {
if (current instanceof AbstractBlock) {
//building blocks as fast as possible
- ((AbstractBlock)current).setBuildInjectedBlocks(false);
+ ((AbstractBlock)current).setBuildIndentsOnly(true);
}
List<Block> blocks = current.getSubBlocks();