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


Java NamespaceDeclaration.add方法代码示例

本文整理汇总了Java中org.aikodi.chameleon.core.namespacedeclaration.NamespaceDeclaration.add方法的典型用法代码示例。如果您正苦于以下问题:Java NamespaceDeclaration.add方法的具体用法?Java NamespaceDeclaration.add怎么用?Java NamespaceDeclaration.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.aikodi.chameleon.core.namespacedeclaration.NamespaceDeclaration的用法示例。


在下文中一共展示了NamespaceDeclaration.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitCompilationUnit

import org.aikodi.chameleon.core.namespacedeclaration.NamespaceDeclaration; //导入方法依赖的package包/类
@Override
public Element visitCompilationUnit(CompilationUnitContext ctx) {
  NamespaceDeclaration ns;
  if(ctx.namespace() != null) {
    ns = visitNamespace(ctx.namespace());
  } else {
    ns = factory().createRootNamespaceDeclaration();
  }
  for(ImportDeclarationContext id: ctx.importDeclaration()) {
    ns.addImport(visitImportDeclaration(id));
  }
  List<KlassContext> klasses = ctx.klass();
  for(KlassContext klas : klasses) {
    ns.add(visitKlass(klas));
  }
  _document.add(ns);
  return _document;
}
 
开发者ID:markovandooren,项目名称:jlo,代码行数:19,代码来源:JLoConvertor.java

示例2: load

import org.aikodi.chameleon.core.namespacedeclaration.NamespaceDeclaration; //导入方法依赖的package包/类
public Document load(Java7 language) throws FileNotFoundException, IOException, LookupException {
  Type t = read(language);
  Document doc = new Document();

  NamespaceDeclaration decl;
  if(packageFQN() != null) {
    decl = new JavaNamespaceDeclaration(packageFQN());
  } else {
    decl = new JavaNamespaceDeclaration(new RootNamespaceReference());
  }
  doc.add(decl);
  decl.add(t);
  return doc;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:15,代码来源:ASMClassParser.java

示例3: processType

import org.aikodi.chameleon.core.namespacedeclaration.NamespaceDeclaration; //导入方法依赖的package包/类
public void processType(NamespaceDeclaration np, Type type){
  if(np == null) {throw new IllegalArgumentException("namespace part given to processType is null.");}
  if(type == null) {return;}  //throw new IllegalArgumentException("type given to processType is null.");}
  np.add(type);
  // inherit from java.lang.Object if there is no explicit extends relation
  //String fqn = type.getFullyQualifiedName();
  //if(fqn != null) {
  //  if(type.nonMemberInheritanceRelations().isEmpty() && (! fqn.equals("java.lang.Object"))){
  //    type.addInheritanceRelation(new SubtypeRelation(createTypeReference(expressionFactory().createNamedTarget("java.lang"),"Object")));
  //  }
  //}

}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:14,代码来源:Java_JavaP.java

示例4: read

import org.aikodi.chameleon.core.namespacedeclaration.NamespaceDeclaration; //导入方法依赖的package包/类
@Override
public Document read(Class clazz, RootNamespace root, Document doc) throws LookupException {
	String packageName = clazz.getPackage().getName();
	NamespaceDeclaration nsd = new JavaNamespaceDeclaration(packageName);
	doc.add(nsd);
	
	Type type = createType(clazz);
	
   nsd.add(type);
	return doc;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:12,代码来源:ReflectiveClassParser.java

示例5: testMethodCalls

import org.aikodi.chameleon.core.namespacedeclaration.NamespaceDeclaration; //导入方法依赖的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) {
	}
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:44,代码来源:TestCustomCases.java


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