blob: 3aed188ca9faf57a60252a9d9c51714904df8acf [file] [log] [blame]
/*
* Copyright (c) 2011 Google 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
*/
package com.google.eclipse.protobuf.scoping;
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Collections.emptyList;
import static org.eclipse.xtext.EcoreUtil2.getAllContentsOfType;
import static org.eclipse.xtext.resource.EObjectDescription.create;
import java.util.*;
import org.eclipse.xtext.resource.IEObjectDescription;
import com.google.eclipse.protobuf.protobuf.*;
import com.google.eclipse.protobuf.protobuf.Enum;
/**
* @author alruiz@google.com (Alex Ruiz)
*/
class LiteralDescriptions {
Collection<IEObjectDescription> literalsOf(Enum anEnum) {
if (anEnum == null) {
return emptyList();
}
List<IEObjectDescription> descriptions = newArrayList();
for (Literal literal : getAllContentsOfType(anEnum, Literal.class)) {
String name = literal.getName();
descriptions.add(create(name, literal));
}
return descriptions;
}
}