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


Java Namespace类代码示例

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


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

示例1: find

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
public <E extends Element> List<E> find(Class<E> kind, SafePredicate<E> safe) {
	List<E> result = new ArrayList<E>();
	for(Namespace ns: namespaces()) {
		//System.out.println("Analyzing "+type.getFullyQualifiedName());
		result.addAll(ns.descendants(kind, safe));
	}
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:9,代码来源:CommandLineTool.java

示例2: declarationTypeSelector

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
private PredicateSelector<Element> declarationTypeSelector() {
  ListContentProvider<Class> contentProvider = new ListContentProvider<Class>() {

    @Override
    public List<Class> items(Object context) {
      return ImmutableList.<Class>of(Declaration.class,Namespace.class,Type.class,Method.class,Variable.class);
    }
  };
  LabelProvider labelProvider = new LabelProvider(){

    @Override
    public String text(Object object) {
      String result = null; 
      if(object instanceof Class) {
        if(object == Declaration.class) {
          result = "All declarations";
        } else {
          result = ((Class) object).getSimpleName();
        }
      }
      return result;
    }
  };
  Function<Class,UniversalPredicate<? super Element, Nothing>,Nothing> function = new Function<Class, UniversalPredicate<? super Element,Nothing>, Nothing>() {

    @Override
    public UniversalPredicate<? super Element, Nothing> apply(Class argument) throws Nothing {
      return new TypePredicate(argument);
    }
  };
  ComboBoxSelector<Class,Element> selector = new ComboBoxSelector<>(contentProvider, labelProvider,function,2);
  return selector;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:34,代码来源:JavaDependencyOptions.java

示例3: doRefresh

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
@Override
public void doRefresh() throws InputException {
	try {
		Namespace ns = namespace();
		setDocument(_parser.load((Java7) ns.language()));
	} catch (Exception e) {
		throw new InputException(e);
	}
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:10,代码来源:LazyClassFileDocumentLoader.java

示例4: declarations

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
protected <D extends Declaration> List<? extends SelectionResult> declarations(DeclarationSelector<D> selector) throws LookupException {
	List<? extends SelectionResult> result = declarationContainer().declarations(selector);
	if(declarationContainer() != declarationContainer().defaultNamespace()) {
		new TypeFilter(Namespace.class).discard(result);
	}
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:8,代码来源:JavaNonNestedPackageLookupStrategy.java

示例5: getNullType

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
public Type getNullType(Namespace ns) {
	if(_nullType == null) {
		try {
			_nullType = findType("null type",ns);
		} catch (LookupException e) {
			throw new ChameleonProgrammerException(e);
		}
	}
	return _nullType;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:11,代码来源:Java7.java

示例6: box

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
public JavaTypeReference box(JavaTypeReference aRef, Namespace root) throws LookupException {
	String newFqn = _boxMap.get(((CrossReferenceWithName)aRef).name());
	if(newFqn == null) {
		//throw new LookupException("Type "+fqn+" cannot be converted through boxing.");
		return aRef;
	}
	JavaTypeReference result = createTypeReference(newFqn);
	result.setUniParent(root);
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:11,代码来源:Java7.java

示例7: createLocalLookupStrategy

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
public  LookupContext createLocalLookupStrategy(DeclarationContainer element) {
if(element instanceof Namespace) {
	return new JavaNonNestedPackageLookupStrategy((Namespace)element);
} else {
	return super.createLocalLookupStrategy(element);
}
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:8,代码来源:JavaLookupFactory.java

示例8: namespaces

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
public Collection<Namespace> namespaces() {
	return _provider.namespaceProvider().elements(view());
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:4,代码来源:CommandLineTool.java

示例9: refreshTargetDeclarationNames

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
@Override
public List<String> refreshTargetDeclarationNames(Namespace ns) {
  return Collections.singletonList(_parser.name());
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:5,代码来源:LazyClassFileDocumentLoader.java

示例10: refreshTargetDeclarationNames

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
@Override
public List<String> refreshTargetDeclarationNames(Namespace ns) {
	return Collections.singletonList(_name);
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:5,代码来源:LazyReflectiveDocumentLoader.java

示例11: createNamespaceDeclaration

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
@Override
public NamespaceDeclaration createNamespaceDeclaration(CrossReference<Namespace> cref) {
	return new JavaNamespaceDeclaration(cref);
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:5,代码来源:Java7Factory.java

示例12: getDefaultNamespace

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
public Namespace getDefaultNamespace() {
  return gJavaP.getDefaultNamespace();
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:4,代码来源:JavaParser.java

示例13: testMethodCalls

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的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

示例14: testSubtyping

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
public void testSubtyping() throws LookupException {
			Java7 language = (Java7)view().language();
			Namespace ns = view().namespace();
			BasicJavaTypeReference listOfStringRef = (BasicJavaTypeReference) language.createTypeReference("test.generics.List");
			listOfStringRef.addArgument(language.createEqualityTypeArgument(language.createTypeReference("java.lang.String")));
			listOfStringRef.setUniParent(ns);
			BasicJavaTypeReference tref2 = (BasicJavaTypeReference) language.createTypeReference("test.generics.List");
			tref2.addArgument(language.createEqualityTypeArgument(language.createTypeReference("java.lang.String")));
			tref2.setUniParent(ns);
			BasicJavaTypeReference tref3 = (BasicJavaTypeReference) language.createTypeReference("test.generics.SubList");
			tref3.addArgument(language.createEqualityTypeArgument(language.createTypeReference("java.lang.String")));
			tref3.setUniParent(ns);
			BasicJavaTypeReference listOfObjectRef = (BasicJavaTypeReference) language.createTypeReference("test.generics.List");
			listOfObjectRef.addArgument(language.createEqualityTypeArgument(language.createTypeReference("java.lang.Object")));
			listOfObjectRef.setUniParent(ns);
			BasicJavaTypeReference listOfExtendsCharSequenceRef = (BasicJavaTypeReference) language.createTypeReference("test.generics.List");
			listOfExtendsCharSequenceRef.addArgument(language.createExtendsWildcard(language.createTypeReference("java.lang.CharSequence")));
			listOfExtendsCharSequenceRef.setUniParent(ns);
			BasicJavaTypeReference tref6 = (BasicJavaTypeReference) language.createTypeReference("test.generics.List");
			tref6.addArgument(language.createExtendsWildcard(language.createTypeReference("java.lang.String")));
			tref6.setUniParent(ns);
			BasicJavaTypeReference listOfSuperOfStringRef = (BasicJavaTypeReference) language.createTypeReference("test.generics.List");
			listOfSuperOfStringRef.addArgument(language.createSuperWildcard(language.createTypeReference("java.lang.String")));
			listOfSuperOfStringRef.setUniParent(ns);
			BasicJavaTypeReference listOfSuperOfStringRefDuo = (BasicJavaTypeReference) language.createTypeReference("test.generics.List");
			listOfSuperOfStringRefDuo.addArgument(language.createSuperWildcard(language.createTypeReference("java.lang.String")));
			listOfSuperOfStringRefDuo.setUniParent(ns);
			BasicJavaTypeReference listSuperOfCharSequenceRef = (BasicJavaTypeReference) language.createTypeReference("test.generics.List");
			listSuperOfCharSequenceRef.addArgument(language.createSuperWildcard(language.createTypeReference("java.lang.CharSequence")));
			listSuperOfCharSequenceRef.setUniParent(ns);

			Type listOfString = listOfStringRef.getElement(); // test.generics.List<java.lang.String>
			Type type2 = tref2.getElement();
			Type type3 = tref3.getElement();
			Type listOfObject = listOfObjectRef.getElement(); // test.generics.List<java.lang.Object>
			Type listOfExtendsCharSequence = listOfExtendsCharSequenceRef.getElement(); // test.generics.List<? extends CharSequence>
			Type type6 = tref6.getElement();
			JavaType listOfSuperOfString = (JavaType) listOfSuperOfStringRef.getElement();
			JavaType listOfSuperOfStringDuo = (JavaType) listOfSuperOfStringRefDuo.getElement();
			Type listOfSuperOfStringCaptured = listOfSuperOfString.captureConversion();
			Type listOfSuperOfStringDuoCaptured = listOfSuperOfStringDuo.captureConversion();
			Type listSuperOfCharSequence = listSuperOfCharSequenceRef.getElement();
			assertTrue(type2.subtypeOf(listOfString));
			assertTrue(listOfString.sameAs(type2));
			assertTrue(listOfString.equals(type2));
			assertTrue(type3.subtypeOf(listOfString));
			assertFalse(listOfObject.subtypeOf(listOfString));
			assertFalse(listOfString.subtypeOf(listOfObject));
			assertTrue(listOfString.subtypeOf(listOfExtendsCharSequence));
			assertFalse(listOfObject.subtypeOf(listOfExtendsCharSequence));
			assertFalse(listOfExtendsCharSequence.subtypeOf(listOfString));
			assertTrue(type6.subtypeOf(listOfExtendsCharSequence));
			assertTrue(type2.subtypeOf(type6));
			assertFalse(listOfExtendsCharSequence.subtypeOf(type6));
			assertTrue(listOfObject.subtypeOf(listOfSuperOfString));
			assertTrue(listOfObject.subtypeOf(listSuperOfCharSequence));
//			assertTrue(listSuperOfCharSequence.subtypeOf(listOfSuperOfString));
			assertFalse(listOfExtendsCharSequence.subtypeOf(listSuperOfCharSequence));
			assertFalse(listOfExtendsCharSequence.subtypeOf(listOfSuperOfString));
			assertFalse(type6.subtypeOf(listSuperOfCharSequence));
			assertFalse(type6.subtypeOf(listOfSuperOfString));
			assertTrue(listOfSuperOfString.subtypeOf(listOfSuperOfStringDuo));
			assertFalse(listOfSuperOfStringCaptured.subtypeOf(listOfSuperOfStringDuoCaptured));
			assertTrue(listOfSuperOfStringCaptured.subtypeOf(listOfSuperOfString));
			assertTrue(listOfSuperOfStringCaptured.subtypeOf(listOfSuperOfStringDuo));
			assertTrue(listOfSuperOfStringDuoCaptured.subtypeOf(listOfSuperOfString));
			assertTrue(listOfSuperOfStringDuoCaptured.subtypeOf(listOfSuperOfStringDuo));
		}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:69,代码来源:TestCustomCases.java

示例15: JavaNamespaceDeclaration

import org.aikodi.chameleon.core.namespace.Namespace; //导入依赖的package包/类
public JavaNamespaceDeclaration(String fqn) {
	this(new NameReference<Namespace>(fqn, Namespace.class));
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:4,代码来源:JavaNamespaceDeclaration.java


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