void addPropertiesProposals(String text, String startsWith, AppRegistration appRegistration, Set<String> alreadyPresentOptions, List<CompletionProposal> collector, int detailLevel){ Resource metadataResource = appRegistry.getAppMetadataResource(appRegistration); // For whitelisted properties, use their simple name if (metadataResource != null) { CompletionProposal.Factory proposals = CompletionProposal.expanding(text); for (ConfigurationMetadataProperty property : metadataResolver.listProperties(metadataResource)) { String name = property.getName(); if (!alreadyPresentOptions.contains(name) && name.startsWith(startsWith)) { collector.add(proposals .withSeparateTokens("--" + property.getName() + "=", property.getShortDescription())); } } // For other properties (including WL'ed in full form), use their id if (detailLevel > 1) { for (ConfigurationMetadataProperty property : metadataResolver.listProperties(metadataResource, true)) { String id = property.getId(); if (!alreadyPresentOptions.contains(id) && id.startsWith(startsWith)) { collector.add(proposals .withSeparateTokens("--" + property.getId() + "=", property.getShortDescription())); } } } } }
@Override public boolean addProposals(String text, StreamDefinition parseResult, int detailLevel, List<CompletionProposal> collector) { if (text.isEmpty() || !text.endsWith(" ")) { return false; } StreamAppDefinition lastApp = parseResult.getDeploymentOrderIterator().next(); // Consider "bar | foo". If there is indeed a sink named foo in the registry, // "foo" may also be a processor, in which case we can continue boolean couldBeASink = appRegistry.find(lastApp.getName(), ApplicationType.sink) != null; if (couldBeASink) { boolean couldBeAProcessor = appRegistry.find(lastApp.getName(), ApplicationType.processor) != null; if (!couldBeAProcessor) { return false; } } CompletionProposal.Factory proposals = CompletionProposal.expanding(text); for (AppRegistration appRegistration : appRegistry.findAll()) { if (appRegistration.getType() == ApplicationType.processor || appRegistration.getType() == ApplicationType.sink) { String expansion = CompletionUtils.maybeQualifyWithLabel(appRegistration.getName(), parseResult); collector.add(proposals.withSeparateTokens("| " + expansion, "Continue stream definition with a " + appRegistration.getType())); } } return false; } }
@Override public void addProposals(String dsl, CheckPointedParseException exception, int detailLevel, List<CompletionProposal> proposals) { CompletionProposal.Factory completionFactory = CompletionProposal.expanding(dsl); for (AppRegistration app : this.registry.findAll()) { if (app.getType() == ApplicationType.task) { proposals.add(completionFactory.withSeparateTokens(app.getName(), "Choose a task app")); } } }
@Override public void addProposals(String dsl, CheckPointedParseException exception, int detailLevel, List<CompletionProposal> collector) { StreamDefinition streamDefinition = new StreamDefinition("__dummy", exception.getExpressionStringUntilCheckpoint()); CompletionProposal.Factory proposals = CompletionProposal.expanding(dsl); // We only support full streams at the moment, so completions can only be // processor or sink for (AppRegistration appRegistration : appRegistry.findAll()) { if (appRegistration.getType() == ApplicationType.processor || appRegistration.getType() == ApplicationType.sink) { String expansion = CompletionUtils.maybeQualifyWithLabel(appRegistration.getName(), streamDefinition); collector.add(proposals.withSeparateTokens(expansion, "Continue stream definition with a " + appRegistration.getType())); } } } }
@Override public void addProposals(String dsl, CheckPointedParseException exception, int detailLevel, List<CompletionProposal> collector) { StreamDefinition streamDefinition = new StreamDefinition("__dummy", exception.getExpressionStringUntilCheckpoint()); CompletionProposal.Factory proposals = CompletionProposal.expanding(dsl); for (AppRegistration appRegistration : appRegistryService.findAll()) { if (appRegistration.getType() == ApplicationType.app) { String expansion = CompletionUtils.maybeQualifyWithLabel(appRegistration.getName(), streamDefinition); collector.add(proposals.withSeparateTokens(expansion, "Continue stream definition with a " + appRegistration.getType())); } } } }
@Override public void addProposals(String dsl, CheckPointedParseException exception, int detailLevel, List<CompletionProposal> proposals) { CompletionProposal.Factory completionFactory = CompletionProposal.expanding(dsl); for (AppRegistration appRegistration : appRegistry.findAll()) { if (appRegistration.getType() == ApplicationType.processor || appRegistration.getType() == ApplicationType.sink) { proposals.add(completionFactory.withSeparateTokens(appRegistration.getName(), "Wire destination into a " + appRegistration.getType() + " app")); } } }
@Override public void addProposals(String dsl, IllegalArgumentException exception, int detailLevel, List<CompletionProposal> proposals) { CompletionProposal.Factory completionFactory = CompletionProposal.expanding(dsl); for (AppRegistration app : this.registry.findAll()) { if (app.getType() == ApplicationType.source || app.getType() == ApplicationType.app) { proposals.add(completionFactory.withSeparateTokens(app.getName(), "Start with a source app or an unbounded streaming app")); } } }
/** * Add a suffix as a new token, that is, make sure there is a space before it. * <p> * A space is not appended if this is the very first token. * * @param suffix the suffix to add * @return a new completion proposal */ public CompletionProposal withSeparateTokens(String suffix) { return withSeparateTokens(suffix, null); } }