You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.0 KiB
101 lines
2.0 KiB
7 years ago
|
/*
|
||
|
* Copyright (c) 2017 - present Facebook, Inc.
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This source code is licensed under the BSD style license found in the
|
||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||
|
*/
|
||
|
// makes it easier to mock graphql types
|
||
|
package com.facebook.graphql.model;
|
||
|
|
||
|
import java.util.List;
|
||
|
|
||
|
abstract class A {
|
||
|
abstract A getA();
|
||
|
abstract B getB();
|
||
|
abstract C getC();
|
||
|
}
|
||
|
|
||
|
abstract class B {
|
||
|
abstract C getC();
|
||
|
}
|
||
|
|
||
|
abstract class C {
|
||
|
abstract D getD();
|
||
|
}
|
||
|
|
||
|
class D {}
|
||
|
|
||
|
abstract class GraphQLStory {
|
||
|
|
||
|
public abstract List getActors();
|
||
|
|
||
|
}
|
||
|
|
||
|
class LithoTest {
|
||
|
|
||
|
void /*basic chain*/onCreateLayout(A a) {
|
||
|
a.getB().getC().getD();
|
||
|
}
|
||
|
|
||
|
void /*sibling chain*/onCreateLayout(A a, int i) {
|
||
|
a.getB().getC().getD();
|
||
|
a.getC().getD();
|
||
|
}
|
||
|
|
||
|
void /*split chain*/onCreateLayout(A a, int i1, int i2) {
|
||
|
B b = a.getB();
|
||
|
C c = b.getC();
|
||
|
c.getD();
|
||
|
}
|
||
|
|
||
|
|
||
|
void chainFromActual1(B b) {
|
||
|
b.getC().getD();
|
||
|
}
|
||
|
|
||
|
void chainFromActual2(C c) {
|
||
|
c.getD();
|
||
|
}
|
||
|
|
||
|
void /*chain rooted in actual*/onCreateLayout(A a, boolean b) {
|
||
|
chainFromActual1(a.getB());
|
||
|
}
|
||
|
|
||
|
void /*local chain + interproc chain*/onCreateLayout(A a, char ch) {
|
||
|
C c = a.getB().getC();
|
||
|
chainFromActual2(c);
|
||
|
}
|
||
|
|
||
|
// conditional getters
|
||
|
static GraphQLStory getPrimaryActor(GraphQLStory story) {
|
||
|
List actors = story.getActors();
|
||
|
return actors != null && actors.size() > 0 ? (GraphQLStory) actors.get(0) : null;
|
||
|
}
|
||
|
|
||
|
void /*conditional getters on formal*/onCreateLayout(GraphQLStory story) {
|
||
|
getPrimaryActor(story).toString();
|
||
|
}
|
||
|
|
||
|
native static GraphQLStory getStory();
|
||
|
|
||
|
void /*conditional getters on local*/onCreateLayout() {
|
||
|
GraphQLStory story = getStory();
|
||
|
getPrimaryActor(story).toString();
|
||
|
}
|
||
|
|
||
|
void /*cycle*/onCreateLayout(A a, float f) {
|
||
|
a = a.getA();
|
||
|
}
|
||
|
|
||
|
void cycle(A a) {
|
||
|
a = a.getA();
|
||
|
}
|
||
|
|
||
|
void /*interprocedural cycle*/onCreateLayout(A a, double d) {
|
||
|
cycle(a);
|
||
|
}
|
||
|
|
||
|
}
|