本文整理汇总了Java中org.aikodi.chameleon.support.variable.LocalVariableDeclarator类的典型用法代码示例。如果您正苦于以下问题:Java LocalVariableDeclarator类的具体用法?Java LocalVariableDeclarator怎么用?Java LocalVariableDeclarator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocalVariableDeclarator类属于org.aikodi.chameleon.support.variable包,在下文中一共展示了LocalVariableDeclarator类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toCodeForInit
import org.aikodi.chameleon.support.variable.LocalVariableDeclarator; //导入依赖的package包/类
public String toCodeForInit(Element element) {
if(element instanceof LocalVariableDeclarator) {
return toCodeVariableDeclarator((LocalVariableDeclarator)element);
} else {
return toCode(element);
}
}
示例2: isLocalVariableDeclarator
import org.aikodi.chameleon.support.variable.LocalVariableDeclarator; //导入依赖的package包/类
public boolean isLocalVariableDeclarator(Element element) {
return element instanceof LocalVariableDeclarator;
}
示例3: toCodeLocalVariableDeclarator
import org.aikodi.chameleon.support.variable.LocalVariableDeclarator; //导入依赖的package包/类
public String toCodeLocalVariableDeclarator(LocalVariableDeclarator local) {
return toCodeVariableDeclarator(local) + ";";
}
示例4: localVariableDeclaration
import org.aikodi.chameleon.support.variable.LocalVariableDeclarator; //导入依赖的package包/类
public final Java_JavaP.localVariableDeclaration_return localVariableDeclaration() throws RecognitionException {
Java_JavaP.localVariableDeclaration_return retval = new Java_JavaP.localVariableDeclaration_return();
retval.start = input.LT(1);
int localVariableDeclaration_StartIndex = input.index();
Object root_0 = null;
Java_JavaP.variableModifiers_return mods = null;
Java_JavaP.type_return ref = null;
Java_JavaP.variableDeclarators_return decls = null;
try {
if ( state.backtracking>0 && alreadyParsedRule(input, 93) ) { return retval; }
// JavaP.g:1273:5: (mods= variableModifiers ref= type decls= variableDeclarators )
// JavaP.g:1273:9: mods= variableModifiers ref= type decls= variableDeclarators
{
root_0 = (Object)adaptor.nil();
pushFollow(FOLLOW_variableModifiers_in_localVariableDeclaration5637);
mods=variableModifiers();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) adaptor.addChild(root_0, mods.getTree());
pushFollow(FOLLOW_type_in_localVariableDeclaration5641);
ref=type();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) adaptor.addChild(root_0, ref.getTree());
if ( state.backtracking==0 ) {
retval.element = new LocalVariableDeclarator(ref.element);
}
pushFollow(FOLLOW_variableDeclarators_in_localVariableDeclaration5647);
decls=variableDeclarators();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) adaptor.addChild(root_0, decls.getTree());
if ( state.backtracking==0 ) {
for(VariableDeclaration decl: decls.element) {retval.element.add(decl);}
}
if ( state.backtracking==0 ) {
for(Modifier mod : mods.element) {retval.element.addModifier(mod);}
}
}
retval.stop = input.LT(-1);
if ( state.backtracking==0 ) {
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
}
finally {
if ( state.backtracking>0 ) { memoize(input, 93, localVariableDeclaration_StartIndex); }
}
return retval;
}
示例5: testMethodCalls
import org.aikodi.chameleon.support.variable.LocalVariableDeclarator; //导入依赖的package包/类
public void testMethodCalls() throws LookupException, ProjectException {
Java7 language = (Java7)view().language();
Namespace ns = view().namespace();
DirectScanner scanner = new DirectScanner();
view().addSource(scanner);
Document document = new Document();
NamespaceDeclaration nsd = new JavaNamespaceDeclaration("test");
document.add(nsd);
RegularJavaType type = new RegularJavaType("Test");
nsd.add(type);
DirectDocumentLoader loader = new DirectDocumentLoader(scanner, document);
Type test = ns.find("test.Test", Type.class);
NormalMethod caller = new NormalMethod(new SimpleNameMethodHeader("m", new BasicJavaTypeReference("void")));
Block body = new Block();
caller.setImplementation(new RegularImplementation(body));
BasicJavaTypeReference listRef = new BasicJavaTypeReference("java.util.List");
listRef.addArgument(new PureWildcard());
LocalVariableDeclarator declarator = new LocalVariableDeclarator(listRef);
declarator.add(new JavaVariableDeclaration("first"));
declarator.add(new JavaVariableDeclaration("second"));
body.addStatement(declarator);
JavaMethodInvocation call = new JavaMethodInvocation("two", null);
call.addArgument(new JavaNameExpression("first"));
call.addArgument(new JavaNameExpression("second"));
body.addStatement(new StatementExpression(call));
type.add(caller);
SimpleNameMethodHeader calleeHeader = new SimpleNameMethodHeader("two", new BasicJavaTypeReference("void"));
calleeHeader.addTypeParameter(new FormalTypeParameter("T"));
BasicJavaTypeReference listTRef = new BasicJavaTypeReference("java.util.List");
listTRef.addArgument(new EqualityTypeArgument(new BasicJavaTypeReference("T")));
calleeHeader.addFormalParameter(new FormalParameter("first", listTRef.clone(listTRef)));
calleeHeader.addFormalParameter(new FormalParameter("second", listTRef.clone(listTRef)));
NormalMethod callee = new NormalMethod(calleeHeader);
callee.setImplementation(new RegularImplementation(new Block()));
type.add(callee);
try {
call.getElement();
assertTrue(false);
} catch(LookupException exc) {
}
}
示例6: resources
import org.aikodi.chameleon.support.variable.LocalVariableDeclarator; //导入依赖的package包/类
public List<LocalVariableDeclarator> resources() {
return _resources.getOtherEnds();
}
示例7: addResource
import org.aikodi.chameleon.support.variable.LocalVariableDeclarator; //导入依赖的package包/类
public void addResource(LocalVariableDeclarator decl) {
add(_resources, decl);
}
示例8: removeResource
import org.aikodi.chameleon.support.variable.LocalVariableDeclarator; //导入依赖的package包/类
public void removeResource(LocalVariableDeclarator decl) {
remove(_resources, decl);
}