当前位置: 首页>>代码示例>>Java>>正文


Java Context类代码示例

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


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


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