.asList(CompletionUtils.determinePotentialTypes(lastApp, streamDefinition.getAppDefinitions().size() > 1)); if (validTypesAtThisPosition.contains(appRegistration.getType()) && !alreadyTyped.equals(candidateName) && candidateName.startsWith(alreadyTyped)) { String expansion = CompletionUtils.maybeQualifyWithLabel(appRegistration.getName(), streamDefinition);
@Override public boolean addProposals(String text, StreamDefinition streamDefinition, int detailLevel, List<CompletionProposal> collector) { StreamAppDefinition lastApp = streamDefinition.getDeploymentOrderIterator().next(); AppRegistration appRegistration = this.collectorSupport.findAppRegistration(lastApp.getName(), CompletionUtils.determinePotentialTypes(lastApp,streamDefinition.getAppDefinitions().size() > 1)); if (appRegistration != null) { Set<String> alreadyPresentOptions = new HashSet<>(lastApp.getProperties().keySet()); this.collectorSupport.addPropertiesProposals(text, "", appRegistration, alreadyPresentOptions, collector, detailLevel); } return false; } }
@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; } }
List<ConfigurationMetadataProperty> whiteListedProps = metadataResolver.listProperties(metadataResource); for (ConfigurationMetadataProperty property : allProps) { if (CompletionUtils.isMatchingProperty(propertyName, property, whiteListedProps)) { for (ValueHintProvider valueHintProvider : valueHintProviders) { List<ValueHint> valueHints = valueHintProvider.generateValueHints(property, classLoader);
@Override public boolean addProposals(String text, StreamDefinition parseResult, int detailLevel, List<CompletionProposal> collector) { Set<String> propertyNames = new HashSet<>( parseResult.getDeploymentOrderIterator().next().getProperties().keySet()); propertyNames.removeAll(CompletionUtils.IMPLICIT_PARAMETER_NAMES); if (text.endsWith(" ") || propertyNames.isEmpty()) { return false; } String propertyName = recoverPropertyName(text); StreamAppDefinition lastApp = parseResult.getDeploymentOrderIterator().next(); String alreadyTyped = lastApp.getProperties().get(propertyName); AppRegistration lastAppRegistration = this.collectorSupport.findAppRegistration(lastApp.getName(), CompletionUtils.determinePotentialTypes(lastApp, parseResult.getAppDefinitions().size() > 1)); if (lastAppRegistration != null) { return this.collectorSupport.addAlreadyTypedValueHintsProposals(text, lastAppRegistration, collector, propertyName, valueHintProviders, alreadyTyped); } return false; }
@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())); } } } }
void addValueHintsProposals(final String dsl, AppRegistration appRegistration, final List<CompletionProposal> collector, final String propertyName, final ValueHintProvider[] valueHintProviders){ final Resource metadataResource = this.appRegistry.getAppMetadataResource(appRegistration); if (metadataResource != null) { final URLClassLoader classLoader = metadataResolver.createAppClassLoader(metadataResource); this.doWithClassLoader(classLoader, () -> { CompletionProposal.Factory proposals = CompletionProposal.expanding(dsl); List<ConfigurationMetadataProperty> whiteList = metadataResolver.listProperties(metadataResource); for (ConfigurationMetadataProperty property : metadataResolver.listProperties(metadataResource, true)) { if (CompletionUtils.isMatchingProperty(propertyName, property, whiteList)) { for (ValueHintProvider valueHintProvider : valueHintProviders) { for (ValueHint valueHint : valueHintProvider.generateValueHints(property, classLoader)) { collector.add(proposals.withSuffix(String.valueOf(valueHint.getValue()), valueHint.getShortDescription())); } } } } return null; }); } }
@Override public void addProposals(String dsl, CheckPointedParseException exception, int detailLevel, List<CompletionProposal> collector) { String safe = exception.getExpressionStringUntilCheckpoint(); StreamDefinition streamDefinition = new StreamDefinition("__dummy", safe); StreamAppDefinition lastApp = streamDefinition.getDeploymentOrderIterator().next(); AppRegistration appRegistration = this.collectorSupport.findAppRegistration(lastApp.getName(), CompletionUtils.determinePotentialTypes(lastApp, streamDefinition.getAppDefinitions().size() > 1)); if (appRegistration != null) { Set<String> alreadyPresentOptions = new HashSet<>(lastApp.getProperties().keySet()); this.collectorSupport.addPropertiesProposals(safe, "", appRegistration, alreadyPresentOptions, collector, detailLevel); } } }
@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())); } } } }
private AppRegistration lookupLastApp(CheckPointedParseException exception) { String safe = exception.getExpressionStringUntilCheckpoint(); StreamDefinition streamDefinition = new StreamDefinition("__dummy", safe); StreamAppDefinition lastApp = streamDefinition.getDeploymentOrderIterator().next(); return this.collectorSupport.findAppRegistration(lastApp.getName(), CompletionUtils.determinePotentialTypes(lastApp, streamDefinition.getAppDefinitions().size() > 1)); }
@Override public void addProposals(String dsl, CheckPointedParseException exception, int detailLevel, List<CompletionProposal> collector) { String safe = exception.getExpressionStringUntilCheckpoint(); StreamDefinition streamDefinition = new StreamDefinition("__dummy", safe); StreamAppDefinition lastApp = streamDefinition.getDeploymentOrderIterator().next(); AppRegistration appRegistration = this.collectorSupport.findAppRegistration(lastApp.getName(), CompletionUtils.determinePotentialTypes(lastApp, streamDefinition.getAppDefinitions().size() > 1)); if (appRegistration != null) { String startsWith = ProposalsCollectorSupportUtils.computeStartsWith(exception); Set<String> alreadyPresentOptions = new HashSet<>(lastApp.getProperties().keySet()); this.collectorSupport.addPropertiesProposals(safe, startsWith, appRegistration, alreadyPresentOptions, collector, detailLevel); } } }