Remove unnessary param from getContextNode method
This commit is contained in:
@@ -90,8 +90,8 @@ public abstract class AbstractYamlAssistContext implements YamlAssistContext {
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
protected SNode getContextNode(YamlDocument file) throws Exception {
|
||||
return contextPath.traverse((SNode)getContextRoot(file));
|
||||
protected SNode getContextNode() throws Exception {
|
||||
return contextPath.traverse((SNode)getContextRoot(getDocument()));
|
||||
}
|
||||
|
||||
protected SDocNode getContextRoot(YamlDocument file) throws Exception {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
|
||||
|
||||
public List<ICompletionProposal> getKeyCompletions(YamlDocument doc, int offset, String query) throws Exception {
|
||||
int queryOffset = offset - query.length();
|
||||
SNode contextNode = getContextNode(doc);
|
||||
SNode contextNode = getContextNode();
|
||||
DynamicSchemaContext dynamicCtxt = new SNodeDynamicSchemaContext(contextNode);
|
||||
List<YTypedProperty> properties = typeUtil.getProperties(type, dynamicCtxt);
|
||||
if (CollectionUtil.hasElements(properties)) {
|
||||
@@ -167,7 +167,7 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
|
||||
return contextWith(s, typeUtil.getDomainType(type));
|
||||
}
|
||||
String key = s.toPropString();
|
||||
SNode contextNode = getContextNode(getDocument());
|
||||
SNode contextNode = getContextNode();
|
||||
DynamicSchemaContext dynamicCtxt = new SNodeDynamicSchemaContext(contextNode);
|
||||
Map<String, YTypedProperty> subproperties = typeUtil.getPropertiesMap(type, dynamicCtxt);
|
||||
if (subproperties!=null) {
|
||||
@@ -232,7 +232,7 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
|
||||
|
||||
private DynamicSchemaContext getSchemaContext() {
|
||||
try {
|
||||
SNode contextNode = getContextNode(getDocument());
|
||||
SNode contextNode = getContextNode();
|
||||
return new SNodeDynamicSchemaContext(contextNode);
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
|
||||
@@ -192,7 +192,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon
|
||||
List<TypedProperty> properties = getProperties(query, enumCaseMode, beanMode);
|
||||
if (CollectionUtil.hasElements(properties)) {
|
||||
ArrayList<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(properties.size());
|
||||
SNode contextNode = getContextNode(doc);
|
||||
SNode contextNode = getContextNode();
|
||||
Set<String> definedProps = getDefinedProperties(contextNode);
|
||||
for (TypedProperty p : properties) {
|
||||
String name = p.getName();
|
||||
@@ -443,7 +443,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon
|
||||
YamlPath propertyPath = YamlPath.fromProperty(match.data.getId());
|
||||
YamlPath relativePath = propertyPath.dropFirst(contextPath.size());
|
||||
YamlPathSegment nextSegment = relativePath.getSegment(0);
|
||||
SNode contextNode = getContextNode(file);
|
||||
SNode contextNode = getContextNode();
|
||||
//To determine if this completion is 'in place' or needs to be inserted
|
||||
// elsewhere in the tree, we check whether a node already exists in our
|
||||
// context. If it doesn't we can create it as any child of the context
|
||||
|
||||
@@ -3298,6 +3298,22 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
" classpath:stuff/wordlist.txt<*>\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void testCompletionsInContextWithDuplicateKey() throws Exception {
|
||||
//See: https://www.pivotaltracker.com/story/show/135708013
|
||||
defaultTestData();
|
||||
|
||||
assertCompletions(
|
||||
"spring:\n" +
|
||||
" application:\n" +
|
||||
" name: my-app\n" +
|
||||
"spring:\n" +
|
||||
" activemq:\n" +
|
||||
" broker-u<*>"
|
||||
, // ==>
|
||||
"fill it in later"
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void testClassReferenceCompletion() throws Exception {
|
||||
CachingValueProvider.TIMEOUT = Duration.ofSeconds(20);
|
||||
|
||||
Reference in New Issue
Block a user