Fix PT-150487597
Don't type-check values with '@' placeholders in application yaml editor
This commit is contained in:
@@ -20,6 +20,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.ide.vscode.boot.metadata.IndexNavigator;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
@@ -265,8 +266,7 @@ public class ApplicationYamlASTReconciler implements YamlASTReconciler {
|
||||
|
||||
private void reconcile(ScalarNode scalar, Type type) {
|
||||
String stringValue = scalar.getValue();
|
||||
if (!stringValue.contains("${")) { //don't check anything with ${} expressions in it as we
|
||||
// don't know its actual value
|
||||
if (!hasPlaceHolder(stringValue)) { //don't check anything with placeholder expressions in it
|
||||
ValueParser valueParser = typeUtil.getValueParser(type);
|
||||
if (valueParser!=null) {
|
||||
// Tag tag = scalar.getTag(); //use the tag? Actually, boot tolerates String values
|
||||
@@ -282,6 +282,12 @@ public class ApplicationYamlASTReconciler implements YamlASTReconciler {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern PLACE_HOLDER = Pattern.compile("(\\$\\{\\S+\\})|(\\@\\S+\\@)");
|
||||
|
||||
private boolean hasPlaceHolder(String str) {
|
||||
return PLACE_HOLDER.matcher(str).find();
|
||||
}
|
||||
|
||||
private void expectTypeFoundMapping(Type type, MappingNode node) {
|
||||
expectType(ApplicationYamlProblemType.YAML_EXPECT_TYPE_FOUND_MAPPING, type, node);
|
||||
}
|
||||
|
||||
@@ -48,5 +48,4 @@ public class ApplicationYamlReconcileEngine extends YamlReconcileEngine {
|
||||
protected ReconcileProblem syntaxError(String msg, int offset, int len) {
|
||||
return ApplicationYamlProblems.problem(YAML_SYNTAX_ERROR, msg, offset, len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3624,6 +3624,31 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreTypeErrorsForValuesContainingMavenResourcesPlaceholders_workaround() throws Exception {
|
||||
//See: https://www.pivotaltracker.com/story/show/150005676
|
||||
defaultTestData();
|
||||
Editor editor = newEditor(
|
||||
"server:\n" +
|
||||
" port: \"@application-port@\"\n" +
|
||||
"bogus: bad" //token error to ensure reconciler is really working
|
||||
);
|
||||
editor.assertProblems("bogus|Unknown property");
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void IGNORED_testIgnoreTypeErrorsForValuesContainingMavenResourcesPlaceholders_direct() throws Exception {
|
||||
//See: https://www.pivotaltracker.com/story/show/150005676
|
||||
//Not implemented, this test fails. The choice not to implement this was deliberate!
|
||||
defaultTestData();
|
||||
Editor editor = newEditor(
|
||||
"server:\n" +
|
||||
" port: @application-port@\n" +
|
||||
"bogus: bad" //token error to ensure reconciler is really working
|
||||
);
|
||||
editor.assertProblems("bogus|Unknown property");
|
||||
}
|
||||
|
||||
///////////////// cruft ////////////////////////////////////////////////////////
|
||||
|
||||
private void generateNestedProperties(int levels, String[] names, String prefix) {
|
||||
|
||||
@@ -152,7 +152,7 @@ public class SimpleTextDocumentService implements TextDocumentService {
|
||||
if (url!=null) {
|
||||
String text = params.getTextDocument().getText();
|
||||
TrackedDocument td = createDocument(url, languageId, version, text).open();
|
||||
Log.info("Opened "+td.getOpenCount()+" times: "+url);
|
||||
// Log.info("Opened "+td.getOpenCount()+" times: "+url);
|
||||
TextDocument doc = td.getDocument();
|
||||
TextDocumentContentChangeEvent change = new TextDocumentContentChangeEvent() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user