Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenLooman committed Sep 18, 2024
2 parents 31bd725 + 798df12 commit 9a390a7
Show file tree
Hide file tree
Showing 18 changed files with 762 additions and 345 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

0.11.0 (unreleased)

- Fix error when parsing `def_slotted_exemplar()`/`def_indexed_exemplar()`/`define_condition()` with unknown children/data names.
- Fix VariableCountCheck, improve message.
- Support setting environment variables from VSCode tasks.
- Index MagikFileDefinitions, to prevent needing to re-index files without MagikDefinitions.
- Refactor `MagikFileScanner` & friends to be shared.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class VariableCountCheck extends MagikCheck {

private static final int DEFAULT_MAXIMUM_VARIABLE_COUNT = 8;
private static final String MESSAGE =
"Method contains more variables than than permitted (%s/%s).";
"Method/procedure contains more variables than than permitted (%s/%s).";

/** Maximum length of method in lines, without whitelines and comment lines. */
@RuleProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ public String getName() {
+ this.rhsTypeName.getFullString();
}

@Override
public String getPackage() {
return null;
}

@Override
public BinaryOperatorDefinition getWithoutNode() {
return new BinaryOperatorDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ public List<String> getDataNames() {
return Collections.unmodifiableList(this.dataNames);
}

@Override
public String getPackage() {
return null;
}

@Override
public ConditionDefinition getWithoutNode() {
return new ConditionDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ public String getName() {
return this.typeName.getFullString();
}

@Override
public String getPackage() {
return this.typeName.getPakkage();
}

@Override
public ExemplarDefinition getWithoutNode() {
return new ExemplarDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ public String getName() {
return this.typeName.getFullString();
}

@Override
public String getPackage() {
return this.typeName.getPakkage();
}

@Override
public GlobalDefinition getWithoutNode() {
return new GlobalDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,6 @@ public AstNode getNode() {
*/
public abstract String getName();

/**
* Get name of package this definition lives in.
*
* @return Package name.
*/
@CheckForNull
public abstract String getPackage();

/**
* Get a(n equal) copy of self, without the {@link AstNode}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,6 @@ public Set<ConditionUsage> getUsedConditions() {
return Collections.unmodifiableSet(this.usedConditions);
}

@Override
public String getPackage() {
return this.typeName.getPakkage();
}

@Override
public MethodDefinition getWithoutNode() {
return new MethodDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ public List<String> getUses() {
return Collections.unmodifiableList(this.uses);
}

@Override
public String getPackage() {
return this.name;
}

@Override
public PackageDefinition getWithoutNode() {
return new PackageDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ public TypeString getTypeName() {
return this.typeName;
}

@Override
public String getPackage() {
return null;
}

@Override
public ParameterDefinition getWithoutNode() {
return new ParameterDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,6 @@ public Set<ConditionUsage> getUsedConditions() {
return Collections.unmodifiableSet(this.usedConditions);
}

@Override
public String getPackage() {
if (this.typeName != null) {
return this.typeName.getPakkage();
}

return TypeString.UNDEFINED.getPakkage();
}

@Override
public ProcedureDefinition getWithoutNode() {
return new ProcedureDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public TypeString getTypeName() {
return this.typeName;
}

@Override
public String getPackage() {
return null;
}

@Override
public SlotDefinition getWithoutNode() {
return new SlotDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import nl.ramsolutions.sw.magik.MagikFile;
import nl.ramsolutions.sw.magik.analysis.AstQuery;
import nl.ramsolutions.sw.magik.analysis.definitions.MagikDefinition;
Expand Down Expand Up @@ -76,9 +75,10 @@ protected List<TypeString> extractParents(final @Nullable AstNode definitionNode
for (final AstNode parentNode : multiParentNode.getChildren(MagikGrammar.EXPRESSION)) {
final ExpressionNodeHelper parentExpressionHelper = new ExpressionNodeHelper(parentNode);
final String parentStr = parentExpressionHelper.getConstant();
Objects.requireNonNull(parentStr);
final TypeString parent = this.getFullParent(parentStr);
parents.add(parent);
if (parentStr != null) {
final TypeString parent = this.getFullParent(parentStr);
parents.add(parent);
}
}
}
return parents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,21 @@ public static boolean isDefineCondition(final AstNode node) {
final AstNode argumentsNode = node.getFirstChild(MagikGrammar.ARGUMENTS);
final ArgumentsNodeHelper argumentsHelper = new ArgumentsNodeHelper(argumentsNode);
final AstNode argument0Node = argumentsHelper.getArgument(0, MagikGrammar.SYMBOL);
if (argument0Node == null) {
return false;
}

final AstNode argument1Node = argumentsHelper.getArgument(1, MagikGrammar.SYMBOL);
if (argument1Node == null) {
return false;
}

final AstNode argument2Node = argumentsHelper.getArgument(2, MagikGrammar.SIMPLE_VECTOR);
return argument0Node != null && argument1Node != null && argument2Node != null;
if (argument2Node == null) {
return false;
}

return true;
}

/**
Expand Down Expand Up @@ -124,9 +136,14 @@ public List<MagikDefinition> parseDefinitions() {
final ExpressionNodeHelper expressionNodeHelper =
new ExpressionNodeHelper(expressionNode);
final String dataName = expressionNodeHelper.getConstant();
if (dataName == null) {
return null;
}

if (dataName.startsWith(":")) {
return dataName.substring(1);
}

return dataName;
})
.filter(Objects::nonNull)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ public static boolean isDefIndexedExemplar(final AstNode node) {
final AstNode argumentsNode = node.getFirstChild(MagikGrammar.ARGUMENTS);
final ArgumentsNodeHelper argumentsHelper = new ArgumentsNodeHelper(argumentsNode);
final AstNode argument0Node = argumentsHelper.getArgument(0, MagikGrammar.SYMBOL);
return argument0Node != null;
if (argument0Node == null) {
return false;
}

return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ public static boolean isDefSlottedExemplar(final AstNode node) {
if (argument0Node == null) {
return false;
}

final AstNode argument1Node = argumentsHelper.getArgument(1, MagikGrammar.SIMPLE_VECTOR);
return argument1Node != null;
if (argument1Node == null) {
return false;
}

return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ private List<MethodDefinition> generateSlotMethods(
getParameters,
null,
Collections.emptySet(),
ExpressionResultString.UNDEFINED,
ExpressionResultString.UNDEFINED);
new ExpressionResultString(TypeString.UNDEFINED),
ExpressionResultString.EMPTY);
methodDefinitions.add(getMethod);
} else if (flag.equals(FLAG_WRITE) || flag.equals(FLAG_WRITABLE)) {
// get
Expand All @@ -302,8 +302,8 @@ private List<MethodDefinition> generateSlotMethods(
getParameters,
null,
Collections.emptySet(),
ExpressionResultString.UNDEFINED,
ExpressionResultString.UNDEFINED);
new ExpressionResultString(TypeString.UNDEFINED),
ExpressionResultString.EMPTY);
methodDefinitions.add(getMethod);

// set
Expand Down Expand Up @@ -336,8 +336,8 @@ private List<MethodDefinition> generateSlotMethods(
setParameters,
assignmentParam,
Collections.emptySet(),
ExpressionResultString.UNDEFINED,
ExpressionResultString.UNDEFINED);
new ExpressionResultString(TypeString.ofParameterRef("val")),
ExpressionResultString.EMPTY);
methodDefinitions.add(setMethod);

// boot
Expand All @@ -355,8 +355,8 @@ private List<MethodDefinition> generateSlotMethods(
setParameters,
assignmentParam,
Collections.emptySet(),
ExpressionResultString.UNDEFINED,
ExpressionResultString.UNDEFINED);
new ExpressionResultString(TypeString.UNDEFINED),
ExpressionResultString.EMPTY);
methodDefinitions.add(bootMethod);
}
return methodDefinitions;
Expand Down
Loading

0 comments on commit 9a390a7

Please sign in to comment.