[javascript] Add ASTXmlPropRef node

Fixes #3703
This commit is contained in:
Andreas Dangel
2022-01-13 13:44:36 +01:00
parent 7173f65a87
commit cd71c038dd
6 changed files with 124 additions and 0 deletions

View File

@ -29,6 +29,8 @@ This is a {{ site.pmd.release_type }} release.
* [#3686](https://github.com/pmd/pmd/issues/3686): \[java] ReturnEmptyCollectionRatherThanNull - false negative with conditioned returns
* java-performance
* [#3492](https://github.com/pmd/pmd/issues/3492): \[java] UselessStringValueOf: False positive when there is no initial String to append to
* javascript
* [#3703](https://github.com/pmd/pmd/issues/3703): \[javascript] Error - no Node adapter class registered for XmlPropRef
### API Changes

View File

@ -0,0 +1,28 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.Name;
import org.mozilla.javascript.ast.XmlPropRef;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTXmlPropRef extends AbstractEcmascriptNode<XmlPropRef> {
@Deprecated
@InternalApi
public ASTXmlPropRef(XmlPropRef xmlPropRef) {
super(xmlPropRef);
Name propName = xmlPropRef.getPropName();
if (propName != null) {
super.setImage(propName.getIdentifier());
}
}
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
}

View File

@ -64,6 +64,7 @@ import org.mozilla.javascript.ast.WithStatement;
import org.mozilla.javascript.ast.XmlDotQuery;
import org.mozilla.javascript.ast.XmlExpression;
import org.mozilla.javascript.ast.XmlMemberGet;
import org.mozilla.javascript.ast.XmlPropRef;
import org.mozilla.javascript.ast.XmlString;
import net.sourceforge.pmd.annotation.InternalApi;
@ -126,6 +127,7 @@ public final class EcmascriptTreeBuilder implements NodeVisitor {
register(XmlDotQuery.class, ASTXmlDotQuery.class);
register(XmlExpression.class, ASTXmlExpression.class);
register(XmlMemberGet.class, ASTXmlMemberGet.class);
register(XmlPropRef.class, ASTXmlPropRef.class);
register(XmlString.class, ASTXmlString.class);
}

View File

@ -30,4 +30,9 @@ public class JsTreeDumpTest extends BaseTreeDumpTest {
public void jquerySelector() {
doTest("jquery-selector");
}
@Test
public void decorators() {
doTest("decorators");
}
}

View File

@ -0,0 +1,37 @@
import { LightningElement, api, wire, track } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class InteractionScore extends LightningElement {
@api recordId;
@track
relatedRecords;
@track showMessage;
/**
* @description This is a wire adapter used to get case Object Info
* @param
*/
@wire(getRelatedRecordByCaseId, {
caseId: '$recordId'
})
caseObjectInfo({
error,
data
}) {
if (data) {
}
handleDetailAnalysisClick(event) {
}
/**
* @description Method to show toast incase of any error.
*/
showErrorToast(errorMessage) {
const evt = new ShowToastEvent({
title: 'Error Occurred',
message: errorMessage,
variant: 'error'
});
this.dispatchEvent(evt);
}
}
}

View File

@ -0,0 +1,50 @@
+- AstRoot
+- EmptyStatement
+- EmptyStatement
+- EmptyStatement
+- EmptyStatement
+- ExpressionStatement
| +- XmlPropRef
| +- Name
+- ExpressionStatement
| +- Name
+- EmptyStatement
+- Comment
+- ExpressionStatement
| +- FunctionCall
| +- XmlPropRef
| | +- Name
| +- Name
| +- ObjectLiteral
| +- ObjectProperty
| +- Name
| +- StringLiteral
+- EmptyStatement
+- EmptyStatement
+- EmptyStatement
+- EmptyStatement
+- Comment
+- EmptyStatement
+- ExpressionStatement
| +- Assignment
| +- Name
| +- NewExpression
| +- Name
| +- ObjectLiteral
| +- ObjectProperty
| | +- Name
| | +- StringLiteral
| +- ObjectProperty
| | +- Name
| | +- Name
| +- ObjectProperty
| +- Name
| +- StringLiteral
+- ExpressionStatement
| +- FunctionCall
| +- PropertyGet
| | +- KeywordLiteral
| | +- Name
| +- Name
+- EmptyStatement
+- EmptyStatement