diff --git a/cli/src/main/java/org/jboss/as/cli/impl/AttributeNamePathCompleter.java b/cli/src/main/java/org/jboss/as/cli/impl/AttributeNamePathCompleter.java index 88f01ea937e..ac42a184f06 100644 --- a/cli/src/main/java/org/jboss/as/cli/impl/AttributeNamePathCompleter.java +++ b/cli/src/main/java/org/jboss/as/cli/impl/AttributeNamePathCompleter.java @@ -236,9 +236,11 @@ public int complete(String buffer, List candidates, final ModelNode desc return -1; } final Collection foundCandidates = handler.getCandidates(descr, writeOnly); + if(foundCandidates.isEmpty()) { return -1; } + candidates.addAll(foundCandidates); return handler.getCandidateIndex(); } @@ -349,6 +351,11 @@ public Collection getCandidates(ModelNode attrsDescr, boolean writeOnly) candidateIndex += chunk.length(); } candidates.add("["); + }else if (modelType.equals(ModelType.STRING)) { + if (candidates.isEmpty()) { + candidateIndex += chunk.length(); + } + candidates.add(""); } } } diff --git a/cli/src/main/java/org/jboss/as/cli/operation/OperationRequestCompleter.java b/cli/src/main/java/org/jboss/as/cli/operation/OperationRequestCompleter.java index bff335b74bd..6aada8778a6 100644 --- a/cli/src/main/java/org/jboss/as/cli/operation/OperationRequestCompleter.java +++ b/cli/src/main/java/org/jboss/as/cli/operation/OperationRequestCompleter.java @@ -40,7 +40,6 @@ import org.jboss.as.cli.parsing.StateParser.SubstitutedLine; import org.jboss.logging.Logger; - /** * * @author Alexey Loubyansky @@ -411,6 +410,7 @@ private int completeWithValueCompleter(CommandContext ctx, ParsedCommandLine par final String normalizedChunk = chunk == null ? "" : chunk; int valueResult = valueCompleter.complete(ctx, normalizedChunk, normalizedChunk.length(), candidates); + // No proposition. if (valueResult < 0) { return valueResult; @@ -418,13 +418,13 @@ private int completeWithValueCompleter(CommandContext ctx, ParsedCommandLine par // Implies a single candidate to inline, the value is complete. // propose the property separator if more properties to come // or the propertyListEnd if no more properties. - if (suggestionEqualsUserEntry(candidates, chunk, valueResult)) { + if (suggestionEqualsUserEntry(candidates, chunk, valueResult) || areIncludedCandidatesForSpecificValueTypes(candidates)) { final CommandLineFormat format = parsedCmd.getFormat(); if (format != null) { for (CommandArgument arg : allArgs) { try { if (arg.canAppearNext(ctx)) { - candidates.set(0, "" + format.getPropertySeparator()); + candidates.add("" + format.getPropertySeparator()); return buffer.length(); } } catch (CommandFormatException e) { @@ -432,7 +432,7 @@ private int completeWithValueCompleter(CommandContext ctx, ParsedCommandLine par } } // inline the end of properties. - candidates.set(0, format.getPropertyListEnd()); + candidates.add(format.getPropertyListEnd()); // at the end of the input. return buffer.length(); } @@ -730,16 +730,31 @@ private SegmentParsingInitialState.SegmentParsingCallbackHandler parseLastSegmen } private boolean suggestionEqualsUserEntry(List candidates, String chunk, int suggestionOffset) { + if (chunk == null || candidates.size() != 1) { return false; } - if (suggestionOffset > 0) { + if (suggestionOffset > 0 && candidates.get(0)!="") { // user entry before suggestionOffset is always the same - compare only part after offset return chunk.substring(suggestionOffset).equals(candidates.get(0)); } else { - return chunk.equals(candidates.get(0)); + if(chunk.equals(candidates.get(0))){ + candidates.clear(); + return true; + } + return false; + } + } + + boolean areIncludedCandidatesForSpecificValueTypes(List candidates){ + if(candidates.contains("[") || candidates.contains(".")){ + return true; + }else if(candidates.contains("")){ + candidates.clear(); + return true; } + return false; } protected CommandLineCompleter getValueCompleter(CommandContext ctx, Iterable allArgs, final String argName) { diff --git a/cli/src/main/java/org/jboss/as/cli/operation/impl/DefaultOperationCandidatesProvider.java b/cli/src/main/java/org/jboss/as/cli/operation/impl/DefaultOperationCandidatesProvider.java index da69207dcae..f7506dc61a1 100644 --- a/cli/src/main/java/org/jboss/as/cli/operation/impl/DefaultOperationCandidatesProvider.java +++ b/cli/src/main/java/org/jboss/as/cli/operation/impl/DefaultOperationCandidatesProvider.java @@ -444,7 +444,7 @@ protected List getPropertiesFromPropList(List propLis if(ctx.getParsedCommandLine().getLastParsedPropertyValue() == null) { radical = ctx.getParsedCommandLine().getLastParsedPropertyName(); //Check if the property is completely specified and is negated - if(ctx.getParsedCommandLine().isLastPropertyNegated()) { + if(ctx.getParsedCommandLine().isLastPropertyNegated() || radical!=null) { for (Property prop : propList) { if(radical.equals(prop.getName())){ radical = null; diff --git a/cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java b/cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java index eadab8c82d4..bc67b7cf077 100644 --- a/cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java +++ b/cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java @@ -272,8 +272,8 @@ public void leavingState(ParsingContext ctx) throws CommandFormatException { // property value (e.g. a closing } or ], or " is missing) and it's not // really a property separator. format.isPropertySeparator(ctx.getCharacter()) && ctx.getError() == null) { - handler.propertySeparator(ctx.getLocation()); - } + handler.propertySeparator(ctx.getLocation()); + } buffer.setLength(0); name = null;