Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apex] Summit-AST Apex module - Part 4 - statements #4206

Merged
Merged
Expand Up @@ -4,14 +4,11 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;
import com.google.summit.ast.statement.BreakStatement;

public class ASTBreakStatement extends AbstractApexNode.Single<Node> {
public class ASTBreakStatement extends AbstractApexNode.Single<BreakStatement> {

@Deprecated
@InternalApi
public ASTBreakStatement(Node breakStatement) {
ASTBreakStatement(BreakStatement breakStatement) {
super(breakStatement);
}

Expand Down
Expand Up @@ -4,15 +4,12 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;
import com.google.summit.ast.statement.TryStatement;

public class ASTCatchBlockStatement extends AbstractApexCommentContainerNode<Node> {
public class ASTCatchBlockStatement extends AbstractApexCommentContainerNode<TryStatement.CatchBlock> {

@Deprecated
@InternalApi
public ASTCatchBlockStatement(Node catchBlockStatement) {
super(catchBlockStatement);
ASTCatchBlockStatement(TryStatement.CatchBlock catchBlock) {
super(catchBlock);
}

@Override
Expand All @@ -21,20 +18,14 @@ public Object jjtAccept(ApexParserVisitor visitor, Object data) {
}

public String getExceptionType() {
// return String.valueOf(node.getTypeRef());
// TODO(b/239648780)
return null;
return node.getExceptionVariable().getType().asCodeString();
}

public String getVariableName() {
// if (node.getVariable() != null) {
// return node.getVariable().getName();
// }
// TODO(b/239648780)
return null;
return node.getExceptionVariable().getId().getString();
}

public ASTBlockStatement getBody() {
return (ASTBlockStatement) getChild(0);
return getFirstChildOfType(ASTBlockStatement.class);
}
}
Expand Up @@ -5,13 +5,10 @@
package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;

public class ASTConstructorPreambleStatement extends AbstractApexNode.Single<Node> {

@Deprecated
@InternalApi
public ASTConstructorPreambleStatement(Node constructorPreambleStatement) {
ASTConstructorPreambleStatement(Node constructorPreambleStatement) {
super(constructorPreambleStatement);
}

Expand Down
Expand Up @@ -4,14 +4,11 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;
import com.google.summit.ast.statement.ContinueStatement;

public class ASTContinueStatement extends AbstractApexNode.Single<Node> {
public class ASTContinueStatement extends AbstractApexNode.Single<ContinueStatement> {

@Deprecated
@InternalApi
public ASTContinueStatement(Node continueStatement) {
ASTContinueStatement(ContinueStatement continueStatement) {
super(continueStatement);
}

Expand Down
Expand Up @@ -5,13 +5,10 @@
package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;

public class ASTDmlDeleteStatement extends AbstractApexNode.Single<Node> {

@Deprecated
@InternalApi
public ASTDmlDeleteStatement(Node dmlDeleteStatement) {
ASTDmlDeleteStatement(Node dmlDeleteStatement) {
super(dmlDeleteStatement);
}

Expand Down
Expand Up @@ -5,13 +5,10 @@
package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;

public class ASTDmlInsertStatement extends AbstractApexNode.Single<Node> {

@Deprecated
@InternalApi
public ASTDmlInsertStatement(Node dmlInsertStatement) {
ASTDmlInsertStatement(Node dmlInsertStatement) {
super(dmlInsertStatement);
}

Expand Down
Expand Up @@ -5,13 +5,10 @@
package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;

public class ASTDmlMergeStatement extends AbstractApexNode.Single<Node> {

@Deprecated
@InternalApi
public ASTDmlMergeStatement(Node dmlMergeStatement) {
ASTDmlMergeStatement(Node dmlMergeStatement) {
super(dmlMergeStatement);
}

Expand Down
Expand Up @@ -5,13 +5,10 @@
package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;

public class ASTDmlUndeleteStatement extends AbstractApexNode.Single<Node> {

@Deprecated
@InternalApi
public ASTDmlUndeleteStatement(Node dmlUndeleteStatement) {
ASTDmlUndeleteStatement(Node dmlUndeleteStatement) {
super(dmlUndeleteStatement);
}

Expand Down
Expand Up @@ -5,13 +5,10 @@
package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;

public class ASTDmlUpdateStatement extends AbstractApexNode.Single<Node> {

@Deprecated
@InternalApi
public ASTDmlUpdateStatement(Node dmlUpdateStatement) {
ASTDmlUpdateStatement(Node dmlUpdateStatement) {
super(dmlUpdateStatement);
}

Expand Down
Expand Up @@ -5,13 +5,10 @@
package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;

public class ASTDmlUpsertStatement extends AbstractApexNode.Single<Node> {

@Deprecated
@InternalApi
public ASTDmlUpsertStatement(Node dmlUpsertStatement) {
ASTDmlUpsertStatement(Node dmlUpsertStatement) {
super(dmlUpsertStatement);
}

Expand Down
Expand Up @@ -4,15 +4,12 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;
import com.google.summit.ast.statement.DoWhileLoopStatement;

public class ASTDoLoopStatement extends AbstractApexNode.Single<Node> {
public class ASTDoLoopStatement extends AbstractApexNode.Single<DoWhileLoopStatement> {

@Deprecated
@InternalApi
public ASTDoLoopStatement(Node doLoopStatement) {
super(doLoopStatement);
ASTDoLoopStatement(DoWhileLoopStatement doWhileLoopStatement) {
super(doWhileLoopStatement);
}

@Override
Expand Down
Expand Up @@ -4,16 +4,14 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import com.google.summit.ast.statement.SwitchStatement;

public final class ASTElseWhenBlock extends AbstractApexNode.Single<Node> {
public final class ASTElseWhenBlock extends AbstractApexNode.Single<SwitchStatement.WhenElse> {


ASTElseWhenBlock(Node node) {
super(node);
ASTElseWhenBlock(SwitchStatement.WhenElse whenElse) {
super(whenElse);
}


@Override
public Object jjtAccept(ApexParserVisitor visitor, Object data) {
return visitor.visit(this, data);
Expand Down
Expand Up @@ -4,42 +4,16 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.statement.ExpressionStatement;
import com.google.summit.ast.expression.Expression;

public class ASTExpressionStatement extends AbstractApexNode.Single<ExpressionStatement> {
public class ASTExpressionStatement extends AbstractApexNode.Single<Expression> {
aaronhurst-google marked this conversation as resolved.
Show resolved Hide resolved

ASTExpressionStatement(ExpressionStatement expressionStatement) {
super(expressionStatement);
ASTExpressionStatement(Expression expression) {
super(expression);
}

@Override
public Object jjtAccept(ApexParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}

/*
private int beginColumnDiff = -1;

@Override
public int getBeginColumn() {
if (beginColumnDiff > -1) {
return super.getBeginColumn() - beginColumnDiff;
}

if (getNumChildren() > 0 && getChild(0) instanceof ASTMethodCallExpression) {
ASTMethodCallExpression methodCallExpression = (ASTMethodCallExpression) getChild(0);

int fullLength = methodCallExpression.getFullMethodName().length();
int nameLength = methodCallExpression.getMethodName().length();
if (fullLength > nameLength) {
beginColumnDiff = fullLength - nameLength;
} else {
beginColumnDiff = 0;
}
}

return super.getBeginColumn() - beginColumnDiff;
}
*/
// TODO(b/239648780)
}
Expand Up @@ -4,15 +4,12 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;
import com.google.summit.ast.statement.EnhancedForLoopStatement;

public class ASTForEachStatement extends AbstractApexNode.Single<Node> {
public class ASTForEachStatement extends AbstractApexNode.Single<EnhancedForLoopStatement> {

@Deprecated
@InternalApi
public ASTForEachStatement(Node forEachStatement) {
super(forEachStatement);
ASTForEachStatement(EnhancedForLoopStatement enhancedForLoopStatement) {
super(enhancedForLoopStatement);
}

@Override
Expand Down
Expand Up @@ -4,14 +4,11 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;
import com.google.summit.ast.statement.ForLoopStatement;

public class ASTForLoopStatement extends AbstractApexNode.Single<Node> {
public class ASTForLoopStatement extends AbstractApexNode.Single<ForLoopStatement> {

@Deprecated
@InternalApi
public ASTForLoopStatement(Node forLoopStatement) {
ASTForLoopStatement(ForLoopStatement forLoopStatement) {
super(forLoopStatement);
}

Expand Down
Expand Up @@ -4,15 +4,12 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;
import com.google.summit.ast.statement.IfStatement;

public class ASTIfBlockStatement extends AbstractApexNode.Single<Node> {
public class ASTIfBlockStatement extends AbstractApexNode.Single<IfStatement> {

@Deprecated
@InternalApi
public ASTIfBlockStatement(Node ifBlockStatement) {
super(ifBlockStatement);
ASTIfBlockStatement(IfStatement ifStatement) {
super(ifStatement);
}

@Override
Expand Down
Expand Up @@ -4,15 +4,15 @@

package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;
import com.google.summit.ast.statement.IfStatement;

public class ASTIfElseBlockStatement extends AbstractApexNode.Single<Node> {
public class ASTIfElseBlockStatement extends AbstractApexNode.Single<IfStatement> {

@Deprecated
@InternalApi
public ASTIfElseBlockStatement(Node ifElseBlockStatement) {
super(ifElseBlockStatement);
private final boolean hasElseStatement;

ASTIfElseBlockStatement(IfStatement ifStatement, boolean hasElseStatement) {
super(ifStatement);
this.hasElseStatement = hasElseStatement;
}

@Override
Expand All @@ -21,8 +21,6 @@ public Object jjtAccept(ApexParserVisitor visitor, Object data) {
}

public boolean hasElseStatement() {
// return node.hasElseStatement();
// TODO(b/239648780)
return false;
return hasElseStatement;
}
}
Expand Up @@ -10,10 +10,10 @@

public class ASTMapEntryNode extends AbstractApexNode.Many<Expression> {

private final Expression key;
private final Expression value;
private final Expression key;
private final Expression value;

ASTMapEntryNode(Expression key, Expression value) {
ASTMapEntryNode(Expression key, Expression value) {
super(Arrays.asList(key, value));
this.key = key;
this.value = value;
Expand Down
Expand Up @@ -5,13 +5,10 @@
package net.sourceforge.pmd.lang.apex.ast;

import com.google.summit.ast.Node;
import net.sourceforge.pmd.annotation.InternalApi;

public class ASTMethodBlockStatement extends AbstractApexNode.Single<Node> {

@Deprecated
@InternalApi
public ASTMethodBlockStatement(Node node) {
ASTMethodBlockStatement(Node node) {
super(node);
}

Expand Down