當前位置: 首頁>>代碼示例>>Java>>正文


Java Iterables2類代碼示例

本文整理匯總了Java中org.metaborg.util.iterators.Iterables2的典型用法代碼示例。如果您正苦於以下問題:Java Iterables2類的具體用法?Java Iterables2怎麽用?Java Iterables2使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Iterables2類屬於org.metaborg.util.iterators包,在下文中一共展示了Iterables2類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: tracingTermsCompletions

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
private Iterable<IStrategoTerm> tracingTermsCompletions(final int position, Object result,
    final ISourceRegion region, final HybridInterpreter runtime, final ITermFactory termFactory,
    final String languageName, final Map<IStrategoTerm, Boolean> leftRecursiveTerms,
    final Map<IStrategoTerm, Boolean> rightRecursiveTerms) {
    if(result == null || region == null) {
        return Iterables2.empty();
    }
    final Collection<IStrategoTerm> parsed = Lists.newLinkedList();

    final IStrategoTermVisitor visitor = new AStrategoTermVisitor() {
        @Override public boolean visit(IStrategoTerm term) {
            final ISourceLocation location = fromTokens(term, runtime, termFactory, position, languageName,
                leftRecursiveTerms, rightRecursiveTerms);
            if(location != null && location.region().contains(region)) {
                parsed.add(term);
                return false;
            }
            return true;
        }
    };

    StrategoTermVisitee.bottomup(visitor, (IStrategoTerm) result);
    return parsed;
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:25,代碼來源:JSGLRCompletionService.java

示例2: styleParsed

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
@Override public Iterable<IRegionStyle<IStrategoTerm>> styleParsed(ILanguageImpl language,
    Iterable<IRegionCategory<IStrategoTerm>> categorization) {
    final StylerFacet facet = language.facet(StylerFacet.class);
    if(facet == null) {
        logger.error("Cannot style input of {}, it does not have a styler facet", language);
        // GTODO: throw exception instead
        return Iterables2.empty();
    }

    final List<IRegionStyle<IStrategoTerm>> regionStyles = Lists.newLinkedList();
    for(IRegionCategory<IStrategoTerm> regionCategory : categorization) {
        final IRegionStyle<IStrategoTerm> regionStyle = style(facet, regionCategory);
        if(regionStyle != null) {
            regionStyles.add(regionStyle);
        }
    }

    return regionStyles;
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:20,代碼來源:StylerService.java

示例3: toTerms

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
private Iterable<IStrategoTerm> toTerms(IStrategoTerm ast, final ISourceRegion region) {
    if(ast == null || region == null) {
        return Iterables2.empty();
    }
    final Collection<IStrategoTerm> parsed = Lists.newLinkedList();
    final IStrategoTermVisitor visitor = new AStrategoTermVisitor() {
        @Override public boolean visit(IStrategoTerm term) {
            final ISourceLocation location = location(term);
            if(location != null && location.region().contains(region)) {
                parsed.add(term);
                return false;
            }
            return true;
        }
    };
    StrategoTermVisitee.bottomup(visitor, ast);
    return parsed;
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:19,代碼來源:TracingService.java

示例4: toTermsWithin

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
private Iterable<IStrategoTerm> toTermsWithin(IStrategoTerm ast, final ISourceRegion region) {
    if(ast == null || region == null) {
        return Iterables2.empty();
    }
    final Collection<IStrategoTerm> parsed = Lists.newLinkedList();
    final IStrategoTermVisitor visitor = new AStrategoTermVisitor() {
        @Override public boolean visit(IStrategoTerm term) {
            final ISourceLocation location = location(term);
            if(location != null && region.contains(location.region())) {
                parsed.add(term);
                // no need to check the children, as this term is already within the given region
                return false;
            }
            return true;
        }
    };
    StrategoTermVisitee.topdown(visitor, ast);
    return parsed;
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:20,代碼來源:TracingService.java

示例5: find

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
public static Iterable<FileObject> find(FileObject base, FileSelector selector) throws FileSystemException {
    final FileObject[] files = base.findFiles(selector);
    if(files == null) {
        return Iterables2.empty();
    }
    return Iterables2.from(files);
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:8,代碼來源:ResourceUtils.java

示例6: sourcePaths

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
@Override public Iterable<FileObject> sourcePaths(IProject project, String languageName) throws MetaborgException {
    final Iterable<ILanguageComponent> dependencies = dependencyService.compileDeps(project);
    final Collection<FileObject> sources = Lists.newArrayList();
    for(ILanguageComponent dependency : dependencies) {
        final Collection<IGenerateConfig> generates = dependency.config().generates();
        for(IGenerateConfig generate : generates) {
            if(languageName.equals(generate.languageName())) {
                resolve(project.location(), Iterables2.singleton(generate.directory()), sources);
            }
        }
    }
    return sources;
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:14,代碼來源:DependencyPathProvider.java

示例7: toFiles

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
@Override public Collection<IdentifiedResource> toFiles(Iterable<FileObject> paths, ILanguageImpl language) {
    final Collection<FileObject> files = ResourceUtils.expand(paths);
    final Collection<IdentifiedResource> identifiedFiles = Lists.newArrayListWithExpectedSize(files.size());
    for(FileObject file : files) {
        final IdentifiedResource identifiedFile =
            languageIdentifierService.identifyToResource(file, Iterables2.singleton(language));
        if(identifiedFile != null) {
            identifiedFiles.add(identifiedFile);
        }
    }
    return identifiedFiles;
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:13,代碼來源:LanguagePathService.java

示例8: startSymbols

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
private static Iterable<String> startSymbols(IStrategoAppl document) {
    final IStrategoAppl result = ESVReader.findTerm(document, "StartSymbols");
    if(result == null) {
        return null;
    }

    final String contents = ESVReader.termContents(termAt(termAt(result, 0), 0));
    return Iterables2.singleton(contents);
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:10,代碼來源:SyntaxFacetFromESV.java

示例9: analyze

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
@Override public ISpoofaxAnalyzeResult analyze(ISpoofaxParseUnit input, IContext genericContext, IProgress progress,
        ICancel cancel) throws AnalysisException {
    if(!input.valid()) {
        final String message = logger.format("Parse input for {} is invalid, cannot analyze", input.source());
        throw new AnalysisException(genericContext, message);
    }
    final ISpoofaxAnalyzeResults results =
            analyzeAll(Iterables2.singleton(input), genericContext, progress, cancel);
    if(results.results().isEmpty()) {
        throw new AnalysisException(genericContext, "Analysis failed.");
    }
    return new SpoofaxAnalyzeResult(Iterables.getOnlyElement(results.results()), results.updates(),
            results.context());
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:15,代碼來源:AbstractConstraintAnalyzer.java

示例10: analyze

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
@Override public ISpoofaxAnalyzeResult analyze(ISpoofaxParseUnit input, IContext context, IProgress progress,
    ICancel cancel) throws AnalysisException, InterruptedException {
    if(!input.valid()) {
        final String message = logger.format("Parse input for {} is invalid, cannot analyze", input.source());
        throw new AnalysisException(context, message);
    }

    final ISpoofaxAnalyzeResults results = analyzeAll(Iterables2.singleton(input), context, progress, cancel);
    return new SpoofaxAnalyzeResult(results.results().iterator().next(), results.updates(), context);
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:11,代碼來源:TaskEngineAnalyzer.java

示例11: result

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
private ISpoofaxAnalyzeUnit result(String error, ISpoofaxParseUnit input, IContext context, Throwable e,
    long duration) {
    final FileObject source = input.source();
    final IMessage message = MessageFactory.newAnalysisErrorAtTop(source, error, e);
    return unitService.analyzeUnit(input,
        new AnalyzeContrib(false, false, true, null, Iterables2.singleton(message), duration), context);
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:8,代碼來源:StrategoAnalyzer.java

示例12: fragments

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
@Override public Iterable<IStrategoTerm> fragments(ISpoofaxAnalyzeUnit result, ISourceRegion region) {
    if(!result.valid()) {
        throw new MetaborgRuntimeException(
            "Cannot get fragments for analyze unit " + result + " because it is invalid");
    }
    if(!result.hasAst()) {
        return Iterables2.empty();
    }
    return toTerms(result.ast(), region);
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:11,代碼來源:TracingService.java

示例13: matchWf

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
private static IMatcher<IRegExp<Label>> matchWf(IRegExpBuilder<Label> builder) {
    return M.casesFix(m -> Iterables2.from(
        // @formatter:off
            M.appl0("Empty", (t) -> builder.emptySet()), M.appl0("Epsilon", (t) -> builder.emptyString()),
            M.appl1("Closure", m, (t, re) -> builder.closure(re)),
            M.appl2("Concat", m, m, (t, re1, re2) -> builder.concat(re1, re2)),
            M.appl2("And", m, m, (t, re1, re2) -> builder.and(re1, re2)),
            M.appl2("Or", m, m, (t, re1, re2) -> builder.or(re1, re2)), Label.matcher(l -> builder.symbol(l))
    // @formatter:on
    ));
}
 
開發者ID:metaborg,項目名稱:nabl,代碼行數:12,代碼來源:ResolutionParameters.java

示例14: collecttd

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
public static <R> Function1<ITerm, Collection<R>> collecttd(IMatcher<? extends R> m) {
    return term -> {
        List<R> results = Lists.newArrayList();
        M.<Unit>casesFix(f -> Iterables2.<IMatcher<? extends Unit>>from(
            // @formatter:off
            t -> m.match(t).map(r -> {
                results.add(r);
                return Unit.unit;
            }),
            t -> Optional.of(t.match(Terms.<Unit>cases(
                (appl) -> {
                    for(ITerm arg : appl.getArgs()) {
                        f.match(arg);
                    }
                    return Unit.unit;
                },
                (list) -> list.match(ListTerms.<Unit> cases(
                    (cons) -> {
                        f.match(cons.getHead());
                        f.match(cons.getTail());
                        return Unit.unit;
                    },
                    (nil) -> Unit.unit,
                    (var) -> Unit.unit
                )),
                (string) -> Unit.unit,
                (integer) -> Unit.unit,
                (var) -> Unit.unit
            )))
            // @formatter:on
        )).match(term);
        return results;
    };
}
 
開發者ID:metaborg,項目名稱:nabl,代碼行數:35,代碼來源:Terms.java

示例15: matcher

import org.metaborg.util.iterators.Iterables2; //導入依賴的package包/類
public static IMatcher<MessageContent> matcher() {
    return M.<MessageContent>cases(
        // @formatter:off
        M.appl0(DEFAULT, (t) -> ImmutableDefaultMessage.of()),
        M.appl1(FORMATTED, M.listElems(partMatcher()), (t, ps) -> ImmutableCompoundMessage.of(ps)),
        M.string(s -> ImmutableTextMessage.of(s.getValue())),
        partMatcher(),
        M.term(t -> ImmutableCompoundMessage.of(Iterables2.from(
            ImmutableTermMessage.of(t),
            ImmutableTextMessage.of(" (error message was malformed)")
        )))
        // @formatter:on
    );
}
 
開發者ID:metaborg,項目名稱:nabl,代碼行數:15,代碼來源:MessageContent.java


注:本文中的org.metaborg.util.iterators.Iterables2類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。