GeezerVison is showing github.com — [modelica] Follow-up fixes for Modelica language module by atrosinenko · Pull Request #2169 · pmd/pmd
[modelica] Follow-up fixes for Modelica language module
#2169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.java
(3)
.xml
(3)
All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -65,10 +65,6 @@
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -11,11 +11,11 @@ public class ASTClassDefinition extends AbstractModelicaNode {
private ModelicaClassSpecialization specialization;
private ModelicaClassSpecifierNode specifier;
public ASTClassDefinition(int id) {
ASTClassDefinition(int id) {
super(id);
}
public ASTClassDefinition(ModelicaParser p, int id) {
ASTClassDefinition(ModelicaParser p, int id) {
super(p, id);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -7,11 +7,11 @@
public class ASTElementList extends AbstractModelicaNode {
private Visibility visibility;
public ASTElementList(int id) {
ASTElementList(int id) {
super(id);
}
public ASTElementList(ModelicaParser p, int id) {
ASTElementList(ModelicaParser p, int id) {
super(p, id);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -4,12 +4,13 @@
package net.sourceforge.pmd.lang.modelica.ast;
import net.sourceforge.pmd.lang.ast.RootNode;
import net.sourceforge.pmd.lang.modelica.resolver.CompositeName;
/**
* A representation of a Modelica source code file.
*/
public class ASTStoredDefinition extends AbstractModelicaNode {
public class ASTStoredDefinition extends AbstractModelicaNode implements RootNode {
private boolean hasBOM = false;
ASTStoredDefinition(int id) {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -11,6 +11,7 @@ Rules which enforce generally accepted best practices.
<rule name="ClassStartNameEqualsEndName"
language="modelica"
message="Class ends with an end clause with a different name"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_modelica_bestpractices.html#classstartnameequalsendname"
class="net.sourceforge.pmd.lang.rule.XPathRule">
<description>
Having a class starting with some name and some *different*
Expand All
@@ -27,27 +28,82 @@ Rules which enforce generally accepted best practices.
</value>
</property>
</properties>
<example>
<![CDATA[
model SomeName
Real x;
equation
x = 1;
end SomeOtherName /* should be SomeName */;
]]>
</example>
</rule>
<rule name="ConnectUsingNonConnector"
language="modelica"
message="Arguments passed to `connect` should be connectors, not `{0}`"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_modelica_bestpractices.html#connectusingnonconnector"
class="net.sourceforge.pmd.lang.modelica.rule.ConnectUsingNonConnector">
<description>
Modelica specification requires passing connectors to the `connect` clause,
while some implementations tolerate using it on plain variables, etc..
</description>
<priority>2</priority>
<example>
<![CDATA[
package Example
connector Conn
Real x;
Real y;
end Conn;
model Test
input Conn c1;
output Conn c2;
input Real x1;
output Real x2;
equation
connect(c1, c2); // OK
connect(x1, x2); // error, x1 and x2 are not (both) connectors
// x1 = x2; // OK
end Test;
end Example;
]]>
</example>
</rule>
<rule name="AmbiguousResolution"
language="modelica"
message="Type resolution is ambiguous: {0}"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_modelica_bestpractices.html#ambiguousresolution"
class="net.sourceforge.pmd.lang.modelica.rule.AmbiguousResolutionRule">
<description>
There is multiple candidates for this type resolution. While generally this is not an error,
this may indicate a bug.
</description>
<priority>3</priority>
<example>
<![CDATA[
package Test
package Inc1
model X
end X;
model Y
end Y;
end Inc1;
package Inc2
model Y
end Y;
model Z
end Z;
end Inc2;
model B
import Test.Inc1.*;
import Test.Inc2.*;
Y y; // Class Y is imported twice
end B;
end Test;
]]>
</example>
</rule>
</ruleset>
Original file line number
Diff line number
Diff line change
Expand Up
@@ -40,7 +40,7 @@ end Test;
]]></code>
</test-code>
<test-code>
<description>Invalid example: class Y is both placed to the scope by extending and import </description>
<description>Invalid example: class Y is imported twice </description>
<expected-problems>1</expected-problems>
<code><![CDATA[
package Test
Expand All
@@ -64,8 +64,7 @@ package Test
end Test;
]]></code>
</test-code>
<!--
<test-code>
<test-code regressionTest="false">
<description>Invalid example: suspicious reference to X</description>
<expected-problems>1</expected-problems>
<code><![CDATA[
Expand All
@@ -78,5 +77,4 @@ package Test
end Test;
]]></code>
</test-code>
-->
</test-data>
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.