本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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
));
}
示例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;
};
}
示例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
);
}