本文整理匯總了Java中org.aikodi.chameleon.core.lookup.LookupException類的典型用法代碼示例。如果您正苦於以下問題:Java LookupException類的具體用法?Java LookupException怎麽用?Java LookupException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LookupException類屬於org.aikodi.chameleon.core.lookup包,在下文中一共展示了LookupException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: contains
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
@Override
public boolean contains(List<Type> first, List<Type> second)
throws LookupException {
// for varags, the last type of the second list is an array type.
int size = first.size();
int nbNormalArguments = second.size() - 1;
boolean result = size >= nbNormalArguments;
for(int i = 0; result && i < nbNormalArguments; i++) {
result = result && first.get(i).assignableTo(second.get(i));
}
Type other = ((ArrayType) second.get(nbNormalArguments)).elementType();
for(int i = nbNormalArguments; result && i < size; i++) {
result = result && first.get(i).assignableTo(other);
}
return result;
}
示例2: replaceSubobjectsOld
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
protected void replaceSubobjectsOld(Document javaDocument) {
javaDocument.apply(Subobject.class, javaSubobject -> {
try {
Type subobjectInterface = ooFactory(javaSubobject).createRegularType(subobjectInterfaceName(javaSubobject));
Subobject jloSubobject = (Subobject) javaSubobject.origin();
subobjectInterface.addModifier(new Interface());
SubtypeRelation javaSubtypeRelation = new SubtypeRelation(clone(javaSubobject.superClassReference()));
subobjectInterface.addInheritanceRelation(javaSubtypeRelation);
Method getter = createSubobjectGetterTemplate(jloSubobject, java(javaSubobject));
getter.addModifier(new Abstract());
getter.addModifier(new Public());
Type nearestAncestor = javaSubobject.nearestAncestor(Type.class);
nearestAncestor.add(getter);
applyToSortedTypeMemberDeclarators(jloSubobject.nearestAncestor(Type.class), m -> {
subobjectInterface.addParameter(TypeParameter.class, clone(m.parameter()));
});
javaSubobject.replaceWith(subobjectInterface);
} catch (LookupException e) {
throw new ChameleonProgrammerException(e);
}
} );
}
示例3: crossReferenceTargetType
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
protected UniversalPredicate<CrossReference,Nothing> crossReferenceTargetType(final AnalysisOptions options, final ObjectOrientedView view) throws LookupException {
final UniversalPredicate<Type, Nothing> targetPredicate = targetTypePredicate(options, view);
UniversalPredicate<CrossReference,LookupException> unguarded = new UniversalPredicate<CrossReference,LookupException>(CrossReference.class) {
@Override
public boolean uncheckedEval(CrossReference object) throws LookupException{
Declaration element = object.getElement();
Type t = element.lexical().nearestAncestorOrSelf(Type.class);
if(t != null) {
return targetPredicate.eval(t);
} else {
return true;
}
}
};
UniversalPredicate<CrossReference, Nothing> result = unguarded.guard(true);
return result;
}
示例4: removeNonMostSpecificMembers
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
protected
<X extends Declaration> List<SelectionResult<X>> removeNonMostSpecificMembers(List<SelectionResult<X>> current, final List<SelectionResult<X>> potential) throws LookupException {
final List<SelectionResult<X>> toAdd = new ArrayList<SelectionResult<X>>();
for(SelectionResult<X> mm: potential) {
Declaration m = (Declaration) mm.finalDeclaration();
boolean add = true;
Iterator<SelectionResult<X>> iterCurrent = current.iterator();
while(add && iterCurrent.hasNext()) {
Declaration alreadyInherited = (Declaration) iterCurrent.next().finalDeclaration();
// Remove the already inherited member if potentially inherited member m overrides or hides it.
if((alreadyInherited.sameAs(m) || alreadyInherited.compatibleSignature(m) || alreadyInherited.hides(m))) {
add = false;
} else if((!alreadyInherited.sameAs(m)) && (m.compatibleSignature(alreadyInherited) || m.hides(alreadyInherited))) {
iterCurrent.remove();
}
}
if(add == true) {
toAdd.add(mm);
}
}
current.addAll(toAdd);
return current;
}
示例5: assignableTo
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的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())
);
}
示例6: lci
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
private Type lci(Type first, Type second, Binder root) throws LookupException {
Type result = first;
if(first.nbTypeParameters(TypeParameter.class) > 0) {
result = Util.clone(first);
result.setUniParent(first.parent());
List<TypeArgument> firstArguments = arguments(first);
List<TypeArgument> secondArguments = arguments(second);
int size = firstArguments.size();
if(secondArguments.size() != size) {
throw new ChameleonProgrammerException("The number of type parameters from the first list: "+size+" is different from the number of type parameters in the second list: "+secondArguments.size());
}
List<TypeParameter> newParameters = lcta(firstArguments, secondArguments,root);
result.replaceAllParameters(TypeParameter.class,newParameters);
}
return result;
}
示例7: actualType
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
protected Type actualType() throws LookupException {
Element parent = parent();
if (parent instanceof ArrayCreationExpression) {
return ((ArrayCreationExpression)parent).getType();
}
else if (parent instanceof ArrayInitializer) {
Type type = ((ArrayInitializer)parent).getType();
ArrayType temp = (ArrayType)type;
return temp.elementType();
}
else if (parent instanceof Expression) {
return ((Expression)parent).getType();
}
else if (parent instanceof Variable) {
return ((Variable)parent).getType();
}
else if (parent instanceof JavaVariableDeclaration) {
return nearestAncestor(JavaVariableDeclaration.class).typeReference().getElement();
}
else {
throw new ChameleonProgrammerException("Cannot determine type of array initializer based on the parent.");
}
}
示例8: replaceFields
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
protected void replaceFields(Document javaDocument) throws LookupException {
javaDocument.apply(new Action<MemberVariableDeclarator,LookupException>(MemberVariableDeclarator.class) {
/**
* @throws LookupException
* @{inheritDoc}
*/
@Override
public void doPerform(MemberVariableDeclarator javaMemberVariableDeclarator) throws LookupException {
VariableDeclaration variableDeclaration = javaMemberVariableDeclarator.variableDeclarations().get(0);
replaceFieldReferences(javaDocument, variableDeclaration);
Method getter = createGetterTemplate(javaMemberVariableDeclarator);
getter.addModifier(new Abstract());
getter.addModifier(new Public());
javaMemberVariableDeclarator.replaceWith(getter);
Method setter = createSetterTemplate(javaMemberVariableDeclarator);
setter.addModifier(new Abstract());
setter.addModifier(new Public());
getter.nearestAncestor(Type.class).add(setter);
}
} );
}
示例9: unassigned
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
public List<TypeParameter> unassigned() throws LookupException {
List<TypeParameter> result = new ArrayList<TypeParameter>();
//FIXME Avoid cloning.
//PERFORMANCE
List<TypeAssignment> local = new ArrayList<>(assignments());
for(TypeParameter parameter: typeParameters()) {
int position = -1;
int index = 0;
for(TypeAssignment assignment: local) {
if(assignment.parameter().sameAs(parameter)) {
position = index;
break;
}
index++;
}
if(position >= 0) {
local.remove(position);
} else {
result.add(parameter);
}
}
return result;
}
示例10: createImplementation
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
/**
* Convert the given document, which is a clone from
* a JLo document to Java. The elements in the document
* must have their origin set to the corresponding element
* in the JLo document such that the translation can
* query the original model if needed. The given
* document cannot be used for that, as it will be modified.
*
* @param javaDocument The document to be converted to Java.
* @return
* @throws LookupException
*/
public Document createImplementation(Document javaDocument) throws LookupException {
// All normal methodes will be part of the interface as default methods.
// The support for multiple inheritance makes it much easier as we
// don't have to clone methods out of their context.
removeNormalMethods(javaDocument);
// Each JLo class is represented by a Java interface and a class that
// implements the interface, and contains the fields.
// The class must implement the interface.
implementOwnInterfaces(javaDocument);
replaceSubobjects(javaDocument);
addFields(javaDocument);
renameConstructorCalls(javaDocument);
addTypeParameterToOwnClass(javaDocument);
return javaDocument;
}
示例11: processSuperTypeConstraints
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
private void processSuperTypeConstraints() throws LookupException {
Java7 language = null;
for(TypeParameter p: typeParameters()) {
boolean hasSuperConstraints = false;
for(SecondPhaseConstraint constraint: constraints()) {
if(constraint instanceof SupertypeConstraint && constraint.typeParameter().sameAs(p)) {
hasSuperConstraints = true;
break;
}
}
if(hasSuperConstraints) {
List<JavaTypeReference> Us = Us(p, SupertypeConstraint.class);
if(language == null) {
language = p.language(Java7.class);
}
add(new ActualTypeAssignment(p, leastUpperBound(Us,language)));
}
}
}
示例12: diamondConstructors
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
public List<Declaration> diamondConstructors(List<? extends Declaration> selectionCandidates) throws LookupException {
List<Declaration> result = new ArrayList<Declaration>();
for (Declaration decl : selectionCandidates) {
result.add(createDiamondConstructorDummy(decl));
}
return result;
}
示例13: lookupContext
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
@Override
public LookupContext lookupContext(Element child) throws LookupException {
if(child.origin() == child) {
throw new ChameleonProgrammerException("A child of a component stub has itself as origin.");
}
return child.origin().lexicalContext(); // this is wrong. It should behave like a subclass: look for inheritable declarations,
}
示例14: analyze
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
public void analyze(OutputStreamWriter writer, MessageFormatter formatter) throws LookupException, InputException, IOException {
List<Analysis<?,?,? extends Exception>> analyses = new ArrayList<>();
analyses.add(new IncomingLeak());
analyses.add(new OutgoingLeak());
analyses.add(new SuspiciousCastAnalysis());
// analyses.add(new PublicFieldViolation());
analyses.add(new NonPrivateNonFinalField());
analyses.add(new EmptyAbstractType());
//analyses.add(new NonDefensiveFieldAssignment());
analyses.add(new AssignmentAsExpression());
analyses.add(new EqualsWithoutHashCode());
analyze(analyses, writer,formatter, Handler.<Exception>printer(System.out), Handler.<Exception>printer(System.out));
}
示例15: substituteRHS
import org.aikodi.chameleon.core.lookup.LookupException; //導入依賴的package包/類
public void substituteRHS(JavaTypeReference tref, EqualTypeConstraint eq) throws LookupException {
for(SecondPhaseConstraint constraint: constraints()) {
if(constraint != eq) {
if(constraint.typeParameter().sameAs(eq.typeParameter())) {
remove(constraint);
} else {
final TypeParameter tp = eq.typeParameter();
JavaTypeReference uRef = constraint.URef();
NonLocalJavaTypeReference.replace(tref, tp, uRef);
}
}
}
}