use of org.csstudio.autocomplete.parser.IContentParser in project yamcs-studio by yamcs.
the class AutoCompleteService method parseContent.
/* Handle recursive parsing of a content desc. */
private List<ContentDescriptor> parseContent(ContentDescriptor desc) {
List<ContentDescriptor> tokenList = new ArrayList<ContentDescriptor>();
ContentDescriptor newDesc = null;
// backup data
int startIndex = desc.getStartIndex();
int endIndex = desc.getEndIndex();
AutoCompleteType acType = desc.getAutoCompleteType();
String defaultDatasource = desc.getDefaultDataSource();
String originalContent = desc.getOriginalContent();
// cancel replay
desc.setReplay(false);
for (IContentParser parser : parsers) {
if (parser.accept(desc) && (newDesc = parser.parse(desc)) != null) {
newDesc.setAutoCompleteType(acType);
newDesc.setDefaultDataSource(defaultDatasource);
newDesc.setOriginalContent(originalContent);
// update indexes
newDesc.setStartIndex(newDesc.getStartIndex() + startIndex);
newDesc.setEndIndex(newDesc.getEndIndex() + endIndex);
if (newDesc.isReplay()) {
// recursive
tokenList.addAll(parseContent(newDesc));
} else {
tokenList.add(newDesc);
}
}
}
if (tokenList.isEmpty()) {
desc.setContentType(ContentType.Undefined);
tokenList.add(desc);
}
return tokenList;
}
use of org.csstudio.autocomplete.parser.IContentParser in project yamcs-studio by yamcs.
the class AutoCompleteService method getOSGIParsers.
/* Get providers from OSGI services */
private List<IContentParser> getOSGIParsers() throws InvalidSyntaxException {
final List<IContentParser> list = new ArrayList<IContentParser>();
BundleContext context = AutoCompletePlugin.getBundleContext();
Collection<ServiceReference<IContentParser>> references = context.getServiceReferences(IContentParser.class, null);
for (ServiceReference<IContentParser> ref : references) {
IContentParser parser = (IContentParser) context.getService(ref);
list.add(parser);
}
return list;
}
Aggregations