From ef3981b162a8fd386ac85a40e6d18efb2f589f98 Mon Sep 17 00:00:00 2001 From: nsingh Date: Wed, 2 Aug 2017 10:51:00 -0700 Subject: [PATCH] Adding docs and some code cleanup --- .../reconcile/IProblemCollector.java | 18 +++++++++++++++--- .../ide/vscode/commons/util/ValueParser.java | 4 ++++ .../SchemaBasedYamlASTReconciler.java | 3 +-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/IProblemCollector.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/IProblemCollector.java index 7ee9dfe3d..eec0df9c1 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/IProblemCollector.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/IProblemCollector.java @@ -15,7 +15,21 @@ public interface IProblemCollector { void beginCollecting(); void endCollecting(); void accept(ReconcileProblem problem); - void checkPointCollecting(); + + /** + * Allows the problem collector to process problems that has been collected so + * far, BEFORE the end collecting. It is to handle cases where a subset of + * problems need to be processed or published in an "intermediate" phase during + * a collecting session, but prior to the final end collecting. For example, if + * a collection session in a reconcile engine wants to publish fast problems + * first before handling slow problems , this method allows the reconcile engine + * to notify the problem collector to process the fast problems first before + * starting with the slow ones. The reconcile engine, or whoever is calling the + * collector, is responsible for deciding when to call this checkpoint. + */ + default void checkPointCollecting() { + + } /** * Problem collector that simply ignores/discards anything passed to it. @@ -27,7 +41,5 @@ public interface IProblemCollector { } public void accept(ReconcileProblem problem) { } - public void checkPointCollecting() { - } }; } \ No newline at end of file diff --git a/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ValueParser.java b/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ValueParser.java index 35b218cd9..bd5685e89 100644 --- a/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ValueParser.java +++ b/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ValueParser.java @@ -23,6 +23,10 @@ public interface ValueParser { * that the String is not the format this parser expects. */ Object parse(String str) throws Exception; + + default boolean longRunning() { + return false; + } static ValueParser of(ValueParser x) { return x; diff --git a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java index b175c7a66..d68fea323 100644 --- a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java +++ b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java @@ -31,7 +31,6 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.Reconcile import org.springframework.ide.vscode.commons.languageserver.reconcile.ReconcileProblemImpl; import org.springframework.ide.vscode.commons.languageserver.reconcile.ReplacementQuickfix; import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion; -import org.springframework.ide.vscode.commons.util.EnumValueParser; import org.springframework.ide.vscode.commons.util.ExceptionUtil; import org.springframework.ide.vscode.commons.util.IntegerRange; import org.springframework.ide.vscode.commons.util.Log; @@ -198,7 +197,7 @@ public class SchemaBasedYamlASTReconciler implements YamlASTReconciler { SchemaContextAware parserProvider = typeUtil.getValueParser(type); if (parserProvider!=null) { parserProvider.safeWithContext(schemaContext).ifPresent(parser -> { - if (parser instanceof EnumValueParser && ((EnumValueParser) parser).longRunning()) { + if (parser.longRunning()) { slowDelayedConstraints.add(() -> { parse(ast, node, type, parser); });