use of java.util.LinkedHashSet in project antlr4 by antlr.
the class XPath method evaluate.
/**
* Return a list of all nodes starting at {@code t} as root that satisfy the
* path. The root {@code /} is relative to the node passed to
* {@link #evaluate}.
*/
public Collection<ParseTree> evaluate(final ParseTree t) {
ParserRuleContext dummyRoot = new ParserRuleContext();
// don't set t's parent.
dummyRoot.children = Collections.singletonList(t);
Collection<ParseTree> work = Collections.<ParseTree>singleton(dummyRoot);
int i = 0;
while (i < elements.length) {
Collection<ParseTree> next = new LinkedHashSet<ParseTree>();
for (ParseTree node : work) {
if (node.getChildCount() > 0) {
// only try to match next element if it has children
// e.g., //func/*/stat might have a token node for which
// we can't go looking for stat nodes.
Collection<? extends ParseTree> matching = elements[i].evaluate(node);
next.addAll(matching);
}
}
i++;
work = next;
}
return work;
}
use of java.util.LinkedHashSet in project antlr4 by antlr.
the class Grammar method getStringLiterals.
public Set<String> getStringLiterals() {
final Set<String> strings = new LinkedHashSet<String>();
GrammarTreeVisitor collector = new GrammarTreeVisitor() {
@Override
public void stringRef(TerminalAST ref) {
strings.add(ref.getText());
}
@Override
public ErrorManager getErrorManager() {
return tool.errMgr;
}
};
collector.visitGrammar(ast);
return strings;
}
use of java.util.LinkedHashSet in project platform_frameworks_base by android.
the class NetworkPolicyManagerServiceTest method testLastCycleSane.
@Test
public void testLastCycleSane() throws Exception {
final NetworkPolicy policy = new NetworkPolicy(sTemplateWifi, 31, TIMEZONE_UTC, WARNING_DISABLED, LIMIT_DISABLED, false);
final LinkedHashSet<Long> seen = new LinkedHashSet<Long>();
// walk backwards, ensuring that cycle boundaries look sane
long currentCycle = computeLastCycleBoundary(parseTime("2011-08-04T00:00:00.000Z"), policy);
for (int i = 0; i < 128; i++) {
long lastCycle = computeLastCycleBoundary(currentCycle, policy);
assertEqualsFuzzy(DAY_IN_MILLIS * 30, currentCycle - lastCycle, DAY_IN_MILLIS * 3);
assertUnique(seen, lastCycle);
currentCycle = lastCycle;
}
}
use of java.util.LinkedHashSet in project androidannotations by androidannotations.
the class ModelExtractor method extractAncestorsAnnotations.
private void extractAncestorsAnnotations(AnnotationElementsHolder extractedModel, Set<String> annotationTypesToCheck, Set<TypeElement> rootTypeElements) {
for (TypeElement rootTypeElement : rootTypeElements) {
Set<TypeElement> ancestors = new LinkedHashSet<>();
addAncestorsElements(ancestors, rootTypeElement);
if (!ancestors.isEmpty()) {
for (TypeElement ancestor : ancestors) {
extractAnnotations(extractedModel, annotationTypesToCheck, rootTypeElement, ancestor);
for (Element ancestorEnclosedElement : ancestor.getEnclosedElements()) {
ElementKind enclosedKind = ancestorEnclosedElement.getKind();
if (enclosedKind == ElementKind.FIELD || enclosedKind == ElementKind.METHOD) {
extractAnnotations(extractedModel, annotationTypesToCheck, rootTypeElement, ancestorEnclosedElement);
}
}
}
}
}
}
use of java.util.LinkedHashSet in project gradle by gradle.
the class AbstractJettyRunTask method configureWebApplication.
/**
* Subclasses should invoke this to setup basic info on the webapp.
*/
public void configureWebApplication() throws Exception {
//way of doing things
if (webAppConfig == null) {
webAppConfig = new JettyPluginWebAppContext();
}
webAppConfig.setContextPath(getContextPath().startsWith("/") ? getContextPath() : "/" + getContextPath());
if (getTemporaryDir() != null) {
webAppConfig.setTempDirectory(getTemporaryDir());
}
if (getWebDefaultXml() != null) {
webAppConfig.setDefaultsDescriptor(getWebDefaultXml().getCanonicalPath());
}
if (getOverrideWebXml() != null) {
webAppConfig.setOverrideDescriptor(getOverrideWebXml().getCanonicalPath());
}
// Don't treat JCL or Log4j as system classes
Set<String> systemClasses = new LinkedHashSet<String>(Arrays.asList(webAppConfig.getSystemClasses()));
systemClasses.remove("org.apache.commons.logging.");
systemClasses.remove("org.apache.log4j.");
webAppConfig.setSystemClasses(systemClasses.toArray(new String[0]));
webAppConfig.setParentLoaderPriority(false);
LOGGER.info("Context path = " + webAppConfig.getContextPath());
LOGGER.info("Tmp directory = " + " determined at runtime");
LOGGER.info("Web defaults = " + (webAppConfig.getDefaultsDescriptor() == null ? " jetty default" : webAppConfig.getDefaultsDescriptor()));
LOGGER.info("Web overrides = " + (webAppConfig.getOverrideDescriptor() == null ? " none" : webAppConfig.getOverrideDescriptor()));
}
Aggregations