Search in sources :

Example 31 with LinkedHashSet

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 32 with LinkedHashSet

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) GrammarTreeVisitor(org.antlr.v4.parse.GrammarTreeVisitor) TerminalAST(org.antlr.v4.tool.ast.TerminalAST)

Example 33 with LinkedHashSet

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;
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NetworkPolicy(android.net.NetworkPolicy) Matchers.anyLong(org.mockito.Matchers.anyLong) Test(org.junit.Test)

Example 34 with LinkedHashSet

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);
                    }
                }
            }
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ElementKind(javax.lang.model.element.ElementKind) TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement)

Example 35 with LinkedHashSet

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()));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JettyPluginWebAppContext(org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1511 ArrayList (java.util.ArrayList)292 Set (java.util.Set)194 HashSet (java.util.HashSet)163 HashMap (java.util.HashMap)142 File (java.io.File)128 Map (java.util.Map)125 LinkedHashMap (java.util.LinkedHashMap)110 IOException (java.io.IOException)108 List (java.util.List)104 Test (org.junit.Test)103 ProcessResult (org.asqatasun.entity.audit.ProcessResult)77 SourceCodeRemark (org.asqatasun.entity.audit.SourceCodeRemark)73 LinkedList (java.util.LinkedList)63 URL (java.net.URL)43 Collection (java.util.Collection)41 DataCell (org.knime.core.data.DataCell)39 DataColumnSpec (org.knime.core.data.DataColumnSpec)39 Iterator (java.util.Iterator)38 TreeSet (java.util.TreeSet)35