|
23 | 23 |
|
24 | 24 | import static com.igormaznitsa.jcp.removers.AbstractCommentRemover.makeCommentRemover; |
25 | 25 | import static com.igormaznitsa.jcp.utils.IOUtils.closeQuietly; |
26 | | -import static com.igormaznitsa.jcp.utils.PreprocessorUtils.findFirstActiveFileContainer; |
| 26 | +import static com.igormaznitsa.jcp.utils.PreprocessorUtils.findActiveFileInfoContainer; |
27 | 27 | import static java.util.Objects.requireNonNull; |
28 | 28 | import static java.util.Objects.requireNonNullElse; |
29 | 29 |
|
@@ -160,16 +160,20 @@ public String getLastReadString() { |
160 | 160 | return this.lastReadString; |
161 | 161 | } |
162 | 162 |
|
163 | | - public void pushExcludeIfData(final FileInfoContainer infoContainer, |
164 | | - final String excludeIfCondition, final int stringIndex) { |
| 163 | + public void pushExcludeIfData( |
| 164 | + final FileInfoContainer infoContainer, |
| 165 | + final String excludeIfCondition, |
| 166 | + final int stringIndex |
| 167 | + ) { |
165 | 168 | requireNonNull(infoContainer, "File info is null"); |
166 | 169 | requireNonNull(excludeIfCondition, "Condition is null"); |
167 | 170 |
|
168 | 171 | if (stringIndex < 0) { |
169 | 172 | throw new IllegalArgumentException("Unexpected string index [" + stringIndex + ']'); |
170 | 173 | } |
171 | 174 |
|
172 | | - deferredExcludeStack.push(new ExcludeIfInfo(infoContainer, excludeIfCondition, stringIndex)); |
| 175 | + this.deferredExcludeStack.push( |
| 176 | + new ExcludeIfInfo(infoContainer, excludeIfCondition, stringIndex)); |
173 | 177 | } |
174 | 178 |
|
175 | 179 | public ResettablePrinter getSelectedPrinter() { |
@@ -296,11 +300,6 @@ public boolean isIncludeStackEmpty() { |
296 | 300 | return includeStack.isEmpty(); |
297 | 301 | } |
298 | 302 |
|
299 | | - public boolean isOnlyRootOnStack() { |
300 | | - return includeStack.size() == 1; |
301 | | - } |
302 | | - |
303 | | - |
304 | 303 | private TextFileDataContainer cloneTopTextDataContainer() { |
305 | 304 | final TextFileDataContainer topElement = requireNonNull(includeStack.peek()); |
306 | 305 | return new TextFileDataContainer(topElement, |
@@ -553,7 +552,7 @@ public boolean saveBuffersToFile(final File outFile, final CommentRemoverType ke |
553 | 552 | } |
554 | 553 |
|
555 | 554 | if (wasSaved) { |
556 | | - findFirstActiveFileContainer(context).ifPresent(t -> t.getGeneratedResources().add(outFile)); |
| 555 | + findActiveFileInfoContainer(context).ifPresent(t -> t.getGeneratedResources().add(outFile)); |
557 | 556 | if (this.context.isKeepAttributes() && outFile.exists()) { |
558 | 557 | PreprocessorUtils.copyFileAttributes(this.getRootFileInfo().getSourceFile(), outFile); |
559 | 558 | } |
|
0 commit comments