• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Context类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.strategoxt.lang.Context的典型用法代码示例。如果您正苦于以下问题:Java Context类的具体用法?Java Context怎么用?Java Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Context类属于org.strategoxt.lang包,在下文中一共展示了Context类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: invoke

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override
public IStrategoTerm invoke(Context context, IStrategoTerm usedWordTerm, IStrategoTerm schemeNameTerm) {

	if (usedWordTerm instanceof IStrategoString) {
		if (schemeNameTerm instanceof IStrategoString) {
			final String schemeName = Tools.asJavaString(schemeNameTerm);
			final String usedWord = Tools.asJavaString(usedWordTerm);
			final String regex = schemeName + "(_.+|[0-9]+'*|'+[0-9]*)";
			if (usedWord.matches(regex)) {
				return usedWordTerm;
			}
		}
	}
	return null;

}
 
开发者ID:metaborg,项目名称:dynsem,代码行数:17,代码来源:native_name_matches_varscheme_0_1.java


示例2: invoke

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override
public IStrategoTerm invoke(Context context, IStrategoTerm current) {
	if (!(current instanceof IStrategoString)) {
		return null;
	}

	final IContext mbContext = (IContext) context.contextObject();
	final Injector injector = mbContext.injector();
	final IResourceService resources = injector.getInstance(IResourceService.class);
	final FileObject fileObj = resources.resolve(Tools.asJavaString(current));
	try {
		fileObj.setExecutable(true, false);
	} catch (FileSystemException e1) {
		return null;
	}

	return current;
}
 
开发者ID:metaborg,项目名称:dynsem,代码行数:19,代码来源:fmakeexecutable_0_0.java


示例3: invoke

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override public IStrategoTerm invoke(Context context, IStrategoTerm current) {
    if(!Tools.isTermString(current))
        return null;

    try {
        final String path = Tools.asJavaString(current);
        final FileObject resource = resourceService.resolve(path);
        if(resource.getType() != FileType.FILE) {
            return null;
        }
        final IdentifiedResource identifiedResource = languageIdentifierService.identifyToResource(resource);
        if(identifiedResource == null) {
            return null;
        }
        final String text = sourceTextService.text(resource);
        final ISpoofaxInputUnit input =
            unitService.inputUnit(resource, text, identifiedResource.language, identifiedResource.dialect);
        final ISpoofaxParseUnit result = syntaxService.parse(input);
        return result.ast();
    } catch(ParseException | IOException e) {
        throw new StrategoException("Parsing failed unexpectedly", e);
    }
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:24,代码来源:ParseFileStrategy.java


示例4: invoke

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override
public IStrategoTerm invoke(Context context, IStrategoTerm current,
		IStrategoTerm tpropname, IStrategoTerm defaultvalue) {

	if (!(current instanceof IStrategoString)) {
		return null;
	}
	if (!(tpropname instanceof IStrategoString)) {
		return null;
	}
	if (!(defaultvalue instanceof IStrategoString)) {
		return null;
	}

	Properties prop = new Properties();

	try(InputStream is = context.getIOAgent().openInputStream(Tools.javaString(current))) {
		prop.load(is);
	} catch (Exception e) {
		return null;
	}
	
	String propval = prop.getProperty(Tools.javaString(tpropname));

	if (propval == null) {
		return defaultvalue;
	}

	return context.getFactory().makeString(propval);
}
 
开发者ID:metaborg,项目名称:dynsem,代码行数:31,代码来源:read_property_0_2.java


示例5: main

import org.strategoxt.lang.Context; //导入依赖的package包/类
public static void main(String[] args) {

		Context ctx = dynsem.trans.Main.init();
		ITermFactory tf = ctx.getFactory();

		IStrategoTerm ast = parse_ds_0_0.instance.invoke(ctx,
				tf.makeString(args[0]));
		IStrategoTerm position = tf.makeList();
		IStrategoTerm path = tf.makeString(args[0]);
		IStrategoTerm projectpath = tf.makeString(args[1]);

		IStrategoTerm tup = tf.makeTuple(ast, position, ast, path, projectpath);
		ds_backend_editor_0_0.instance.invoke(ctx, tup);
	}
 
开发者ID:metaborg,项目名称:dynsem,代码行数:15,代码来源:GenMetaInterp.java


示例6: invoke

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override public IStrategoTerm invoke(Context context, IStrategoTerm current) {
    final String str = Tools.asJavaString(current);
    final ITermFactory factory = context.getFactory();
    IStrategoTerm after = factory.makeString(unquote(str));
    after = factory.annotateTerm(after, current.getAnnotations());
    after = factory.copyAttachments(current, after);
    return after;
}
 
开发者ID:metaborg,项目名称:sdf,代码行数:9,代码来源:unquote_0_0.java


示例7: invoke

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override public IStrategoTerm invoke(Context context, IStrategoTerm current, Strategy commandStrat) {
    final IStrategoTerm commandTerm = commandStrat.invoke(context, current);
    if(commandTerm instanceof IStrategoString && current instanceof IStrategoList) {
        final String command = ((IStrategoString) commandTerm).stringValue();
        if(this.command.equals(command)) {
            final ExecutionResult result = run(current.getAllSubterms());
            return result.success ? current : null;
        }
    }

    return proceed.invoke(context, current, commandStrat);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:13,代码来源:ExecutableCommandStrategy.java


示例8: prettyPrint

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override public IStrategoString prettyPrint(IStrategoTerm term) {
    final Context context = strategoRuntimeService.genericRuntime().getCompiledContext();
    final ITermFactory termFactory = termFactoryService.getGeneric();
    org.strategoxt.stratego_aterm.Main.init(context);
    term = aterm_escape_strings_0_0.instance.invoke(context, term);
    term = pp_aterm_box_0_0.instance.invoke(context, term);
    term = box2text_string_0_1.instance.invoke(context, term, termFactory.makeInt(120));
    return (IStrategoString) term;
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:10,代码来源:StrategoCommon.java


示例9: init

import org.strategoxt.lang.Context; //导入依赖的package包/类
public static void init(Context context) {
  // Called when the editor is being initialized
}
 
开发者ID:Apanatshka,项目名称:elm-spoofax,代码行数:4,代码来源:Main.java


示例10: invoke

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override
public IStrategoTerm invoke(Context context, IStrategoTerm current) {
  context.getIOAgent().printError("Input for java-strategy: " + current);
  ITermFactory factory = context.getFactory();
  return factory.makeString("Regards from java-strategy");
}
 
开发者ID:Apanatshka,项目名称:elm-spoofax,代码行数:7,代码来源:java_strategy_0_0.java


示例11: invoke

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override
public IStrategoTerm invoke(Context context, IStrategoTerm current) {
	final String str = current.toString();
	final String hash = Hashing.sha256().hashString(str, StandardCharsets.UTF_8).toString();
	return context.getFactory().makeString(hash);
}
 
开发者ID:metaborg,项目名称:dynsem,代码行数:7,代码来源:digest_term_0_0.java


示例12: withContext

import org.strategoxt.lang.Context; //导入依赖的package包/类
public StrategoExecutor withContext(Context context) {
    this.context = context;
    return this;
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:5,代码来源:StrategoExecutor.java


示例13: invoke

import org.strategoxt.lang.Context; //导入依赖的package包/类
@Override public IStrategoTerm invoke(Context context, IStrategoTerm current) {
    return parseFileStrategy.invoke(context, current);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:4,代码来源:ParseStrategoFileStrategy.java


示例14: init

import org.strategoxt.lang.Context; //导入依赖的package包/类
public static void init(Context context) {
    
}
 
开发者ID:HiroshiLyda,项目名称:ldbc_gcore_parser,代码行数:4,代码来源:Main.java


示例15: init

import org.strategoxt.lang.Context; //导入依赖的package包/类
/**
 * Called when the editor is being initialized.
 * 
 * @param context
 */
public static void init(Context context) {
}
 
开发者ID:metaborg,项目名称:dynsem,代码行数:8,代码来源:Main.java


示例16: init

import org.strategoxt.lang.Context; //导入依赖的package包/类
/**
 * @param context
 */
public static void init(Context context) {
    
}
 
开发者ID:metaborg,项目名称:sdf,代码行数:7,代码来源:Main.java



注:本文中的org.strategoxt.lang.Context类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Bindable类代码示例发布时间:2022-05-22
下一篇:
Java TypePath类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap