diff options
author | Tor Norbye <tnorbye@google.com> | 2013-08-07 11:11:08 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-08-07 11:11:08 -0700 |
commit | 6739a8f0977b70ddc8a8283b169902da3f2eecb3 (patch) | |
tree | 5c5573c2ac01544f02d9318671aa558769726289 /platform/lang-impl/src/com/intellij/formatting | |
parent | c1ace1f7e1e49c81bb4b75377c99f07be340abfe (diff) | |
download | idea-6739a8f0977b70ddc8a8283b169902da3f2eecb3.tar.gz |
Snapshot af729d01433bb5bbd6ca93c0fdf9778b36d624ce from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I214dd066d0d27444a26166c0eae1a5aaf3705d49
Diffstat (limited to 'platform/lang-impl/src/com/intellij/formatting')
7 files changed, 36 insertions, 34 deletions
diff --git a/platform/lang-impl/src/com/intellij/formatting/AbstractBlockWrapper.java b/platform/lang-impl/src/com/intellij/formatting/AbstractBlockWrapper.java index 82e84d006651..d2a9b2b33da7 100644 --- a/platform/lang-impl/src/com/intellij/formatting/AbstractBlockWrapper.java +++ b/platform/lang-impl/src/com/intellij/formatting/AbstractBlockWrapper.java @@ -505,7 +505,7 @@ public abstract class AbstractBlockWrapper { return myParent.findFirstIndentedParent(); } - public void setIndent(final IndentImpl indent) { + public void setIndent(@Nullable final IndentImpl indent) { myIndent = indent; } diff --git a/platform/lang-impl/src/com/intellij/formatting/CompositeBlockWrapper.java b/platform/lang-impl/src/com/intellij/formatting/CompositeBlockWrapper.java index 3fc4e9a14d45..7f56fa495ff3 100644 --- a/platform/lang-impl/src/com/intellij/formatting/CompositeBlockWrapper.java +++ b/platform/lang-impl/src/com/intellij/formatting/CompositeBlockWrapper.java @@ -33,7 +33,7 @@ public class CompositeBlockWrapper extends AbstractBlockWrapper{ * @param whiteSpace white space before the block * @param parent wrapped block parent */ - public CompositeBlockWrapper(final Block block, final WhiteSpace whiteSpace, final CompositeBlockWrapper parent) { + public CompositeBlockWrapper(final Block block, final WhiteSpace whiteSpace, @Nullable final CompositeBlockWrapper parent) { super(block, whiteSpace, parent, block.getTextRange()); } diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java index a21252764bee..4f8034a59384 100644 --- a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java +++ b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java @@ -27,7 +27,6 @@ import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.util.TextRange; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; -import com.intellij.psi.formatter.DocumentBasedFormattingModel; import com.intellij.util.ui.UIUtil; import gnu.trove.TIntObjectHashMap; import org.jetbrains.annotations.NotNull; @@ -227,8 +226,8 @@ class FormatProcessor { myCurrentState.setNext(adjustState); } else { - formatWithoutRealModifications(sequentially); - performModifications(model, sequentially); + formatWithoutRealModifications(false); + performModifications(model, false); } } @@ -898,7 +897,7 @@ class FormatProcessor { } @Nullable - private LeafBlockWrapper getPrevBlock(final LeafBlockWrapper result) { + private LeafBlockWrapper getPrevBlock(@Nullable final LeafBlockWrapper result) { if (result != null) { return result.getPreviousBlock(); } @@ -1015,7 +1014,7 @@ class FormatProcessor { } } - private static int getAlignOffsetBefore(final Alignment alignment, @Nullable final LeafBlockWrapper blockAfter) { + private static int getAlignOffsetBefore(@Nullable final Alignment alignment, @Nullable final LeafBlockWrapper blockAfter) { if (alignment == null) return -1; final LeafBlockWrapper alignRespBlock = ((AlignmentImpl)alignment).getOffsetRespBlockBefore(blockAfter); if (alignRespBlock != null) { diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatterEx.java b/platform/lang-impl/src/com/intellij/formatting/FormatterEx.java index 6010bdd1a20e..e9e8c130a6f4 100644 --- a/platform/lang-impl/src/com/intellij/formatting/FormatterEx.java +++ b/platform/lang-impl/src/com/intellij/formatting/FormatterEx.java @@ -118,7 +118,7 @@ public abstract class FormatterEx{ public abstract void setProgressTask(@NotNull FormattingProgressTask progressIndicator); public interface IndentInfoStorage { - void saveIndentInfo(IndentInfo info, int startOffset); + void saveIndentInfo(@Nullable IndentInfo info, int startOffset); IndentInfo getIndentInfo(int startOffset); } diff --git a/platform/lang-impl/src/com/intellij/formatting/InitialInfoBuilder.java b/platform/lang-impl/src/com/intellij/formatting/InitialInfoBuilder.java index 4d4c7ac84aab..7274c79421aa 100644 --- a/platform/lang-impl/src/com/intellij/formatting/InitialInfoBuilder.java +++ b/platform/lang-impl/src/com/intellij/formatting/InitialInfoBuilder.java @@ -43,15 +43,15 @@ class InitialInfoBuilder { private final Map<AbstractBlockWrapper, Block> myResult = new THashMap<AbstractBlockWrapper, Block>(); - private final FormattingDocumentModel myModel; - private final FormatTextRanges myAffectedRanges; - private final int myPositionOfInterest; + private final FormattingDocumentModel myModel; + private final FormatTextRanges myAffectedRanges; + private final int myPositionOfInterest; @NotNull - private final FormattingProgressCallback myProgressCallback; + private final FormattingProgressCallback myProgressCallback; private final CommonCodeStyleSettings.IndentOptions myOptions; private final Stack<State> myStates = new Stack<State>(); - + private WhiteSpace myCurrentWhiteSpace; private CompositeBlockWrapper myRootBlockWrapper; private LeafBlockWrapper myPreviousBlock; @@ -59,12 +59,11 @@ class InitialInfoBuilder { private LeafBlockWrapper myLastTokenBlock; private SpacingImpl myCurrentSpaceProperty; private ReadOnlyBlockInformationProvider myReadOnlyBlockInformationProvider; - - private final static boolean INLINE_TABS_ENABLED = "true".equalsIgnoreCase(System.getProperty("inline.tabs.enabled")); - private final static boolean DEBUG_ENABLED = false; + + private static final boolean INLINE_TABS_ENABLED = "true".equalsIgnoreCase(System.getProperty("inline.tabs.enabled")); private InitialInfoBuilder(final FormattingDocumentModel model, - final FormatTextRanges affectedRanges, + @Nullable final FormatTextRanges affectedRanges, final CommonCodeStyleSettings.IndentOptions options, final int positionOfInterest, @NotNull FormattingProgressCallback progressCallback) @@ -79,7 +78,7 @@ class InitialInfoBuilder { public static InitialInfoBuilder prepareToBuildBlocksSequentially(Block root, FormattingDocumentModel model, - final FormatTextRanges affectedRanges, + @Nullable final FormatTextRanges affectedRanges, final CommonCodeStyleSettings.IndentOptions options, int interestingOffset, @NotNull FormattingProgressCallback progressCallback) @@ -91,7 +90,7 @@ class InitialInfoBuilder { /** * Asks current builder to wrap one more remaining {@link Block code block} (if any). - * + * * @return <code>true</code> if all blocks are wrapped; <code>false</code> otherwise */ public boolean iteration() { @@ -164,13 +163,13 @@ class InitialInfoBuilder { myReadOnlyBlockInformationProvider = (ReadOnlyBlockInformationProvider)rootBlock; } if (isReadOnly) { - return processSimpleBlock(rootBlock, parent, isReadOnly, index, parentBlock); + return processSimpleBlock(rootBlock, parent, true, index, parentBlock); } final List<Block> subBlocks = rootBlock.getSubBlocks(); if (subBlocks.isEmpty() || myReadOnlyBlockInformationProvider != null && myReadOnlyBlockInformationProvider.isReadOnly(rootBlock)) { - final AbstractBlockWrapper wrapper = processSimpleBlock(rootBlock, parent, isReadOnly, index, parentBlock); + final AbstractBlockWrapper wrapper = processSimpleBlock(rootBlock, parent, false, index, parentBlock); if (!subBlocks.isEmpty()) { wrapper.setIndent((IndentImpl)subBlocks.get(0).getIndent()); } @@ -184,9 +183,9 @@ class InitialInfoBuilder { } private CompositeBlockWrapper buildCompositeBlock(final Block rootBlock, - final CompositeBlockWrapper parent, + @Nullable final CompositeBlockWrapper parent, final int index, - final WrapImpl currentWrapParent, + @Nullable final WrapImpl currentWrapParent, boolean rootBlockIsRightBlock) { final CompositeBlockWrapper wrappedRootBlock = new CompositeBlockWrapper(rootBlock, myCurrentWhiteSpace, parent); @@ -236,7 +235,9 @@ class InitialInfoBuilder { if (!state.readOnly) { try { subBlocks.set(childBlockIndex, null); // to prevent extra strong refs during model building - } catch (Throwable ex) {} // read-only blocks + } catch (Throwable ex) { + // read-only blocks + } } if (state.childBlockProcessed(block, wrapper)) { @@ -257,10 +258,10 @@ class InitialInfoBuilder { } private AbstractBlockWrapper processSimpleBlock(final Block rootBlock, - final CompositeBlockWrapper parent, + @Nullable final CompositeBlockWrapper parent, final boolean readOnly, final int index, - Block parentBlock) + @Nullable Block parentBlock) { LeafBlockWrapper result = doProcessSimpleBlock(rootBlock, parent, readOnly, index, parentBlock); myProgressCallback.afterWrappingBlock(result); @@ -268,10 +269,10 @@ class InitialInfoBuilder { } private LeafBlockWrapper doProcessSimpleBlock(final Block rootBlock, - final CompositeBlockWrapper parent, + @Nullable final CompositeBlockWrapper parent, final boolean readOnly, final int index, - Block parentBlock) + @Nullable Block parentBlock) { if (!INLINE_TABS_ENABLED && !myCurrentWhiteSpace.containsLineFeeds()) { myCurrentWhiteSpace.setForceSkipTabulationsUsage(true); diff --git a/platform/lang-impl/src/com/intellij/formatting/LeafBlockWrapper.java b/platform/lang-impl/src/com/intellij/formatting/LeafBlockWrapper.java index da1665510139..2b1b2f93a163 100644 --- a/platform/lang-impl/src/com/intellij/formatting/LeafBlockWrapper.java +++ b/platform/lang-impl/src/com/intellij/formatting/LeafBlockWrapper.java @@ -44,7 +44,7 @@ class LeafBlockWrapper extends AbstractBlockWrapper { * @param isReadOnly flag that indicates if target block is read-only */ public LeafBlockWrapper(final Block block, - CompositeBlockWrapper parent, + @Nullable CompositeBlockWrapper parent, WhiteSpace whiteSpaceBefore, FormattingDocumentModel model, CommonCodeStyleSettings.IndentOptions options, @@ -188,7 +188,7 @@ class LeafBlockWrapper extends AbstractBlockWrapper { return myParent.getChildOffset(this, options, this.getStartOffset()); } - public void setSpaceProperty(final SpacingImpl currentSpaceProperty) { + public void setSpaceProperty(@Nullable final SpacingImpl currentSpaceProperty) { mySpaceProperty = currentSpaceProperty; } diff --git a/platform/lang-impl/src/com/intellij/formatting/WrapImpl.java b/platform/lang-impl/src/com/intellij/formatting/WrapImpl.java index abbeecc597a4..0a63272bd04e 100644 --- a/platform/lang-impl/src/com/intellij/formatting/WrapImpl.java +++ b/platform/lang-impl/src/com/intellij/formatting/WrapImpl.java @@ -16,6 +16,8 @@ package com.intellij.formatting; +import org.jetbrains.annotations.Nullable; + import java.util.*; class WrapImpl extends Wrap { @@ -38,7 +40,7 @@ class WrapImpl extends Wrap { private static final Type[] myTypes = Type.values(); - public boolean isChildOf(final WrapImpl wrap, LeafBlockWrapper leaf) { + public boolean isChildOf(@Nullable final WrapImpl wrap, LeafBlockWrapper leaf) { if (getIgnoreParentWraps()) return false; if (leaf != null && myIgnoredWraps != null) { Collection<LeafBlockWrapper> leaves = myIgnoredWraps.get(wrap); @@ -61,7 +63,7 @@ class WrapImpl extends Wrap { * * @param parent parent wrap to register for the current wrap */ - void registerParent(WrapImpl parent) { + void registerParent(@Nullable WrapImpl parent) { if (parent == this) return; if (parent == null) return; if (parent.isChildOf(this, null)) return; @@ -109,7 +111,7 @@ class WrapImpl extends Wrap { * @param wrap target wrap * @param currentBlock target block for which given wrap should be ignored */ - public void ignoreParentWrap(final WrapImpl wrap, final LeafBlockWrapper currentBlock) { + public void ignoreParentWrap(@Nullable final WrapImpl wrap, final LeafBlockWrapper currentBlock) { if (myIgnoredWraps == null) { myIgnoredWraps = new HashMap<WrapImpl, Collection<LeafBlockWrapper>>(5); } @@ -133,7 +135,7 @@ class WrapImpl extends Wrap { return myFirstEntry != null && myFirstEntry == currentBlock; } - static enum Type{ + enum Type{ DO_NOT_WRAP, WRAP_AS_NEEDED, CHOP_IF_NEEDED, WRAP_ALWAYS } |