當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。