本文整理汇总了Java中org.walkmod.javalang.ast.expr.ObjectCreationExpr类的典型用法代码示例。如果您正苦于以下问题:Java ObjectCreationExpr类的具体用法?Java ObjectCreationExpr怎么用?Java ObjectCreationExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectCreationExpr类属于org.walkmod.javalang.ast.expr包,在下文中一共展示了ObjectCreationExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadThisSymbol
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
private void loadThisSymbol(ObjectCreationExpr n, A arg) {
if (AnonymousClassUtil.isAnonymousClass(n) && AnonymousClassUtil.needsSymbolData(n)) {
ScopeLoader scopeLoader = new ScopeLoader(typeTable, expressionTypeAnalyzer, actionProvider);
Scope scope = n.accept(scopeLoader, symbolTable);
if (scope != null) {
symbolTable.pushScope(scope);
}
if (n.getAnonymousClassBody() != null) {
for (BodyDeclaration member : n.getAnonymousClassBody()) {
member.accept(this, arg);
}
}
if (scope != null) {
symbolTable.popScope();
}
}
}
示例2: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
@Override
public void visit(ObjectCreationExpr n, A arg) {
loadThisSymbol(n, arg);
SymbolType[] argsType = argsType(n.getArgs());
SymbolType scopeType = (SymbolType) n.getType().getSymbolData();
symbolTable.lookUpSymbolForRead(scopeType.getClazz().getSimpleName(), n, scopeType, argsType,
ReferenceType.METHOD);
List<Type> typeargs = n.getTypeArgs();
if (typeargs != null) {
for (Type type : typeargs) {
type.accept(this, arg);
}
}
}
示例3: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
public void visit(ObjectCreationExpr n, T context) {
boolean restore = false;
if (startingNode == null) {
startingNode = n;
restore = true;
}
List<BodyDeclaration> members = n.getAnonymousClassBody();
if (members != null) {
SymbolType st = symbolTable.getType("this", ReferenceType.VARIABLE);
n.setSymbolData(st);
String name = st.getName();
String oldCtx = contextName;
contextName = name;
processMembers(members, context);
contextName = oldCtx;
}
if (restore) {
startingNode = null;
}
}
示例4: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
@Override
public void visit(ObjectCreationExpr n, A arg) {
if (n.getScope() != null) {
n.getScope().accept(this, arg);
}
if (n.getTypeArgs() != null) {
for (Type t : n.getTypeArgs()) {
t.accept(this, arg);
}
}
n.getType().accept(this, arg);
if (!AnonymousClassUtil.isAnonymousClass(n) || AnonymousClassUtil.needsSymbolData(n)) {
SymbolType st = (SymbolType) n.getType().getSymbolData();
resolveConstructor(n, n.getArgs(), st, arg);
}
// we need to update the symbol table
if (semanticVisitor != null) {
n.accept(semanticVisitor, arg);
}
}
示例5: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
public R visit(ObjectCreationExpr n, A arg) {
if (n.getScope() != null) {
n.getScope().accept(this, arg);
}
if (n.getTypeArgs() != null) {
for (Type t : n.getTypeArgs()) {
t.accept(this, arg);
}
}
n.getType().accept(this, arg);
if (n.getArgs() != null) {
for (Expression e : n.getArgs()) {
e.accept(this, arg);
}
}
if (n.getAnonymousClassBody() != null) {
for (BodyDeclaration member : n.getAnonymousClassBody()) {
member.accept(this, arg);
}
}
return null;
}
示例6: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
public Boolean visit(ObjectCreationExpr n1, Node arg) {
ObjectCreationExpr n2 = (ObjectCreationExpr) arg;
if (!nodeEquals(n1.getScope(), n2.getScope())) {
return Boolean.FALSE;
}
if (!nodeEquals(n1.getType(), n2.getType())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getAnonymousClassBody(), n2.getAnonymousClassBody())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getArgs(), n2.getArgs())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例7: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
public void visit(ObjectCreationExpr n, A arg) {
if (n.getScope() != null) {
n.getScope().accept(this, arg);
}
if (n.getTypeArgs() != null) {
for (Type t : n.getTypeArgs()) {
t.accept(this, arg);
}
}
n.getType().accept(this, arg);
if (n.getArgs() != null) {
for (Expression e : n.getArgs()) {
e.accept(this, arg);
}
}
if (n.getAnonymousClassBody() != null) {
for (BodyDeclaration member : n.getAnonymousClassBody()) {
member.accept(this, arg);
}
}
}
示例8: testAddAnnotationInInnerClass
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
@Test
public void testAddAnnotationInInnerClass() throws ParseException {
String code = "public class Foo {\n\tpublic void aux(){\n\t\t new X(){\n\t\t\tvoid hello(){\n\t\t\t\ty();\n\t\t\t}\n\t\t};\n\t}\n}";
DefaultJavaParser parser = new DefaultJavaParser();
CompilationUnit cu = parser.parse(code, false);
CompilationUnit cu2 = parser.parse(code, false);
MethodDeclaration md = (MethodDeclaration) cu.getTypes().get(0).getMembers().get(0);
List<Statement> stmts = md.getBody().getStmts();
ExpressionStmt stmt = (ExpressionStmt) stmts.get(0);
ObjectCreationExpr oce = (ObjectCreationExpr) stmt.getExpression();
List<BodyDeclaration> body = oce.getAnonymousClassBody();
MethodDeclaration md2 = (MethodDeclaration) body.get(0);
List<AnnotationExpr> annotations = new LinkedList<AnnotationExpr>();
annotations.add(new MarkerAnnotationExpr(new NameExpr("Override")));
md2.setAnnotations(annotations);
List<Action> actions = getActions(cu2, cu);
Assert.assertEquals(1, actions.size());
assertCode(actions, code,
"public class Foo {\n\tpublic void aux(){\n\t\t new X(){\n\t\t\[email protected]\n\t\t\tvoid hello(){\n\t\t\t\ty();\n\t\t\t}\n\t\t};\n\t}\n}");
}
示例9: getActions
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
@Override
public List<SymbolAction> getActions(ObjectCreationExpr n) {
RemoveUnusedSymbolsAction unusedSymbols = new RemoveUnusedSymbolsAction(siblings.peek());
actions = new LinkedList<SymbolAction>();
actions.add(unusedSymbols);
siblings.push(n.getAnonymousClassBody());
return actions;
}
示例10: isDisabledCode
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
static boolean isDisabledCode(ObjectCreationExpr n) {
Node child = n;
Node node = child.getParentNode();
while (node != null) {
if (node instanceof IfStmt) {
IfStmt ifs = (IfStmt) node;
if (child == ifs.getThenStmt() && isCompilationDisabledCondition(ifs.getCondition())) {
return true;
}
}
child = node;
node = child.getParentNode();
}
return false;
}
示例11: argTypes
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
private ArgTypes argTypes(List<Expression> args, A arg) {
boolean hasFunctionalExpressions = false;
SymbolType[] symbolTypes = null;
if (args != null) {
symbolTypes = new SymbolType[args.size()];
int i = 0;
for (Expression e : args) {
if (!(e instanceof LambdaExpr) && !(e instanceof MethodReferenceExpr)) {
e.accept(this, arg);
SymbolType argType = null;
if (e instanceof ObjectCreationExpr) {
ObjectCreationExpr aux = (ObjectCreationExpr) e;
argType = (SymbolType) aux.getType().getSymbolData();
} else {
argType = (SymbolType) e.getSymbolData();
}
symbolTypes[i] = argType;
} else {
hasFunctionalExpressions = true;
}
i++;
}
} else {
symbolTypes = new SymbolType[0];
}
return new ArgTypes(symbolTypes, hasFunctionalExpressions);
}
示例12: doPush
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
@Override
public void doPush(Symbol<?> symbol, SymbolTable table) throws Exception {
Node node = symbol.getLocation();
if (node instanceof TypeDeclaration || node instanceof ObjectCreationExpr) {
if (symbol.getName().equals("this")) {
LoadInheritedNestedClasses<?> vis = new LoadInheritedNestedClasses<Object>(table);
node.accept(vis, null);
}
}
}
示例13: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
@Override
public void visit(ObjectCreationExpr n, A ctx) {
n.accept(typeTable, null);
ClassOrInterfaceType type = n.getType();
List<ClassOrInterfaceType> extendsList = new LinkedList<ClassOrInterfaceType>();
extendsList.add(type);
loadExtendsOrImplements(extendsList);
}
示例14: doPush
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
@Override
public void doPush(Symbol<?> symbol, SymbolTable table) throws Exception {
if (symbol.getName().equals("this")) {
Node node = symbol.getLocation();
if (node instanceof TypeDeclaration || node instanceof ObjectCreationExpr
|| node instanceof EnumConstantDeclaration) {
node.accept(new FieldsPopulator(table), table.getScopes().peek());
}
}
}
示例15: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入依赖的package包/类
@Override
public void visit(ObjectCreationExpr o, Scope scope) {
if (!scope.hasFieldsLoaded()) {
table.pushScope(scope);
List<ClassOrInterfaceType> types = new LinkedList<ClassOrInterfaceType>();
types.add(o.getType());
loadExtendsOrImplements(types);
loadFields(o.getAnonymousClassBody(), scope);
table.popScope(true);
}
}