repo stringlengths 1 191 ⌀ | file stringlengths 23 351 | code stringlengths 0 5.32M | file_length int64 0 5.32M | avg_line_length float64 0 2.9k | max_line_length int64 0 288k | extension_type stringclasses 1 value |
|---|---|---|---|---|---|---|
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ExcessivePublicCountTest extends PmdRuleTst {
// no additional unit tests
}
| 281 | 22.5 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ExcessiveParameterListTest extends PmdRuleTst {
// no additional unit tests
}
| 283 | 22.666667 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class CognitiveComplexityTest extends PmdRuleTst {
// no additional unit tests
}
| 279 | 22.333333 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AvoidDeeplyNestedIfStmtsTest extends PmdRuleTst {
// no additional unit tests
}
| 285 | 22.833333 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class NcssTypeCountTest extends PmdRuleTst {
// no additional unit tests
}
| 274 | 21.916667 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class CyclomaticComplexityTest extends PmdRuleTst {
// no additional unit tests
}
| 281 | 22.5 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class NcssConstructorCountTest extends PmdRuleTst {
// no additional unit tests
}
| 281 | 22.5 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class NcssMethodCountTest extends PmdRuleTst {
// no additional unit tests
}
| 276 | 22.083333 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class TooManyFieldsTest extends PmdRuleTst {
// no additional unit tests
}
| 274 | 21.916667 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ExcessiveClassLengthTest extends PmdRuleTst {
// no additional unit tests
}
| 281 | 22.5 | 79 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.multifile;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsStringIgnoringCase;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import net.sourceforge.pmd.internal.util.IOUtil;
import net.sourceforge.pmd.lang.apex.ApexLanguageProperties;
import com.github.stefanbirkner.systemlambda.SystemLambda;
class ApexMultifileAnalysisTest {
@TempDir
private Path tempFolder;
@Test
void testNoSfdxProjectJsonProducesFailedAnalysis() throws Exception {
String log = SystemLambda.tapSystemErr(() -> {
ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder();
assertTrue(analysisInstance.isFailed());
assertTrue(analysisInstance.getFileIssues("any file").isEmpty());
});
assertThat(log, containsStringIgnoringCase("Missing project file"));
}
@Test
void testMalformedSfdxProjectJsonProducesFailedAnalysis() throws Exception {
copyResource("malformedSfdxFile.json", "sfdx-project.json");
String log = SystemLambda.tapSystemErr(() -> {
ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder();
assertTrue(analysisInstance.isFailed());
assertTrue(analysisInstance.getFileIssues("any file").isEmpty());
});
assertThat(log,
containsStringIgnoringCase("Error: line 3 at 4: 'path' is required"));
}
@Test
void testWellFormedSfdxProjectJsonProducesFunctionalAnalysis() throws Exception {
copyResource("correctSfdxFile.json", "sfdx-project.json");
String log = SystemLambda.tapSystemErr(() -> {
ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder();
assertFalse(analysisInstance.isFailed());
});
// TODO: log is not empty due to ANTLR versions, 4.9.1 vs 4.8, expect to resolve with apex-dev-tools switch
log = log.replace("ANTLR Tool version 4.8 used for code generation does not match the current runtime version 4.9.1", "");
log = log.replace("ANTLR Runtime version 4.8 used for parser compilation does not match the current runtime version 4.9.1", "");
log = log.trim();
assertTrue(log.isEmpty());
}
private @NonNull ApexMultifileAnalysis getAnalysisForTempFolder() {
ApexLanguageProperties props = new ApexLanguageProperties();
props.setProperty(ApexLanguageProperties.MULTIFILE_DIRECTORY, tempFolder.toAbsolutePath().toString());
return new ApexMultifileAnalysis(props);
}
private void copyResource(String resourcePath, String relativePathInTempDir) throws IOException {
Path file = tempFolder.resolve(relativePathInTempDir);
String fileContents = IOUtil.readToString(getClass().getResourceAsStream(resourcePath), StandardCharsets.UTF_8);
Files.write(file, Arrays.asList(fileContents.split("\\R").clone()));
}
}
| 3,418 | 38.298851 | 136 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexTokenizerTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.util.Properties;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
class ApexTokenizerTest extends CpdTextComparisonTest {
ApexTokenizerTest() {
super(".cls");
}
@Override
protected String getResourcePrefix() {
return "../lang/apex/cpd/testdata";
}
@Override
public Tokenizer newTokenizer(Properties properties) {
ApexTokenizer tokenizer = new ApexTokenizer();
tokenizer.setProperties(properties);
return tokenizer;
}
@Test
void testTokenize() {
doTest("Simple");
}
@Test
void testTokenizeCaseSensitive() {
doTest("Simple", "_caseSensitive", caseSensitive());
}
/**
* Comments are ignored since using ApexLexer.
*/
@Test
void testTokenizeWithComments() {
doTest("comments");
}
@Test
void testTabWidth() {
doTest("tabWidth");
}
private Properties caseSensitive() {
return properties(true);
}
private Properties properties(boolean caseSensitive) {
Properties properties = new Properties();
properties.setProperty(ApexTokenizer.CASE_SENSITIVE, Boolean.toString(caseSensitive));
return properties;
}
}
| 1,405 | 20.30303 | 94 | java |
pmd | pmd-master/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.internal.util.IOUtil;
import net.sourceforge.pmd.lang.apex.ApexLanguageModule;
class ApexCpdTest {
private File testdir;
@BeforeEach
void setUp() {
String path = IOUtil.normalizePath("src/test/resources/net/sourceforge/pmd/cpd/issue427");
testdir = new File(path);
}
@Test
void testIssue427() throws IOException {
CPDConfiguration configuration = new CPDConfiguration();
configuration.setMinimumTileSize(10);
configuration.setLanguage(LanguageFactory.createLanguage(ApexLanguageModule.TERSE_NAME));
CPD cpd = new CPD(configuration);
cpd.add(new File(testdir, "SFDCEncoder.cls"));
cpd.add(new File(testdir, "SFDCEncoderConstants.cls"));
cpd.go();
Iterator<Match> matches = cpd.getMatches();
int duplications = 0;
while (matches.hasNext()) {
matches.next();
duplications++;
}
assertEquals(1, duplications);
Match firstDuplication = cpd.getMatches().next();
assertTrue(firstDuplication.getSourceCodeSlice().startsWith("global with sharing class SFDCEncoder"));
}
}
| 1,572 | 29.843137 | 110 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProcessor.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.lang.LanguageVersionHandler;
import net.sourceforge.pmd.lang.apex.multifile.ApexMultifileAnalysis;
import net.sourceforge.pmd.lang.impl.BatchLanguageProcessor;
public class ApexLanguageProcessor
extends BatchLanguageProcessor<ApexLanguageProperties> {
private final ApexMultifileAnalysis multifileAnalysis;
private final ApexLanguageHandler services;
ApexLanguageProcessor(ApexLanguageProperties bundle) {
super(bundle);
this.multifileAnalysis = new ApexMultifileAnalysis(bundle);
this.services = new ApexLanguageHandler();
}
@Override
public @NonNull LanguageVersionHandler services() {
return services;
}
public ApexMultifileAnalysis getMultiFileState() {
return multifileAnalysis;
}
}
| 990 | 27.314286 | 79 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProperties.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.properties.PropertyFactory;
/**
* @author Clément Fournier
*/
public class ApexLanguageProperties extends LanguagePropertyBundle {
// todo change that to optional<file> when properties are updated
public static final PropertyDescriptor<String> MULTIFILE_DIRECTORY =
PropertyFactory.stringProperty("rootDirectory")
.desc("The root directory of the Salesforce metadata, where `sfdx-project.json` resides.")
.defaultValue("") // is this ok?
.build();
public ApexLanguageProperties() {
super(ApexLanguageModule.getInstance());
definePropertyDescriptor(MULTIFILE_DIRECTORY);
}
}
| 959 | 31 | 113 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex;
import static net.sourceforge.pmd.util.CollectionUtil.listOf;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.Report.SuppressedViolation;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.ViolationSuppressor;
import net.sourceforge.pmd.lang.apex.ast.ASTAnnotation;
import net.sourceforge.pmd.lang.apex.ast.ASTAnnotationParameter;
import net.sourceforge.pmd.lang.apex.ast.ASTField;
import net.sourceforge.pmd.lang.apex.ast.ASTFieldDeclarationStatements;
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
import net.sourceforge.pmd.lang.apex.ast.ASTModifierNode;
import net.sourceforge.pmd.lang.apex.ast.ASTParameter;
import net.sourceforge.pmd.lang.apex.ast.ASTUserClassOrInterface;
import net.sourceforge.pmd.lang.apex.ast.ASTUserEnum;
import net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclarationStatements;
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
import net.sourceforge.pmd.lang.ast.Node;
final class ApexViolationSuppressors {
private static final ViolationSuppressor APEX_ANNOT_SUPPRESSOR = new ViolationSuppressor() {
@Override
public String getId() {
return "@SuppressWarnings";
}
@Override
public Report.SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node) {
if (node instanceof ApexNode && isSuppressed((ApexNode<?>) node, rv.getRule())) {
return new SuppressedViolation(rv, this, null);
}
return null;
}
};
static final List<ViolationSuppressor> ALL_APEX_SUPPRESSORS = listOf(APEX_ANNOT_SUPPRESSOR);
private ApexViolationSuppressors() {
}
/**
* Check for suppression on this node, on parents, and on contained types
* for ASTCompilationUnit
*/
private static boolean isSuppressed(ApexNode<?> node, Rule rule) {
boolean result = suppresses(node, rule);
if (!result) {
ApexNode<?> parent = node.getParent();
while (!result && parent != null) {
result = suppresses(parent, rule);
parent = parent.getParent();
}
}
return result;
}
private static boolean canSuppressWarnings(ApexNode<?> node) {
return node instanceof ASTFieldDeclarationStatements
|| node instanceof ASTVariableDeclarationStatements
|| node instanceof ASTField
|| node instanceof ASTMethod
|| node instanceof ASTUserClassOrInterface
|| node instanceof ASTUserEnum
|| node instanceof ASTParameter;
}
private static boolean suppresses(final ApexNode<?> node, Rule rule) {
return canSuppressWarnings(node) && hasSuppressWarningsAnnotationFor(node, rule);
}
private static boolean hasSuppressWarningsAnnotationFor(ApexNode<?> node, Rule rule) {
return node.children(ASTModifierNode.class)
.children(ASTAnnotation.class)
.any(a -> suppresses(a, rule));
}
private static boolean suppresses(ASTAnnotation annot, Rule rule) {
final String ruleAnno = "PMD." + rule.getName();
if ("SuppressWarnings".equals(annot.getName())) {
for (ASTAnnotationParameter param : annot.children(ASTAnnotationParameter.class)) {
String image = param.getValue();
if (image != null) {
Set<String> paramValues = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
paramValues.addAll(Arrays.asList(image.replaceAll("\\s+", "").split(",")));
if (paramValues.contains("PMD") || paramValues.contains(ruleAnno) || paramValues.contains("all")) {
return true;
}
}
}
}
return false;
}
}
| 4,148 | 35.394737 | 119 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageModule.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex;
import static net.sourceforge.pmd.util.CollectionUtil.listOf;
import java.util.List;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageModuleBase;
import net.sourceforge.pmd.lang.LanguageProcessor;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
import net.sourceforge.pmd.lang.LanguageRegistry;
public class ApexLanguageModule extends LanguageModuleBase {
public static final String NAME = "Apex";
public static final String TERSE_NAME = "apex";
@InternalApi
public static final List<String> EXTENSIONS = listOf("cls", "trigger");
public ApexLanguageModule() {
super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions(EXTENSIONS)
.addVersion("52")
.addVersion("53")
.addVersion("54")
.addVersion("55")
.addVersion("56")
.addDefaultVersion("57"));
}
@Override
public ApexLanguageProperties newPropertyBundle() {
return new ApexLanguageProperties();
}
@Override
public LanguageProcessor createProcessor(LanguagePropertyBundle bundle) {
return new ApexLanguageProcessor((ApexLanguageProperties) bundle);
}
public static Language getInstance() {
return LanguageRegistry.PMD.getLanguageByFullName(NAME);
}
}
| 1,608 | 31.18 | 83 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageHandler.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex;
import static net.sourceforge.pmd.util.CollectionUtil.setOf;
import java.util.List;
import java.util.Set;
import net.sourceforge.pmd.ViolationSuppressor;
import net.sourceforge.pmd.lang.LanguageVersionHandler;
import net.sourceforge.pmd.lang.apex.ast.ApexParser;
import net.sourceforge.pmd.lang.apex.internal.ApexDesignerBindings;
import net.sourceforge.pmd.lang.apex.metrics.ApexMetrics;
import net.sourceforge.pmd.lang.ast.Parser;
import net.sourceforge.pmd.lang.metrics.LanguageMetricsProvider;
import net.sourceforge.pmd.lang.metrics.Metric;
import net.sourceforge.pmd.util.designerbindings.DesignerBindings;
class ApexLanguageHandler implements LanguageVersionHandler {
private final ApexMetricsProvider myMetricsProvider = new ApexMetricsProvider();
@Override
public Parser getParser() {
return new ApexParser();
}
@Override
public List<ViolationSuppressor> getExtraViolationSuppressors() {
return ApexViolationSuppressors.ALL_APEX_SUPPRESSORS;
}
@Override
public LanguageMetricsProvider getLanguageMetricsProvider() {
return myMetricsProvider;
}
@Override
public DesignerBindings getDesignerBindings() {
return ApexDesignerBindings.INSTANCE;
}
private static final class ApexMetricsProvider implements LanguageMetricsProvider {
private final Set<Metric<?, ?>> metrics = setOf(
ApexMetrics.COGNITIVE_COMPLEXITY,
ApexMetrics.CYCLO,
ApexMetrics.WEIGHED_METHOD_COUNT
);
@Override
public Set<Metric<?, ?>> getMetrics() {
return metrics;
}
}
}
| 1,765 | 28.433333 | 87 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexJorjeLogging.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex;
import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration;
import apex.jorje.parser.impl.BaseApexLexer;
public final class ApexJorjeLogging {
private ApexJorjeLogging() {
// this is a utility class
}
public static void disableLogging() {
// Disable the logging of the ApexLexer, e.g.
// Jul 16, 2017 8:49:56 PM apex.jorje.parser.impl.BaseApexLexer dedupe
// INFORMATION: Deduped array ApexLexer.DFA23_transition. Found 7927114 shorts which is 15MB not
// including array overhead. Removed 7204963 shorts which is 13MB not counting array overhead. Took 18ms.
Slf4jSimpleConfiguration.installJulBridge();
Slf4jSimpleConfiguration.disableLogging(BaseApexLexer.class);
}
}
| 877 | 32.769231 | 113 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BooleanOperator.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.BooleanOp;
/**
* Apex boolean operator
*/
public enum BooleanOperator {
EQUAL("=="),
NOT_EQUAL("!="),
ALT_NOT_EQUAL("<>"),
EXACTLY_EQUAL("==="),
EXACTLY_NOT_EQUAL("!=="),
LESS_THAN("<"),
GREATER_THAN(">"),
LESS_THAN_OR_EQUAL("<="),
GREATER_THAN_OR_EQUAL(">="),
LOGICAL_AND("&&"),
LOGICAL_OR("||");
private final String symbol;
BooleanOperator(String symbol) {
this.symbol = symbol;
}
@Override
public String toString() {
return this.symbol;
}
/**
* Returns a {@link BooleanOperator} corresponding to the given {@link BooleanOp}.
*/
public static BooleanOperator valueOf(BooleanOp op) {
switch (op) {
case DOUBLE_EQUAL:
return EQUAL;
case NOT_EQUAL:
return NOT_EQUAL;
case ALT_NOT_EQUAL:
return ALT_NOT_EQUAL;
case TRIPLE_EQUAL:
return EXACTLY_EQUAL;
case NOT_TRIPLE_EQUAL:
return EXACTLY_NOT_EQUAL;
case LESS_THAN:
return LESS_THAN;
case GREATER_THAN:
return GREATER_THAN;
case LESS_THAN_EQUAL:
return LESS_THAN_OR_EQUAL;
case GREATER_THAN_EQUAL:
return GREATER_THAN_OR_EQUAL;
case AND:
return LOGICAL_AND;
case OR:
return LOGICAL_OR;
default:
throw new IllegalArgumentException("Invalid boolean operator " + op);
}
}
}
| 1,649 | 23.264706 | 86 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThrowStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.ThrowStatement;
public final class ASTThrowStatement extends AbstractApexNode<ThrowStatement> {
ASTThrowStatement(ThrowStatement throwStatement) {
super(throwStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 525 | 24.047619 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisVariableExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.ThisVariableExpression;
public final class ASTThisVariableExpression extends AbstractApexNode<ThisVariableExpression> {
ASTThisVariableExpression(ThisVariableExpression thisVariableExpression) {
super(thisVariableExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 582 | 26.761905 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedStoreExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.NestedStoreExpression;
public final class ASTNestedStoreExpression extends AbstractApexNode<NestedStoreExpression> {
ASTNestedStoreExpression(NestedStoreExpression node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 541 | 24.809524 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTRunAsBlockStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.RunAsBlockStatement;
public final class ASTRunAsBlockStatement extends AbstractApexNode<RunAsBlockStatement> {
ASTRunAsBlockStatement(RunAsBlockStatement runAsBlockStatement) {
super(runAsBlockStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 560 | 25.714286 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClass.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import java.util.List;
import java.util.stream.Collectors;
import apex.jorje.data.Identifier;
import apex.jorje.data.ast.TypeRef;
import apex.jorje.semantic.ast.compilation.UserClass;
public final class ASTUserClass extends BaseApexClass<UserClass> implements ASTUserClassOrInterface<UserClass> {
ASTUserClass(UserClass userClass) {
super(userClass);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public String getSuperClassName() {
return node.getDefiningType().getCodeUnitDetails().getSuperTypeRef().map(TypeRef::getNames)
.map(it -> it.stream().map(Identifier::getValue).collect(Collectors.joining(".")))
.orElse("");
}
public List<String> getInterfaceNames() {
return node.getDefiningType().getCodeUnitDetails().getInterfaceTypeRefs().stream()
.map(TypeRef::getNames).map(it -> it.stream().map(Identifier::getValue).collect(Collectors.joining(".")))
.collect(Collectors.toList());
}
}
| 1,245 | 32.675676 | 121 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/EmptySymbolProvider.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
// Note: taken from https://github.com/forcedotcom/idecore/blob/3083815933c2d015d03417986f57bd25786d58ce/com.salesforce.ide.apex.core/src/com/salesforce/ide/apex/internal/core/EmptySymbolProvider.java
/*
* Copyright 2016 salesforce.com, inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.compiler.Namespace;
import apex.jorje.semantic.compiler.sfdc.SymbolProvider;
import apex.jorje.semantic.symbol.resolver.SymbolResolver;
import apex.jorje.semantic.symbol.type.TypeInfo;
/**
* @author jspagnola
*/
final class EmptySymbolProvider implements SymbolProvider {
private static final EmptySymbolProvider INSTANCE = new EmptySymbolProvider();
private EmptySymbolProvider() {
}
public static EmptySymbolProvider get() {
return INSTANCE;
}
@Override
public TypeInfo find(final SymbolResolver symbols, final TypeInfo referencingType, final String lowerCaseFullName) {
return null;
}
@Override
public TypeInfo getVfComponentType(final SymbolResolver symbols, final TypeInfo referencingType,
final Namespace namespace, final String name) {
return null;
}
@Override
public TypeInfo getFlowInterviewType(final SymbolResolver symbols, final TypeInfo referencingType,
final Namespace namespace, final String name) {
return null;
}
@Override
public TypeInfo getSObjectType(final TypeInfo referencingType, final String name) {
return null;
}
@Override
public String getPageReference(final TypeInfo referencingType, final String name) {
return null;
}
@Override
public boolean hasLabelField(final TypeInfo referencingType, final Namespace namespace, final String name) {
return false;
}
@Override
public String getQuickAction(TypeInfo arg0, String arg1, String arg2) {
return null;
}
@Override
public TypeInfo getAggregateResultType(TypeInfo arg0) {
return null;
}
@Override
public boolean isDynamicTypeNamespace(String var1, String var2) {
return false;
}
@Override
public boolean isDynamicTypeNamespace(String var1) {
return false;
}
}
| 2,863 | 29.147368 | 200 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForLoopStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.ForLoopStatement;
public final class ASTForLoopStatement extends AbstractApexNode<ForLoopStatement> {
ASTForLoopStatement(ForLoopStatement forLoopStatement) {
super(forLoopStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 539 | 24.714286 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/TriggerUsage.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
/**
* This maps the apex enum {@link apex.jorje.data.ast.TriggerUsage} to the PMD equivalent.
*/
public enum TriggerUsage {
AFTER_DELETE(apex.jorje.data.ast.TriggerUsage.AFTER_DELETE),
AFTER_INSERT(apex.jorje.data.ast.TriggerUsage.AFTER_INSERT),
AFTER_UNDELETE(apex.jorje.data.ast.TriggerUsage.AFTER_UNDELETE),
AFTER_UPDATE(apex.jorje.data.ast.TriggerUsage.AFTER_UPDATE),
BEFORE_DELETE(apex.jorje.data.ast.TriggerUsage.BEFORE_DELETE),
BEFORE_INSERT(apex.jorje.data.ast.TriggerUsage.BEFORE_INSERT),
BEFORE_UNDELETE(apex.jorje.data.ast.TriggerUsage.BEFORE_UNDELETE),
BEFORE_UPDATE(apex.jorje.data.ast.TriggerUsage.BEFORE_UPDATE);
private final apex.jorje.data.ast.TriggerUsage apexTriggerUsage;
private static final Map<apex.jorje.data.ast.TriggerUsage, TriggerUsage> APEX_TO_PMD;
static {
APEX_TO_PMD = new HashMap<>();
for (TriggerUsage triggerUsage : TriggerUsage.values()) {
APEX_TO_PMD.put(triggerUsage.getApexTriggerUsage(), triggerUsage);
}
}
TriggerUsage(apex.jorje.data.ast.TriggerUsage apexTriggerUsage) {
this.apexTriggerUsage = apexTriggerUsage;
}
private apex.jorje.data.ast.TriggerUsage getApexTriggerUsage() {
return apexTriggerUsage;
}
public static TriggerUsage of(apex.jorje.data.ast.TriggerUsage apexTriggerUsage) {
TriggerUsage result = APEX_TO_PMD.get(apexTriggerUsage);
if (result != null) {
return result;
}
throw new NoSuchElementException("Unknown TriggerUsage value '" + apexTriggerUsage.name() + "'");
}
}
| 1,837 | 30.152542 | 105 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.SoqlExpression;
public final class ASTSoqlExpression extends AbstractApexNode<SoqlExpression> {
ASTSoqlExpression(SoqlExpression soqlExpression) {
super(soqlExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public String getQuery() {
return node.getRawQuery();
}
public String getCanonicalQuery() {
return node.getCanonicalQuery();
}
}
| 687 | 22.724138 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTypeWhenBlock.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import org.apache.commons.lang3.reflect.FieldUtils;
import apex.jorje.semantic.ast.statement.TypeWhenBlock;
public final class ASTTypeWhenBlock extends AbstractApexNode<TypeWhenBlock> {
ASTTypeWhenBlock(TypeWhenBlock node) {
super(node);
}
public String getType() {
return String.valueOf(node.getTypeRef());
}
public String getName() {
// unfortunately the name is not exposed...
try {
return String.valueOf(FieldUtils.readDeclaredField(node, "name", true));
} catch (IllegalArgumentException | ReflectiveOperationException e) {
return null;
}
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 942 | 24.486486 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTContinueStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.ContinueStatement;
public final class ASTContinueStatement extends AbstractApexNode<ContinueStatement> {
ASTContinueStatement(ContinueStatement continueStatement) {
super(continueStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 546 | 25.047619 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexVisitorBase.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import net.sourceforge.pmd.lang.ast.AstVisitorBase;
public abstract class ApexVisitorBase<P, R> extends AstVisitorBase<P, R> implements ApexVisitor<P, R> {
@Override
public R visit(ASTUserInterface node, P data) {
return visitTypeDecl(node, data);
}
@Override
public R visit(ASTUserClass node, P data) {
return visitTypeDecl(node, data);
}
public R visitTypeDecl(ASTUserClassOrInterface<?> node, P data) {
return visitApexNode(node, data);
}
}
| 637 | 23.538462 | 103 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import java.util.List;
import apex.jorje.semantic.ast.statement.TryCatchFinallyBlockStatement;
public final class ASTTryCatchFinallyBlockStatement extends AbstractApexNode<TryCatchFinallyBlockStatement> {
ASTTryCatchFinallyBlockStatement(TryCatchFinallyBlockStatement tryCatchFinallyBlockStatement) {
super(tryCatchFinallyBlockStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public ASTBlockStatement getTryBlock() {
return (ASTBlockStatement) getChild(0);
}
public List<ASTCatchBlockStatement> getCatchClauses() {
return findChildrenOfType(ASTCatchBlockStatement.class);
}
public ASTBlockStatement getFinallyBlock() {
ApexNode<?> lastChild = null;
if (getNumChildren() >= 2) {
lastChild = getChild(getNumChildren() - 1);
}
if (lastChild instanceof ASTBlockStatement) {
return (ASTBlockStatement) lastChild;
}
return null;
}
}
| 1,218 | 28.02381 | 109 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTInstanceOfExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.InstanceOfExpression;
public final class ASTInstanceOfExpression extends AbstractApexNode<InstanceOfExpression> {
ASTInstanceOfExpression(InstanceOfExpression instanceOfExpression) {
super(instanceOfExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 568 | 26.095238 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import static apex.jorje.semantic.symbol.type.ModifierTypeInfos.TEST_METHOD;
import apex.jorje.semantic.ast.modifier.ModifierNode;
import apex.jorje.semantic.symbol.type.ModifierTypeInfos;
public final class ASTModifierNode extends AbstractApexNode<ModifierNode> implements AccessNode {
ASTModifierNode(ModifierNode modifierNode) {
super(modifierNode);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public int getModifiers() {
return node.getModifiers().getJavaModifiers();
}
@Override
public boolean isPublic() {
return (node.getModifiers().getJavaModifiers() & PUBLIC) == PUBLIC;
}
@Override
public boolean isProtected() {
return (node.getModifiers().getJavaModifiers() & PROTECTED) == PROTECTED;
}
@Override
public boolean isPrivate() {
return (node.getModifiers().getJavaModifiers() & PRIVATE) == PRIVATE;
}
@Override
public boolean isAbstract() {
return (node.getModifiers().getJavaModifiers() & ABSTRACT) == ABSTRACT;
}
@Override
public boolean isStatic() {
return (node.getModifiers().getJavaModifiers() & STATIC) == STATIC;
}
@Override
public boolean isFinal() {
return (node.getModifiers().getJavaModifiers() & FINAL) == FINAL;
}
@Override
public boolean isTransient() {
return (node.getModifiers().getJavaModifiers() & TRANSIENT) == TRANSIENT;
}
/**
* Returns true if function has `@isTest` annotation or `testmethod` modifier
*/
public boolean isTest() {
return node.getModifiers().isTest();
}
/**
* Returns true if function has `testmethod` modifier
*/
public boolean hasDeprecatedTestMethod() {
return node.getModifiers().has(TEST_METHOD);
}
public boolean isTestOrTestSetup() {
return node.getModifiers().isTestOrTestSetup();
}
public boolean isWithSharing() {
return node.getModifiers().has(ModifierTypeInfos.WITH_SHARING);
}
public boolean isWithoutSharing() {
return node.getModifiers().has(ModifierTypeInfos.WITHOUT_SHARING);
}
public boolean isInheritedSharing() {
return node.getModifiers().has(ModifierTypeInfos.INHERITED_SHARING);
}
public boolean isWebService() {
return node.getModifiers().has(ModifierTypeInfos.WEB_SERVICE);
}
public boolean isGlobal() {
return node.getModifiers().has(ModifierTypeInfos.GLOBAL);
}
public boolean isOverride() {
return node.getModifiers().has(ModifierTypeInfos.OVERRIDE);
}
public boolean isVirtual() {
return node.getModifiers().has(ModifierTypeInfos.VIRTUAL);
}
}
| 2,967 | 25.981818 | 97 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisMethodCallExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.ThisMethodCallExpression;
public final class ASTThisMethodCallExpression extends AbstractApexNode<ThisMethodCallExpression> {
ASTThisMethodCallExpression(ThisMethodCallExpression thisMethodCallExpression) {
super(thisMethodCallExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 596 | 27.428571 | 99 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTApexFile.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import java.util.List;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.lang.apex.ApexLanguageProcessor;
import net.sourceforge.pmd.lang.apex.multifile.ApexMultifileAnalysis;
import net.sourceforge.pmd.lang.ast.AstInfo;
import net.sourceforge.pmd.lang.ast.Parser.ParserTask;
import net.sourceforge.pmd.lang.ast.RootNode;
import net.sourceforge.pmd.lang.document.FileId;
import net.sourceforge.pmd.lang.document.TextRegion;
import apex.jorje.semantic.ast.AstNode;
import apex.jorje.semantic.ast.compilation.Compilation;
import com.nawforce.pkgforce.api.Issue;
public final class ASTApexFile extends AbstractApexNode<AstNode> implements RootNode {
private final AstInfo<ASTApexFile> astInfo;
private final @NonNull ApexMultifileAnalysis multifileAnalysis;
ASTApexFile(ParserTask task,
Compilation jorjeNode,
Map<Integer, String> suppressMap,
@NonNull ApexLanguageProcessor apexLang) {
super(jorjeNode);
this.astInfo = new AstInfo<>(task, this).withSuppressMap(suppressMap);
this.multifileAnalysis = apexLang.getMultiFileState();
this.setRegion(TextRegion.fromOffsetLength(0, task.getTextDocument().getLength()));
}
@Override
public AstInfo<ASTApexFile> getAstInfo() {
return astInfo;
}
@Override
public double getApexVersion() {
return getNode().getDefiningType().getCodeUnitDetails().getVersion().getExternal();
}
public ASTUserClassOrInterface<?> getMainNode() {
return (ASTUserClassOrInterface<?>) getChild(0);
}
@Override
public @NonNull ASTApexFile getRoot() {
return this;
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public List<Issue> getGlobalIssues() {
FileId fileId = getAstInfo().getTextDocument().getFileId();
return multifileAnalysis.getFileIssues(fileId.getAbsolutePath());
}
}
| 2,207 | 31 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnonymousClass.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.compilation.AnonymousClass;
public final class ASTAnonymousClass extends AbstractApexNode<AnonymousClass> {
ASTAnonymousClass(AnonymousClass anonymousClass) {
super(anonymousClass);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return node.getClass().getName();
}
}
| 620 | 23.84 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMultiStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.MultiStatement;
public final class ASTMultiStatement extends AbstractApexNode<MultiStatement> {
ASTMultiStatement(MultiStatement node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 505 | 23.095238 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.PrefixOp;
import apex.jorje.semantic.ast.expression.PrefixExpression;
public final class ASTPrefixExpression extends AbstractApexNode<PrefixExpression> {
ASTPrefixExpression(PrefixExpression prefixExpression) {
super(prefixExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public PrefixOp getOperator() {
return node.getOp();
}
public PrefixOperator getOp() {
return PrefixOperator.valueOf(node.getOp());
}
}
| 826 | 23.323529 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIllegalStoreExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.IllegalStoreExpression;
public final class ASTIllegalStoreExpression extends AbstractApexNode<IllegalStoreExpression> {
ASTIllegalStoreExpression(IllegalStoreExpression node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 546 | 25.047619 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTriggerVariableExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.TriggerVariableExpression;
public final class ASTTriggerVariableExpression extends AbstractApexNode<TriggerVariableExpression> {
ASTTriggerVariableExpression(TriggerVariableExpression triggerVariableExpression) {
super(triggerVariableExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 603 | 27.761905 | 101 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperMethodCallExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.SuperMethodCallExpression;
public final class ASTSuperMethodCallExpression extends AbstractApexNode<SuperMethodCallExpression> {
ASTSuperMethodCallExpression(SuperMethodCallExpression superMethodCallExpression) {
super(superMethodCallExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 603 | 27.761905 | 101 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBreakStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.BreakStatement;
public final class ASTBreakStatement extends AbstractApexNode<BreakStatement> {
ASTBreakStatement(BreakStatement breakStatement) {
super(breakStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 525 | 24.047619 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTClassRefExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.ClassRefExpression;
public final class ASTClassRefExpression extends AbstractApexNode<ClassRefExpression> {
ASTClassRefExpression(ClassRefExpression classRefExpression) {
super(classRefExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 554 | 25.428571 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatements.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import apex.jorje.data.Identifier;
import apex.jorje.data.ast.TypeRef;
import apex.jorje.data.ast.TypeRefs.ArrayTypeRef;
import apex.jorje.data.ast.TypeRefs.ClassTypeRef;
import apex.jorje.semantic.ast.statement.FieldDeclarationStatements;
public final class ASTFieldDeclarationStatements extends AbstractApexNode<FieldDeclarationStatements> {
ASTFieldDeclarationStatements(FieldDeclarationStatements fieldDeclarationStatements) {
super(fieldDeclarationStatements);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public ASTModifierNode getModifiers() {
return getFirstChildOfType(ASTModifierNode.class);
}
public String getTypeName() {
if (node.getTypeName() != null) {
List<Identifier> names = node.getTypeName().getNames();
return names.stream().map(Identifier::getValue).collect(Collectors.joining("."));
}
return null;
}
private static String identifiersToString(List<Identifier> identifiers) {
return identifiers.stream().map(Identifier::getValue).collect(Collectors.joining("."));
}
public List<String> getTypeArguments() {
List<String> result = new ArrayList<>();
if (node.getTypeName() != null) {
List<TypeRef> typeArgs = node.getTypeName().getTypeArguments();
for (TypeRef arg : typeArgs) {
if (arg instanceof ClassTypeRef) {
result.add(identifiersToString(arg.getNames()));
} else if (arg instanceof ArrayTypeRef) {
ArrayTypeRef atr = (ArrayTypeRef) arg;
if (atr.getHeldType() instanceof ClassTypeRef) {
result.add(identifiersToString(atr.getHeldType().getNames()));
}
}
}
}
return result;
}
}
| 2,180 | 32.045455 | 103 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BinaryOperator.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.BinaryOp;
/**
* Apex binary operator
*/
public enum BinaryOperator {
ADDITION("+"),
SUBTRACTION("-"),
MULTIPLICATION("*"),
DIVISION("/"),
LEFT_SHIFT("<<"),
RIGHT_SHIFT_SIGNED(">>"),
RIGHT_SHIFT_UNSIGNED(">>>"),
BITWISE_AND("&"),
BITWISE_OR("|"),
BITWISE_XOR("^");
private final String symbol;
BinaryOperator(String symbol) {
this.symbol = symbol;
}
@Override
public String toString() {
return this.symbol;
}
/**
* Returns a {@link BinaryOperator} corresponding to the given {@link BinaryOp}.
*/
public static BinaryOperator valueOf(BinaryOp op) {
switch (op) {
case ADDITION:
return ADDITION;
case SUBTRACTION:
return SUBTRACTION;
case MULTIPLICATION:
return MULTIPLICATION;
case DIVISION:
return DIVISION;
case LEFT_SHIFT:
return LEFT_SHIFT;
case RIGHT_SHIFT:
return RIGHT_SHIFT_SIGNED;
case UNSIGNED_RIGHT_SHIFT:
return RIGHT_SHIFT_UNSIGNED;
case AND:
return BITWISE_AND;
case OR:
return BITWISE_OR;
case XOR:
return BITWISE_XOR;
default:
throw new IllegalArgumentException("Invalid binary operator " + op);
}
}
}
| 1,521 | 22.415385 | 84 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMapEntryNode.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.MapEntryNode;
public final class ASTMapEntryNode extends AbstractApexNode<MapEntryNode> {
ASTMapEntryNode(MapEntryNode mapEntryNode) {
super(mapEntryNode);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 512 | 23.428571 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReturnStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.ReturnStatement;
public final class ASTReturnStatement extends AbstractApexNode<ReturnStatement> {
ASTReturnStatement(ReturnStatement returnStatement) {
super(returnStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 532 | 24.380952 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifier.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.modifier.Modifier;
public final class ASTModifier extends AbstractApexNode<Modifier> {
ASTModifier(Modifier node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 474 | 21.619048 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.Expression;
public final class ASTExpression extends AbstractApexNode<Expression> {
ASTExpression(Expression expression) {
super(expression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 498 | 22.761905 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PrefixOperator.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.PrefixOp;
/**
* Apex prefix operator
*/
public enum PrefixOperator {
POSITIVE("+"),
NEGATIVE("-"),
LOGICAL_NOT("!"),
BITWISE_NOT("~"),
INCREMENT("++"),
DECREMENT("--");
private final String symbol;
PrefixOperator(String symbol) {
this.symbol = symbol;
}
@Override
public String toString() {
return this.symbol;
}
/**
* Returns a {@link PrefixOperator} corresponding to the given {@link PrefixOp}.
*/
public static PrefixOperator valueOf(PrefixOp op) {
switch (op) {
case POSITIVE:
return POSITIVE;
case NEGATIVE:
return NEGATIVE;
case NOT:
return LOGICAL_NOT;
case BITWISE_COMPLEMENT:
return BITWISE_NOT;
case INC:
return INCREMENT;
case DEC:
return DECREMENT;
default:
throw new IllegalArgumentException("Invalid prefix operator " + op);
}
}
}
| 1,154 | 20.792453 | 84 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTConstructorPreambleStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.ConstructorPreambleStatement;
public final class ASTConstructorPreambleStatement extends AbstractApexNode<ConstructorPreambleStatement> {
ASTConstructorPreambleStatement(ConstructorPreambleStatement constructorPreambleStatement) {
super(constructorPreambleStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 623 | 28.714286 | 107 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierOrAnnotation.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.modifier.ModifierOrAnnotation;
public final class ASTModifierOrAnnotation extends AbstractApexNode<ModifierOrAnnotation> {
ASTModifierOrAnnotation(ModifierOrAnnotation modifierOrAnnotation) {
super(modifierOrAnnotation);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 566 | 26 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/TestQueryValidators.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
// Note: taken from https://github.com/forcedotcom/idecore/blob/3083815933c2d015d03417986f57bd25786d58ce/com.salesforce.ide.apex.core/src/apex/jorje/semantic/common/TestQueryValidators.java
/*
* Copyright 2016 salesforce.com, inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.SoqlExpression;
import apex.jorje.semantic.ast.expression.SoslExpression;
import apex.jorje.semantic.ast.visitor.ValidationScope;
import apex.jorje.semantic.compiler.sfdc.QueryValidator;
import apex.jorje.semantic.symbol.resolver.SymbolResolver;
/**
* The test query validators will return back the query it was given. The real implementation actually creates its own
* query.
*
* @author jspagnola
*/
@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass") // this class provides utility classes
final class TestQueryValidators {
private TestQueryValidators() {
}
public static class Noop implements QueryValidator {
@Override
public String validateSoql(
final SymbolResolver symbols,
final ValidationScope scope,
final SoqlExpression soql
) {
return soql.getCanonicalQuery();
}
@Override
public String validateSosl(
final SymbolResolver symbols,
final ValidationScope typeInfo,
final SoslExpression sosl
) {
return sosl.getCanonicalQuery();
}
}
public static class Error implements QueryValidator {
@Override
public String validateSoql(
final SymbolResolver symbols,
final ValidationScope scope,
final SoqlExpression soql
) {
scope.getErrors().markInvalid(soql, "Bad Soql");
return soql.getCanonicalQuery();
}
@Override
public String validateSosl(
final SymbolResolver symbols,
final ValidationScope scope,
final SoslExpression sosl
) {
scope.getErrors().markInvalid(sosl, "Bad Sosl");
return sosl.getCanonicalQuery();
}
}
}
| 2,787 | 31.8 | 189 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatementExecuted.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.StatementExecuted;
public final class ASTStatementExecuted extends AbstractApexNode<StatementExecuted> {
ASTStatementExecuted(StatementExecuted node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 520 | 23.809524 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.member.Method;
public final class ASTMethod extends AbstractApexNode<Method> implements ApexQualifiableNode {
ASTMethod(Method method) {
super(method);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return node.getMethodInfo().getName();
}
public String getCanonicalName() {
return node.getMethodInfo().getCanonicalName();
}
@Override
public ApexQualifiedName getQualifiedName() {
return ApexQualifiedName.ofMethod(this);
}
/**
* Returns true if this is a synthetic class initializer, inserted
* by the parser.
*/
public boolean isSynthetic() {
return getImage().matches("<clinit>|<init>|clone");
}
public boolean isConstructor() {
return node.getMethodInfo().isConstructor();
}
public ASTModifierNode getModifiers() {
return getFirstChildOfType(ASTModifierNode.class);
}
public String getReturnType() {
return node.getMethodInfo().getEmitSignature().getReturnType().getApexName();
}
public int getArity() {
return node.getMethodInfo().getParameterTypes().size();
}
}
| 1,464 | 23.830508 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapLiteralExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.NewMapLiteralExpression;
public final class ASTNewMapLiteralExpression extends AbstractApexNode<NewMapLiteralExpression> {
ASTNewMapLiteralExpression(NewMapLiteralExpression newMapLiteralExpression) {
super(newMapLiteralExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 589 | 27.095238 | 97 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralCase.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.WhenCases.LiteralCase;
public final class ASTLiteralCase extends AbstractApexNode<LiteralCase> {
ASTLiteralCase(LiteralCase node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 502 | 20.869565 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexParserVisitor.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
import net.sourceforge.pmd.lang.ast.Node;
@DeprecatedUntil700
@Deprecated
public interface ApexParserVisitor extends ApexVisitor<Object, Object> {
@Override
default Object visitNode(Node node, Object param) {
for (Node child : node.children()) {
child.acceptVisitor(this, param);
}
return param;
}
@Deprecated
default Object visit(ApexNode<?> node, Object data) {
return visitNode(node, data);
}
@Override
default Object visitApexNode(ApexNode<?> node, Object data) {
return visit(node, data); // calls the overload above for compatibility
}
}
| 827 | 24.090909 | 79 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import apex.jorje.semantic.symbol.type.TypeInfo;
/**
* Qualified name of an apex class or method.
*
* @author Clément Fournier
*/
public final class ApexQualifiedName {
private final String nameSpace;
private final String[] classes;
private final String operation;
private ApexQualifiedName(String nameSpace, String[] classes, String operation) {
this.nameSpace = nameSpace;
this.operation = operation;
this.classes = classes;
}
public String getOperation() {
return operation;
}
public String[] getClasses() {
return Arrays.copyOf(classes, classes.length);
}
/**
* Gets the namespace prefix of this resource.
*
* @return The namespace prefix
*/
public String getNameSpace() {
return nameSpace;
}
/**
* Returns true if the resource addressed by this qualified name is a class.
*
* @return true if the resource addressed by this qualified name is a class.
*/
public boolean isClass() {
return operation == null;
}
/**
* Returns true if the resource addressed by this qualified name is an operation.
*
* @return true if the resource addressed by this qualified name is an operation.
*/
public boolean isOperation() {
return operation != null;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(nameSpace).append("__");
sb.append(classes[0]);
if (classes.length > 1) {
sb.append('.').append(classes[1]);
}
if (isOperation()) {
sb.append("#").append(operation);
}
return sb.toString();
}
/**
* Returns the qualified name of the class the resource is located in. If this instance addresses a class, returns
* this instance.
*
* @return The qualified name of the class
*/
public ApexQualifiedName getClassName() {
if (isClass()) {
return this;
}
return new ApexQualifiedName(this.nameSpace, this.classes, null);
}
@Override
public int hashCode() {
int result = nameSpace.hashCode();
result = 31 * result + Arrays.hashCode(classes);
result = 31 * result + (operation != null ? operation.hashCode() : 0);
return result;
}
@Override
public boolean equals(Object obj) {
return obj instanceof ApexQualifiedName
&& Objects.deepEquals(classes, ((ApexQualifiedName) obj).classes)
&& Objects.equals(operation, ((ApexQualifiedName) obj).operation)
&& Objects.equals(nameSpace, ((ApexQualifiedName) obj).nameSpace);
}
/**
* Parses a string conforming to the format defined below and returns an ApexQualifiedName.
*
* <p>Here are some examples of the format:
* <ul>
* <li> {@code namespace__OuterClass.InnerClass}: name of an inner class
* <li> {@code namespace__Class#method(String, int)}: name of an operation
* </ul>
*
* @param toParse The string to parse
*
* @return An ApexQualifiedName, or null if the string couldn't be parsed
*/
// private static final Pattern FORMAT = Pattern.compile("(\\w+)__(\\w+)(.(\\w+))?(#(\\w+))?"); // TODO
public static ApexQualifiedName ofString(String toParse) {
throw new UnsupportedOperationException();
}
static ApexQualifiedName ofOuterClass(ASTUserClassOrInterface<?> astUserClass) {
String ns = astUserClass.getNamespace();
String[] classes = {astUserClass.getImage()};
return new ApexQualifiedName(StringUtils.isEmpty(ns) ? "c" : ns, classes, null);
}
static ApexQualifiedName ofNestedClass(ApexQualifiedName parent, ASTUserClassOrInterface<?> astUserClass) {
String[] classes = Arrays.copyOf(parent.classes, parent.classes.length + 1);
classes[classes.length - 1] = astUserClass.getImage();
return new ApexQualifiedName(parent.nameSpace, classes, null);
}
static ApexQualifiedName ofOuterEnum(ASTUserEnum astUserEnum) {
String ns = astUserEnum.getNamespace();
String[] classes = {astUserEnum.getImage()};
return new ApexQualifiedName(StringUtils.isEmpty(ns) ? "c" : ns, classes, null);
}
static ApexQualifiedName ofNestedEnum(ApexQualifiedName parent, ASTUserEnum astUserEnum) {
String[] classes = Arrays.copyOf(parent.classes, parent.classes.length + 1);
classes[classes.length - 1] = astUserEnum.getImage();
return new ApexQualifiedName(parent.nameSpace, classes, null);
}
private static String getOperationString(ASTMethod node) {
StringBuilder sb = new StringBuilder();
sb.append(node.getImage()).append('(');
List<TypeInfo> paramTypes = node.node.getMethodInfo().getParameterTypes();
if (!paramTypes.isEmpty()) {
sb.append(paramTypes.get(0).getApexName());
for (int i = 1; i < paramTypes.size(); i++) {
sb.append(", ").append(paramTypes.get(i).getApexName());
}
}
sb.append(')');
return sb.toString();
}
static ApexQualifiedName ofMethod(ASTMethod node) {
// Check first, as enum must be innermost potential parent
ASTUserEnum enumParent = node.ancestors(ASTUserEnum.class).first();
if (enumParent != null) {
ApexQualifiedName baseName = enumParent.getQualifiedName();
return new ApexQualifiedName(baseName.nameSpace, baseName.classes, getOperationString(node));
}
ASTUserClassOrInterface<?> parent = node.ancestors(ASTUserClassOrInterface.class).firstOrThrow();
if (parent instanceof ASTUserTrigger) {
ASTUserTrigger trigger = (ASTUserTrigger) parent;
String ns = trigger.getNamespace();
String targetObj = trigger.getTargetName();
return new ApexQualifiedName(StringUtils.isEmpty(ns) ? "c" : ns, new String[]{"trigger", targetObj}, trigger.getImage()); // uses a reserved word as a class name to prevent clashes
} else {
ApexQualifiedName baseName = parent.getQualifiedName();
return new ApexQualifiedName(baseName.nameSpace, baseName.classes, getOperationString(node));
}
}
}
| 6,636 | 28.896396 | 192 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTProperty.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.member.Property;
public final class ASTProperty extends AbstractApexNode<Property> {
ASTProperty(Property property) {
super(property);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public String getType() {
return node.getFieldInfo().getType().getApexName();
}
public ASTModifierNode getModifiers() {
return getFirstChildOfType(ASTModifierNode.class);
}
}
| 687 | 22.724138 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTEmptyReferenceExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.EmptyReferenceExpression;
public final class ASTEmptyReferenceExpression extends AbstractApexNode<EmptyReferenceExpression> {
ASTEmptyReferenceExpression(EmptyReferenceExpression node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 559 | 22.333333 | 99 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.PostfixOp;
import apex.jorje.semantic.ast.expression.PostfixExpression;
public final class ASTPostfixExpression extends AbstractApexNode<PostfixExpression> {
ASTPostfixExpression(PostfixExpression postfixExpression) {
super(postfixExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public PostfixOp getOperator() {
return node.getOp();
}
public PostfixOperator getOp() {
return PostfixOperator.valueOf(node.getOp());
}
}
| 839 | 22.333333 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.NewKeyValueObjectExpression;
public final class ASTNewKeyValueObjectExpression extends AbstractApexNode<NewKeyValueObjectExpression> {
ASTNewKeyValueObjectExpression(NewKeyValueObjectExpression node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public String getType() {
return node.getTypeRef().getNames().get(0).getValue();
}
public int getParameterCount() {
return node.getParameters().size();
}
}
| 759 | 25.206897 | 105 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCommentContainer.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import net.sourceforge.pmd.annotation.Experimental;
import apex.jorje.semantic.ast.AstNode;
/**
* Interface for nodes that can contain comments. Because comments are for the most part lost, the tree builder only
* captures whether the node did contain comments of any sort in the source code and not the actual contents of those
* comments. This is useful for rules which need to know whether a node did contain comments.
*/
@Experimental
public interface ASTCommentContainer<T extends AstNode> extends ApexNode<T> {
boolean getContainsComment();
}
| 692 | 32 | 117 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import apex.jorje.data.Identifier;
import apex.jorje.semantic.ast.expression.IdentifierContext;
import apex.jorje.semantic.ast.expression.ReferenceExpression;
import apex.jorje.semantic.ast.expression.ReferenceType;
public final class ASTReferenceExpression extends AbstractApexNode<ReferenceExpression> {
ASTReferenceExpression(ReferenceExpression referenceExpression) {
super(referenceExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public IdentifierContext getContext() {
return node.getContext();
}
public ReferenceType getReferenceType() {
return node.getReferenceType();
}
@Override
public String getImage() {
if (node.getNames() != null && !node.getNames().isEmpty()) {
return node.getNames().get(0).getValue();
}
return null;
}
public List<String> getNames() {
List<Identifier> identifiers = node.getNames();
if (identifiers != null) {
return identifiers.stream().map(id -> id.getValue()).collect(Collectors.toList());
}
return Collections.emptyList();
}
public boolean isSafeNav() {
return node.isSafeNav();
}
public boolean isSObjectType() {
List<Identifier> identifiers = node.getNames();
return identifiers != null
&& identifiers.stream().anyMatch(id -> "sobjecttype".equalsIgnoreCase(id.getValue()));
}
}
| 1,779 | 25.969697 | 98 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUpdateStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.DmlUpdateStatement;
public final class ASTDmlUpdateStatement extends AbstractApexNode<DmlUpdateStatement> {
ASTDmlUpdateStatement(DmlUpdateStatement dmlUpdateStatement) {
super(dmlUpdateStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 553 | 25.380952 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapInitExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.NewMapInitExpression;
public final class ASTNewMapInitExpression extends AbstractApexNode<NewMapInitExpression> {
ASTNewMapInitExpression(NewMapInitExpression newMapInitExpression) {
super(newMapInitExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 568 | 26.095238 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.NestedExpression;
public final class ASTNestedExpression extends AbstractApexNode<NestedExpression> {
ASTNestedExpression(NestedExpression node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 516 | 23.619048 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperVariableExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.SuperVariableExpression;
public final class ASTSuperVariableExpression extends AbstractApexNode<SuperVariableExpression> {
ASTSuperVariableExpression(SuperVariableExpression superVariableExpression) {
super(superVariableExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 589 | 27.095238 | 97 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexNode.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
import net.sourceforge.pmd.lang.ast.AstVisitor;
import net.sourceforge.pmd.lang.ast.impl.GenericNode;
import apex.jorje.semantic.ast.AstNode;
import apex.jorje.services.Version;
/**
* Root interface implemented by all Apex nodes. Apex nodes wrap a tree
* obtained from an external parser (Jorje). The underlying AST node is
* available with {@link #getNode()}.
*
* @param <T> Type of the underlying Jorje node
*/
public interface ApexNode<T extends AstNode> extends GenericNode<ApexNode<?>> {
/**
* Accept the visitor.
*
* @deprecated Use {@link #acceptVisitor(AstVisitor, Object)}
*/
@Deprecated
@DeprecatedUntil700
default Object jjtAccept(ApexParserVisitor visitor, Object data) {
return acceptVisitor(visitor, data);
}
/**
* Get the underlying AST node.
* @deprecated the underlying AST node should not be available outside of the AST node.
* If information is needed from the underlying node, then PMD's AST node need to expose
* this information.
*/
@Deprecated
T getNode();
boolean hasRealLoc();
String getDefiningType();
String getNamespace();
@Override
@NonNull ASTApexFile getRoot();
/**
* Gets the apex version this class has been compiled with.
* Use {@link Version} to compare, e.g.
* {@code node.getApexVersion() >= Version.V176.getExternal()}
*
* @return the apex version
*/
default double getApexVersion() {
return getRoot().getApexVersion();
}
}
| 1,798 | 24.7 | 97 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStandardCondition.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.condition.StandardCondition;
public final class ASTStandardCondition extends AbstractApexNode<StandardCondition> {
ASTStandardCondition(StandardCondition standardCondition) {
super(standardCondition);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 546 | 25.047619 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBindExpressions.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.BindExpressions;
public final class ASTBindExpressions extends AbstractApexNode<BindExpressions> {
ASTBindExpressions(BindExpressions bindExpressions) {
super(bindExpressions);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 533 | 24.428571 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AssignmentOperator.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.AssignmentOp;
/**
* Apex assignment operator
*/
public enum AssignmentOperator {
EQUALS("="),
ADDITION_EQUALS("+="),
SUBTRACTION_EQUALS("-="),
MULTIPLICATION_EQUALS("*="),
DIVISION_EQUALS("/="),
LEFT_SHIFT_EQUALS("<<="),
RIGHT_SHIFT_SIGNED_EQUALS(">>="),
RIGHT_SHIFT_UNSIGNED_EQUALS(">>>="),
BITWISE_AND_EQUALS("&="),
BITWISE_OR_EQUALS("|="),
BITWISE_XOR_EQUALS("^=");
private final String symbol;
AssignmentOperator(String symbol) {
this.symbol = symbol;
}
@Override
public String toString() {
return this.symbol;
}
/**
* Returns a {@link AssignmentOperator} corresponding to the given {@link AssignmentOp}.
*/
public static AssignmentOperator valueOf(AssignmentOp op) {
switch (op) {
case EQUALS:
return EQUALS;
case ADDITION_EQUALS:
return ADDITION_EQUALS;
case SUBTRACTION_EQUALS:
return SUBTRACTION_EQUALS;
case MULTIPLICATION_EQUALS:
return MULTIPLICATION_EQUALS;
case DIVISION_EQUALS:
return DIVISION_EQUALS;
case LEFT_SHIFT_EQUALS:
return LEFT_SHIFT_EQUALS;
case RIGHT_SHIFT_EQUALS:
return RIGHT_SHIFT_SIGNED_EQUALS;
case UNSIGNED_RIGHT_SHIFT_EQUALS:
return RIGHT_SHIFT_UNSIGNED_EQUALS;
case AND_EQUALS:
return BITWISE_AND_EQUALS;
case OR_EQUALS:
return BITWISE_OR_EQUALS;
case XOR_EQUALS:
return BITWISE_XOR_EQUALS;
default:
throw new IllegalArgumentException("Invalid assignment operator " + op);
}
}
}
| 1,842 | 26.102941 | 92 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexCommentContainerNode.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.AstNode;
/**
* Abstract base class for nodes which can contain comments.
*
* @param <T> the node type
*/
abstract class AbstractApexCommentContainerNode<T extends AstNode> extends AbstractApexNode<T> implements ASTCommentContainer<T> {
private boolean containsComment = false;
protected AbstractApexCommentContainerNode(T node) {
super(node);
}
void setContainsComment(boolean containsComment) {
this.containsComment = containsComment;
}
@Override
public boolean getContainsComment() {
return containsComment;
}
}
| 742 | 22.967742 | 130 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexParser.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.apex.ApexJorjeLogging;
import net.sourceforge.pmd.lang.apex.ApexLanguageProcessor;
import net.sourceforge.pmd.lang.ast.ParseException;
import net.sourceforge.pmd.lang.ast.Parser;
import net.sourceforge.pmd.lang.document.FileLocation;
import apex.jorje.data.Locations;
import apex.jorje.semantic.ast.compilation.Compilation;
@InternalApi
public final class ApexParser implements Parser {
public ApexParser() {
ApexJorjeLogging.disableLogging();
Locations.useIndexFactory();
}
@Override
public ASTApexFile parse(final ParserTask task) {
try {
final Compilation astRoot = CompilerService.INSTANCE.parseApex(task.getTextDocument());
assert astRoot != null : "Normally replaced by Compilation.INVALID";
final ApexTreeBuilder treeBuilder = new ApexTreeBuilder(task, (ApexLanguageProcessor) task.getLanguageProcessor());
return treeBuilder.buildTree(astRoot);
} catch (apex.jorje.services.exception.ParseException e) {
FileLocation loc = FileLocation.caret(task.getTextDocument().getFileId(), e.getLoc().getLine(), e.getLoc().getColumn());
throw new ParseException(e).withLocation(loc);
}
}
}
| 1,440 | 34.146341 | 132 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTArrayLoadExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.ArrayLoadExpression;
public final class ASTArrayLoadExpression extends AbstractApexNode<ArrayLoadExpression> {
ASTArrayLoadExpression(ArrayLoadExpression arrayLoadExpression) {
super(arrayLoadExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 561 | 25.761905 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexVisitor.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import net.sourceforge.pmd.lang.ast.AstVisitor;
public interface ApexVisitor<P, R> extends AstVisitor<P, R> {
/**
* The default visit method, to which other methods delegate.
*/
default R visitApexNode(ApexNode<?> node, P data) {
return visitNode(node, data);
}
default R visit(ASTApexFile node, P data) {
return visitNode(node, data);
}
default R visit(ASTAnnotation node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTAnnotationParameter node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTAnonymousClass node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTArrayLoadExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTArrayStoreExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTAssignmentExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTBinaryExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTBindExpressions node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTBlockStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTBooleanExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTBreakStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTBridgeMethodCreator node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTCastExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTCatchBlockStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTClassRefExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTConstructorPreamble node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTConstructorPreambleStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTContinueStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTDmlDeleteStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTDmlInsertStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTDmlMergeStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTDmlUndeleteStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTDmlUpdateStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTDmlUpsertStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTDoLoopStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTExpressionStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTField node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTFieldDeclaration node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTFieldDeclarationStatements node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTFormalComment node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTForEachStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTForLoopStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTIfBlockStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTIfElseBlockStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTIllegalStoreExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTInstanceOfExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTInvalidDependentCompilation node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTJavaMethodCallExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTJavaVariableExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTLiteralExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTMapEntryNode node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTMethod node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTMethodBlockStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTMethodCallExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTModifier node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTModifierNode node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTModifierOrAnnotation node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTMultiStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNestedExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNestedStoreExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNewKeyValueObjectExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNewListInitExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNewListLiteralExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNewMapInitExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNewMapLiteralExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNewObjectExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNewSetInitExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTNewSetLiteralExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTPackageVersionExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTParameter node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTPostfixExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTPrefixExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTProperty node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTReferenceExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTReturnStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTRunAsBlockStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTSoqlExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTSoslExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTStandardCondition node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTStatementExecuted node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTSuperMethodCallExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTSuperVariableExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTTernaryExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTThisMethodCallExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTThisVariableExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTThrowStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTTriggerVariableExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTTryCatchFinallyBlockStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTUserClass node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTUserClassMethods node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTUserEnum node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTUserExceptionMethods node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTUserInterface node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTUserTrigger node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTVariableDeclaration node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTVariableDeclarationStatements node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTVariableExpression node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTWhileLoopStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTSwitchStatement node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTElseWhenBlock node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTTypeWhenBlock node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTValueWhenBlock node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTLiteralCase node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTIdentifierCase node, P data) {
return visitApexNode(node, data);
}
default R visit(ASTEmptyReferenceExpression node, P data) {
return visitApexNode(node, data);
}
}
| 10,848 | 25.396594 | 79 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableDeclarationStatements.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.VariableDeclarationStatements;
public final class ASTVariableDeclarationStatements extends AbstractApexNode<VariableDeclarationStatements> {
ASTVariableDeclarationStatements(VariableDeclarationStatements variableDeclarationStatements) {
super(variableDeclarationStatements);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public ASTModifierNode getModifiers() {
return getFirstChildOfType(ASTModifierNode.class);
}
}
| 740 | 28.64 | 109 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.AssignmentOp;
import apex.jorje.semantic.ast.expression.AssignmentExpression;
public final class ASTAssignmentExpression extends AbstractApexNode<AssignmentExpression> {
ASTAssignmentExpression(AssignmentExpression assignmentExpression) {
super(assignmentExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public AssignmentOp getOperator() {
return node.getOp();
}
public AssignmentOperator getOp() {
return AssignmentOperator.valueOf(node.getOp());
}
}
| 870 | 24.617647 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTWhileLoopStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.WhileLoopStatement;
public final class ASTWhileLoopStatement extends AbstractApexNode<WhileLoopStatement> {
ASTWhileLoopStatement(WhileLoopStatement whileLoopStatement) {
super(whileLoopStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 553 | 25.380952 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTernaryExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.TernaryExpression;
public final class ASTTernaryExpression extends AbstractApexNode<TernaryExpression> {
ASTTernaryExpression(TernaryExpression ternaryExpression) {
super(ternaryExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 547 | 25.095238 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetLiteralExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.NewSetLiteralExpression;
public final class ASTNewSetLiteralExpression extends AbstractApexNode<NewSetLiteralExpression> {
ASTNewSetLiteralExpression(NewSetLiteralExpression newSetLiteralExpression) {
super(newSetLiteralExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 589 | 27.095238 | 97 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBinaryExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.BinaryOp;
import apex.jorje.semantic.ast.expression.BinaryExpression;
public final class ASTBinaryExpression extends AbstractApexNode<BinaryExpression> {
ASTBinaryExpression(BinaryExpression binaryExpression) {
super(binaryExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public BinaryOp getOperator() {
return node.getOp();
}
public BinaryOperator getOp() {
return BinaryOperator.valueOf(node.getOp());
}
}
| 826 | 23.323529 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiableNode.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
/**
* @author Clément Fournier
*/
public interface ApexQualifiableNode {
ApexQualifiedName getQualifiedName();
}
| 252 | 17.071429 | 79 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnum.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.compilation.UserEnum;
public final class ASTUserEnum extends BaseApexClass<UserEnum> {
private ApexQualifiedName qname;
ASTUserEnum(UserEnum userEnum) {
super(userEnum);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public ApexQualifiedName getQualifiedName() {
if (qname == null) {
ASTUserClass parent = this.getFirstParentOfType(ASTUserClass.class);
if (parent != null) {
qname = ApexQualifiedName.ofNestedEnum(parent.getQualifiedName(), this);
} else {
qname = ApexQualifiedName.ofOuterEnum(this);
}
}
return qname;
}
}
| 953 | 24.783784 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForEachStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.ForEachStatement;
public final class ASTForEachStatement extends AbstractApexNode<ForEachStatement> {
ASTForEachStatement(ForEachStatement forEachStatement) {
super(forEachStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 539 | 24.714286 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTParameter.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.member.Parameter;
public final class ASTParameter extends AbstractApexNode<Parameter> {
ASTParameter(Parameter parameter) {
super(parameter);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return node.getName().getValue();
}
public ASTModifierNode getModifiers() {
return getFirstChildOfType(ASTModifierNode.class);
}
public String getType() {
return node.getType().getApexName();
}
}
| 773 | 21.764706 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewListLiteralExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.NewListLiteralExpression;
public final class ASTNewListLiteralExpression extends AbstractApexNode<NewListLiteralExpression> {
ASTNewListLiteralExpression(NewListLiteralExpression newListLiteralExpression) {
super(newListLiteralExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 596 | 27.428571 | 99 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIfBlockStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.IfBlockStatement;
public final class ASTIfBlockStatement extends AbstractApexNode<IfBlockStatement> {
ASTIfBlockStatement(IfBlockStatement ifBlockStatement) {
super(ifBlockStatement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 539 | 24.714286 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatement.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.Statement;
public final class ASTStatement extends AbstractApexNode<Statement> {
ASTStatement(Statement statement) {
super(statement);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 490 | 22.380952 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotation.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.modifier.Annotation;
public final class ASTAnnotation extends AbstractApexNode<Annotation> {
ASTAnnotation(Annotation annotation) {
super(annotation);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public String getName() {
return node.getType().getApexName();
}
@Override
@Deprecated
public String getImage() {
return node.getType().getApexName();
}
public boolean isResolved() {
return node.getType().isResolved();
}
}
| 776 | 21.2 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoslExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.SoslExpression;
public final class ASTSoslExpression extends AbstractApexNode<SoslExpression> {
ASTSoslExpression(SoslExpression soslExpression) {
super(soslExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 526 | 24.095238 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.VariableExpression;
public final class ASTVariableExpression extends AbstractApexNode<VariableExpression> {
ASTVariableExpression(VariableExpression variableExpression) {
super(variableExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
if (node.getIdentifier() != null) {
return node.getIdentifier().getValue();
}
return null;
}
}
| 733 | 24.310345 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIdentifierCase.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.statement.WhenCases.IdentifierCase;
public final class ASTIdentifierCase extends AbstractApexNode<IdentifierCase> {
ASTIdentifierCase(IdentifierCase node) {
super(node);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 517 | 21.521739 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.BooleanOp;
import apex.jorje.semantic.ast.expression.BooleanExpression;
public final class ASTBooleanExpression extends AbstractApexNode<BooleanExpression> {
ASTBooleanExpression(BooleanExpression booleanExpression) {
super(booleanExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public BooleanOp getOperator() {
return this.node.getOp();
}
public BooleanOperator getOp() {
return BooleanOperator.valueOf(this.node.getOp());
}
}
| 849 | 22.611111 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetInitExpression.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.semantic.ast.expression.NewSetInitExpression;
public final class ASTNewSetInitExpression extends AbstractApexNode<NewSetInitExpression> {
ASTNewSetInitExpression(NewSetInitExpression newSetInitExpression) {
super(newSetInitExpression);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 568 | 26.095238 | 95 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexParserVisitorAdapter.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
@Deprecated
@DeprecatedUntil700
public class ApexParserVisitorAdapter extends ApexVisitorBase<Object, Object> implements ApexParserVisitor {
}
| 335 | 23 | 108 | java |
pmd | pmd-master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import java.util.List;
import java.util.stream.Collectors;
import apex.jorje.data.Identifier;
import apex.jorje.semantic.ast.compilation.UserTrigger;
public final class ASTUserTrigger extends BaseApexClass<UserTrigger> {
ASTUserTrigger(UserTrigger userTrigger) {
super(userTrigger);
}
@Override
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public String getTargetName() {
return node.getTargetName().stream().map(Identifier::getValue).collect(Collectors.joining("."));
}
public List<TriggerUsage> getUsages() {
return node.getUsages().stream()
.map(TriggerUsage::of)
.sorted()
.collect(Collectors.toList());
}
}
| 949 | 26.142857 | 104 | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.