/*******************************************************************************
* Copyright (c) 2016 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.eclipse.editor.support.yaml.completions;
import org.springframework.ide.eclipse.editor.support.yaml.YamlAssistContextProvider;
import org.springframework.ide.eclipse.editor.support.yaml.YamlDocument;
import org.springframework.ide.eclipse.editor.support.yaml.schema.YamlSchema;
/**
* A {@link YamlAssistContextProvider} that creates {@link YamlAssistContext}s from {@link YamlSchema}
*
* @author Kris De Volder
*/
public class SchemaBasedYamlAssistContextProvider implements YamlAssistContextProvider {
private YamlSchema schema;
public SchemaBasedYamlAssistContextProvider(YamlSchema schema) {
this.schema = schema;
}
@Override
public YamlAssistContext getGlobalAssistContext(YamlDocument doc) {
return new TopLevelAssistContext() {
@Override
protected YamlAssistContext getDocumentContext(int documentSelector) {
return new YTypeAssistContext(this, documentSelector, schema.getTopLevelType(), schema.getTypeUtil());
}
};
}
}