Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2023 Pivotal, Inc.
* Copyright (c) 2016, 2025 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -468,6 +468,10 @@ public boolean isIndexable(Type type) {
public boolean isSequencable(Type type) {
return isIndexable(type);
}

public boolean isObjectOrSequence(Type type) {
return OBJECT_TYPE_NAME.equals(type.getErasure());
}

private static boolean isArray(Type type) {
return type!=null && type.getErasure().endsWith("[]");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016-2017 Pivotal, Inc.
* Copyright (c) 2016, 2025 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -92,7 +92,7 @@ public Type navigate(int offset, Type type) {
} else if (navOp=='[') {
if (typeUtil.isBracketable(type)) {
return bracketNavigate(offset, type);
} else {
} else if (!typeUtil.isObjectOrSequence(type)) {
problemCollector.accept(problem(ApplicationPropertiesProblemType.PROP_INVALID_INDEXED_NAVIGATION,
"Can't use '[..]' navigation for property '"+textBetween(region.getStart(), offset)+"' of type "+type,
offset, region.getEnd()-offset));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2019 Pivotal, Inc.
* Copyright (c) 2016, 2025 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -341,6 +341,8 @@ private void reconcile(YamlFileAST root, SequenceNode seq, Type type) {
reconcile(root, element, domainType);
}
}
} else if (typeUtil.isObjectOrSequence(type)) {
// skip reconciling further as it can be anything - no schema
} else {
expectTypeFoundSequence(type, seq);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2024 Pivotal, Inc.
* Copyright (c) 2016, 2025 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -2309,6 +2309,30 @@ void testSetOfEnumsCompletions() throws Exception {
"my.color-set=red,BLUE<*>"
);
}

@Test
void sequenceOrObject() throws Exception {
data("my.any", "java.util.Map<java.lang.String,java.lang.Object>", null, "Some map");

Editor editor = newEditor(
"""
my.any.entry.value.name=Freddy
my.any.entry.value.age=the-age
my.any.entry.value.bad=123
"""
);
editor.assertProblems();

editor = newEditor(
"""
my.any.entry[0].value.name=Freddy
my.any.entry[0].value.age=the-age
my.any.entry[0].value.bad=123
"""
);
editor.assertProblems();
}


////////////// harness code below /////////////////////////

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2024 Pivotal, Inc.
* Copyright (c) 2016, 2025 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -5060,6 +5060,35 @@ void test_NoQuickfixForDeprecatedProperty() throws Exception {
editor.assertNoCodeAction(problem);
assertEquals(DiagnosticSeverity.Error, problem.getSeverity());
}

@Test
void sequenceOrObject() throws Exception {
IJavaProject p = createPredefinedMavenProject("map-of-pojo");
useProject(p);
data("my.any", "java.util.Map<java.lang.String,java.lang.Object>", null, "Some map");

Editor editor = newEditor(
"my:\n" +
" any:\n" +
" entry:\n" +
" - value:\n" +
" name: Freddy\n" +
" age: the-age\n" +
" bad: 123"
);
editor.assertProblems();

editor = newEditor(
"my:\n" +
" any:\n" +
" entry:\n" +
" value:\n" +
" name: Freddy\n" +
" age: the-age\n" +
" bad: 123"
);
editor.assertProblems();
}

///////////////// cruft ////////////////////////////////////////////////////////

Expand Down