本文整理汇总了Java中org.aikodi.chameleon.oo.language.ObjectOrientedLanguage类的典型用法代码示例。如果您正苦于以下问题:Java ObjectOrientedLanguage类的具体用法?Java ObjectOrientedLanguage怎么用?Java ObjectOrientedLanguage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectOrientedLanguage类属于org.aikodi.chameleon.oo.language包,在下文中一共展示了ObjectOrientedLanguage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: contains
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
@Override
public boolean contains(Declaration fst, Declaration snd) throws LookupException {
Declaration first = fst;
Declaration second = snd;
boolean result = false;
if((first instanceof NormalMethod) && (second instanceof NormalMethod)) {
result = first.nearestAncestor(Type.class).subtypeOf(second.nearestAncestor(Type.class)) &&
(first.is(first.language(ObjectOrientedLanguage.class).CLASS) == Ternary.TRUE) &&
first.sameSignatureAs(second);
} else if(first instanceof RegularMemberVariable && second instanceof RegularMemberVariable) {
result = first.nearestAncestor(Type.class).subtypeOf(second.nearestAncestor(Type.class)) &&
first.sameSignatureAs(second);
} else if(first instanceof Type && second instanceof Type) {
result = first.nearestAncestor(Type.class).subtypeOf(second.nearestAncestor(Type.class)) &&
first.sameSignatureAs(second);
}
return result;
}
示例2: assignableTo
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
public boolean assignableTo(Type other) throws LookupException {
View view = view();
ObjectOrientedLanguage language = view.language(ObjectOrientedLanguage.class);
Type objType = language.getDefaultSuperClass(view.namespace());
return super.assignableTo(other) ||
( // Reference type
elementType().subtypeOf(objType) &&
(other instanceof ArrayType) &&
elementType().assignableTo(((ArrayType)other).elementType())
) ||
( // Primitive type
(! elementType().subtypeOf(objType)) &&
(other instanceof ArrayType) &&
elementType().equals(((ArrayType)other).elementType())
);
}
示例3: implicitNonMemberInheritanceRelations
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
@Override
public List<InheritanceRelation> implicitNonMemberInheritanceRelations() {
//FIXME speed avoid creating collection
String defaultSuperClassFQN = language(ObjectOrientedLanguage.class).getDefaultSuperClassFQN();
if(explicitNonMemberInheritanceRelations().isEmpty() &&
(! getFullyQualifiedName().equals(defaultSuperClassFQN)) //"java.lang.Object"
) {
InheritanceRelation relation = new SubtypeRelation(language(ObjectOrientedLanguage.class).createTypeReference(defaultSuperClassFQN));
relation.setUniParent(this);
relation.setMetadata(new TagImpl(), IMPLICIT_CHILD);
List<InheritanceRelation> result = new ArrayList<InheritanceRelation>();
result.add(relation);
return result;
} else {
return Collections.EMPTY_LIST;
}
}
示例4: impliedProperties
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
/**
* A Java constructor is not inheritable.
*/
/*@
@ also public behavior
@
@ post \result.contains(language().CONSTRUCTOR);
@*/
public PropertySet<Element,ChameleonProperty> impliedProperties() {
PropertySet<Element,ChameleonProperty> result = super.impliedProperties();
result.add(language(ObjectOrientedLanguage.class).INHERITABLE.inverse());
return result;
}
示例5: process
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
public List<SecondPhaseConstraint> process() throws LookupException {
List<SecondPhaseConstraint> result = new ArrayList<SecondPhaseConstraint>();
// If A is the type of null, no constraint is implied on Tj.
Type A = A();
View view = A.view();
ObjectOrientedLanguage l = view.language(ObjectOrientedLanguage.class);
if(! A.equals(l.getNullType(view.namespace()))) {
result.addAll(processFirstLevel());
}
return result;
}
示例6: replace
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
/**
* Replace all references to 'declarator' in 'in' with copies of 'replacement'.
* @param replacement
* @param declarator
* @param in
* @param kind
* @return
* @throws LookupException
*/
public static <E extends Element> E replace(TypeReference replacement, final Declaration declarator, E in, Class<E> kind) throws LookupException {
ObjectOrientedLanguage lang = in.language(ObjectOrientedLanguage.class);
E result = in;
Predicate<BasicTypeReference, LookupException> predicate = object -> object.getDeclarator().sameAs(declarator);
List<BasicTypeReference> crefs = in.descendants(BasicTypeReference.class,
predicate);
if(in instanceof BasicTypeReference) {
BasicTypeReference in2 = (BasicTypeReference) in;
if(predicate.eval(in2)) {
crefs.add(in2);
}
}
for(BasicTypeReference cref: crefs) {
TypeReference substitute;
Element oldParent = replacement.parent();
if(replacement.isDerived()) {
// replacement.setUniParent(null);
substitute = lang.createNonLocalTypeReference(Util.clone(replacement),oldParent);
substitute.setOrigin(replacement);
} else {
substitute = lang.createNonLocalTypeReference(Util.clone(replacement),oldParent);
}
if(! cref.isDerived()) {
SingleAssociation crefParentLink = cref.parentLink();
crefParentLink.getOtherRelation().replace(crefParentLink, substitute.parentLink());
} else {
substitute.setUniParent(in.parent());
}
if(cref == in) {
if(kind.isInstance(substitute)) {
result = (E) substitute;
} else {
throw new ChameleonProgrammerException("The type reference passed to replace must be replaced as a whole, but the kind that was given is more specific than the newly created type reference.");
}
}
}
return result;
}
示例7: processUnresolvedParameters
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
private void processUnresolvedParameters() throws LookupException {
// JLS 15.12.2.8
// In context of assignment with type S.
if(inContextOfAssignmentConversion()) {
processUnresolved(S());
} else {
// Perform under the assumption that S is java.lang.Object
if(! unresolvedParameters().isEmpty()) {
View view = invocation().view();
ObjectOrientedLanguage language = (ObjectOrientedLanguage) view.language();
processUnresolved((JavaTypeReference) language.createTypeReferenceInNamespace(language.getDefaultSuperClassFQN(),view.namespace()));
}
}
}
示例8: checkDefined
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
public boolean checkDefined(Declaration member) throws LookupException {
Ternary temp1 = member.is(member.language(ObjectOrientedLanguage.class).DEFINED);
boolean defined1;
if(temp1 == Ternary.TRUE) {
defined1 = true;
} else if (temp1 == Ternary.FALSE) {
defined1 = false;
} else {
temp1 = member.is(member.language(ObjectOrientedLanguage.class).DEFINED);
throw new LookupException("The definedness of the first element could not be determined.");
}
return defined1;
}
示例9: implicitNonMemberInheritanceRelations
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
@Override
public List<InheritanceRelation> implicitNonMemberInheritanceRelations() {
if(explicitNonMemberInheritanceRelations().isEmpty() && (! "Object".equals(name())) && (! getFullyQualifiedName().equals("java.lang.Object"))) {
TypeReference objectTypeReference = language(ObjectOrientedLanguage.class).createTypeReference("java.lang.Object");
InheritanceRelation relation = new SubtypeRelation(objectTypeReference);
relation.setUniParent(this);
relation.setMetadata(new TagImpl(), IMPLICIT_CHILD);
List<InheritanceRelation> result = ImmutableList.of(relation);
return result;
} else {
return Collections.EMPTY_LIST;
}
}
示例10: inherentProperties
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
@Override
public PropertySet<Element, ChameleonProperty> inherentProperties() {
PropertySet<Element, ChameleonProperty> result = new PropertySet<Element, ChameleonProperty>();
ObjectOrientedLanguage language = language(ObjectOrientedLanguage.class);
result.add(language.ABSTRACT.inverse());
result.add(language.CLASS.inverse());
result.add(language.REFINABLE.inverse());
return result;
}
示例11: implicitConstructors
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
protected List<NormalMethod> implicitConstructors() throws LookupException {
TypeReference tref = typeReference();
Type writtenType = tref.getElement();
List<NormalMethod> superMembers = writtenType.localMembers(NormalMethod.class);
CollectionOperations.filter(superMembers, m -> m.is(language(ObjectOrientedLanguage.class).CONSTRUCTOR) == Ternary.TRUE);
//if the super type is an interface, there will be no constructor, so we must
//create a default constructor.
if(superMembers.isEmpty()) {
superMembers.add(defaultDefaultConstructor(tref, writtenType));
}
return superMembers;
}
示例12: inherentProperties
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
/**
* A Java reference type is not overridable. A such, if B extends A, and both
* A and B have a nested class with name C, then B.C does not override A.C.
*/
@Override
public PropertySet<Element, ChameleonProperty> inherentProperties() {
PropertySet<Element, ChameleonProperty> result = new PropertySet<Element, ChameleonProperty>();
result.add(language(ObjectOrientedLanguage.class).OVERRIDABLE.inverse());
return result;
}
示例13: selector
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
public DeclarationSelector<Declaration> selector() {
return new TwoPhaseDeclarationSelector<Declaration>() {
// @Override
// public WeakPartialOrder<Member> order() {
// return new SelectorWithoutOrder.EqualityOrder<Member>();
// }
@Override
protected void applyOrder(List<SelectionResult<Declaration>> tmp) throws LookupException {
}
@Override
public boolean selectedBasedOnName(Signature signature) throws LookupException {
return signature.name().equals(name());
}
@Override
public Class<Declaration> selectedClass() {
return Declaration.class;
}
@Override
public boolean selectedRegardlessOfName(Declaration declaration) throws LookupException {
ObjectOrientedLanguage language = (ObjectOrientedLanguage) declaration.language(ObjectOrientedLanguage.class);
return declaration.is(language.CLASS) == Ternary.TRUE;
}
@Override
public String selectionName(DeclarationContainer container) throws LookupException {
return name();
}
};
}
示例14: erasure
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
@Override
public Type erasure() {
Element el = farthestOrigin();
if(el != this) {
return ((JavaType)el).erasure();
}
// I am not sure whether this is correct. The memberInheritanceRelations are not erased in RawType.
Type outmostType = lexical().farthestAncestor(Type.class);
if(outmostType == null) {
outmostType = this;
}
RawType outer;
if(outmostType instanceof RawType) {
outer = (RawType) outmostType;
} else {
outer = new RawType(outmostType);
}
RawType current = outer;
List<Type> outerTypes = ancestors(Type.class);
outerTypes.add(0, this);
int size = outerTypes.size();
Factory expressionFactory = language(ObjectOrientedLanguage.class).plugin(Factory.class);
for(int i = size - 2; i>=0;i--) {
NameReference<RawType> simpleRef = expressionFactory.createNameReference(outerTypes.get(i).name(), RawType.class);
simpleRef.setUniParent(current);
try {
current = simpleRef.getElement();
} catch (LookupException e) {
e.printStackTrace();
throw new ChameleonProgrammerException("An inner type of a newly created outer raw type cannot be found",e);
}
}
return current;
}
示例15: language
import org.aikodi.chameleon.oo.language.ObjectOrientedLanguage; //导入依赖的package包/类
public ObjectOrientedLanguage language() {
return (ObjectOrientedLanguage) _view.language();
}