mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Added check for consistence of the white space strategies added in a single bulk
This commit is contained in:
+8
-4
@@ -37,8 +37,12 @@ public class CompositeWhiteSpaceFormattingStrategy implements WhiteSpaceFormatti
|
||||
private final List<WhiteSpaceFormattingStrategy> myStrategies = new ArrayList<WhiteSpaceFormattingStrategy>();
|
||||
private boolean myReplaceDefaultStrategy;
|
||||
|
||||
public CompositeWhiteSpaceFormattingStrategy(@NotNull Collection<WhiteSpaceFormattingStrategy> strategies) {
|
||||
myStrategies.addAll(strategies);
|
||||
public CompositeWhiteSpaceFormattingStrategy(@NotNull Collection<WhiteSpaceFormattingStrategy> strategies)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
for (WhiteSpaceFormattingStrategy strategy : strategies) {
|
||||
addStrategy(strategy);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,9 +68,9 @@ public class CompositeWhiteSpaceFormattingStrategy implements WhiteSpaceFormatti
|
||||
return myReplaceDefaultStrategy;
|
||||
}
|
||||
|
||||
public void addStrategy(@NotNull WhiteSpaceFormattingStrategy strategy) throws IllegalStateException {
|
||||
public void addStrategy(@NotNull WhiteSpaceFormattingStrategy strategy) throws IllegalArgumentException {
|
||||
if (myReplaceDefaultStrategy && strategy.replaceDefaultStrategy()) {
|
||||
throw new IllegalStateException(String.format(
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Can't combine strategy '%s' with already registered strategies (%s). Reason: given strategy is marked to replace "
|
||||
+ "all existing strategies but strategy with such characteristics is already registered", strategy, myStrategies
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user