Skip to content

Commit

Permalink
[LaraCommonLanguage] Removes uses of LangSpecV1
Browse files Browse the repository at this point in the history
  • Loading branch information
joaobispo committed Dec 31, 2024
1 parent 5c2061f commit 57b5030
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 230 deletions.
Original file line number Diff line number Diff line change
@@ -1,163 +1,169 @@
<?xml version="1.0"?>
<artifacts>

<!-- Attributes for all join points -->
<global>
<attribute name="line" type="integer" tooltip="The starting line of the current node in the original code."/>
<attribute name="endLine" type="integer" tooltip="The ending line of the current node in the original code."/>
<attribute name="code" type="string" tooltip="The source code corresponding to this join point."/>
<attribute name="joinPointType" type="string" tooltip="A string with the type of the join point."/>
<attribute name="instanceOf" type="boolean" tooltip="True if the current join point is an instance of the given type.">
<parameter name="joinPointType" type="string" />
</attribute>
<attribute name="sameTypeAs" type="boolean" tooltip="True if the join point are of the same type.">
<parameter name="joinPoint" type="joinPoint" />
</attribute>
<attribute name="equals" type="boolean" tooltip="True if the join point are equal.">
<parameter name="joinPoint" type="joinPoint" />
</attribute>
<attribute name="parent" type="joinpoint" tooltip="Returns the parent joinpoint in the AST."/>
<attribute name="children" type="joinpoint[]" tooltip="Returns an array with the children of the joinpoint."/>
<attribute name="descendants" type="joinpoint[]" tooltip="Returns an array with the descendants of the joinpoint."/>
<attribute name="hasChildren" type="boolean" tooltip="Returns an array with the descendants of the joinpoint."/>
<attribute name="astId" type="string" tooltip="The ID of the node in the AST."/>
<attribute name="hasAncestor" type="boolean" tooltip="Check if joinpoint has ancestor of type.">
<parameter name="joinPointType" type="boolean" />
</attribute>




</global>

<artifact class="file" default="name">
<attribute name="name" type="string" tooltip="The name of the file."/>
<attribute name="id" type="string" tooltip="The id of the file."/>
</artifact>

<artifact class="decl">
<attribute name="isStatic" type="boolean" tooltip="Returns true if decl is considered static"/>
</artifact>

<artifact class="call" default="name">
<attribute name="name" type="string" tooltip="The name of the function called."/>
<attribute name="function" type="function" tooltip="The function called."/>
</artifact>


<artifact class="classType" default="name">
<attribute name="name" type="string" tooltip="The name of the interface."/>
<attribute name="methods" type="method[]" tooltip="The methods of this interface"/>
<attribute name="allMethods" type="method[]" tooltip="The methods of this interface and the methods of the super interfaces"/>
<attribute name="interfaces" type="interface[]" tooltip="The interfaces that this interface DIRECTLY extends"/>
<attribute name="allInterfaces" type="interface[]" tooltip="The interfaces that this interface extends"/>
</artifact>

<artifact class="interface" default="name">

</artifact>

<artifact class="class" default="name">
<attribute name="id" type="string" tooltip="The id of the class."/>
<attribute name="superClasses" type="class[]" tooltip="The superClasses this class extends."/>
<attribute name="allSuperClasses" type="class[]" tooltip="The superClasses this class and its superClasses extends."/>
<attribute name="listOfAllMethods" type="method[]" tooltip="All the methods of this class and superClasses, interfaces."/>
<attribute name="constructors" type="constructor[]" tooltip="The constructors of this class."/>
<attribute name="fields" type="field[]" tooltip="The fields of this class."/>
<attribute name="kind" type="string" tooltip="The kind of record."/>
<attribute name="isCustom" type="boolean" tooltip="Check if the class is defined by the user."/>
<attribute name="isAbstract" type="boolean" tooltip="Check if the class is abstract."/>
</artifact>

<artifact class="method" default="name">
<attribute name="id" type="string" tooltip="The id of the method."/>
<attribute name="class" type="class" tooltip="The class of the method."/>
<attribute name="isCustom" type="boolean" tooltip="Check if the class is defined by the user."/>
</artifact>

<artifact class="field" default="name">
<attribute name="id" type="string" tooltip="The id of the field."/>
<attribute name="name" type="string" tooltip="The name of the field."/>
<attribute name="class" type="class" tooltip="The class of the field."/>
<attribute name="type" type="type"/>
</artifact>

<artifact class="function" default="name">
<attribute name="id" type="string" tooltip="The id of the function."/>
<attribute name="name" type="string" tooltip="The name of the function."/>
<attribute name="signature" type="string" tooltip="The signature of the function."/>
<attribute name="returnType" type="type"/>
<attribute name="params" type="param[]"/>
<attribute name="stmts" type="stmt[]"/>
<attribute name="hasBody" type="Boolean"/>
</artifact>

<artifact class="memberCall" default="name">
<attribute name="class" type="class" tooltip="The class of the method called."/>
<attribute name="method" type="method" tooltip="The method called."/>
</artifact>

<artifact class="constructor" default="name">
<attribute name="superCalls" type="constructorCall[]" tooltip=""/>
</artifact>

<artifact class="constructorCall" default="name">
<attribute name="constructor" type="constructor" tooltip="The constructor called."/>
</artifact>


<artifact class="fieldRef" default="name">
<attribute name="name" type="string" tooltip="The name of the field referenced."/>
<attribute name="field" type="method" tooltip="The field referenced."/>
<attribute name="class" type="class" tooltip="The class of the field referenced."/>
</artifact>

<artifact class="type">
<attribute name="isArray" type="Boolean" />
<attribute name="isPointer" type="Boolean" />
<attribute name="isPrimitive" type="Boolean" />
<attribute name="isClass" type="Boolean" />
<attribute name="isInterface" type="Boolean" />
<attribute name="isClassType" type="Boolean" />
<attribute name="classType" type="classType" />
</artifact>

<artifact class="varRef" default="name">
<attribute name="name" type="string" tooltip="The name of the variable referenced."/>
<attribute name="decl" type="varDecl" tooltip="The declaration of the variable."/>
</artifact>

<artifact class="varDecl" default="name">
<attribute name="name" type="string" tooltip="The name of the variable declared."/>
<attribute name="isParam" type="string" tooltip="Check if the var is a param."/>
</artifact>

<artifact class="param" default="name">
<attribute name="function" type="function" tooltip="The function where the param is declared."/>
</artifact>

<artifact class="binaryOp" default="kind">
<attribute name="kind" type="string" tooltip="Gets the kind of this binary operator."/>
<attribute name="isInnerExpr" type="Boolean" tooltip="Check if this expr is inside another expr."/>
<attribute name="outerExpr" type="expr" tooltip="Gets the outer expr."/>
</artifact>

<artifact class="loop">
<attribute name="condition" type="expr" tooltip="Gets the boolean expression that represents the loop's condition."/>
<attribute name="hasCondition" type="Boolean" tooltip="Check if the loop has a condition."/>
</artifact>

<artifact class="if">
<attribute name="condition" type="expr" tooltip="Gets the boolean expression that represents the if's condition."/>
<attribute name="then" type="stmt" tooltip=""/>
<attribute name="else" type="stmt" tooltip=""/>
<attribute name="hasElse" type="boolean" tooltip=""/>
<attribute name="isElseIf" type="boolean" tooltip=""/>
</artifact>

<artifact class="else">
<attribute name="isElseIf" type="boolean" tooltip=""/>
</artifact>
<!-- Attributes for all join points -->
<global>
<attribute name="line" type="integer" tooltip="The starting line of the current node in the original code."/>
<attribute name="endLine" type="integer" tooltip="The ending line of the current node in the original code."/>
<attribute name="code" type="string" tooltip="The source code corresponding to this join point."/>
<attribute name="joinPointType" type="string" tooltip="A string with the type of the join point."/>
<attribute name="instanceOf" type="boolean"
tooltip="True if the current join point is an instance of the given type.">
<parameter name="joinPointType" type="string"/>
</attribute>
<attribute name="sameTypeAs" type="boolean" tooltip="True if the join point are of the same type.">
<parameter name="joinPoint" type="joinPoint"/>
</attribute>
<attribute name="equals" type="boolean" tooltip="True if the join point are equal.">
<parameter name="joinPoint" type="joinPoint"/>
</attribute>
<attribute name="parent" type="joinpoint" tooltip="Returns the parent joinpoint in the AST."/>
<attribute name="children" type="joinpoint[]" tooltip="Returns an array with the children of the joinpoint."/>
<attribute name="descendants" type="joinpoint[]"
tooltip="Returns an array with the descendants of the joinpoint."/>
<attribute name="hasChildren" type="boolean" tooltip="Returns an array with the descendants of the joinpoint."/>
<attribute name="astId" type="string" tooltip="The ID of the node in the AST."/>
<attribute name="hasAncestor" type="boolean" tooltip="Check if joinpoint has ancestor of type.">
<parameter name="joinPointType" type="boolean"/>
</attribute>


</global>

<artifact class="file" default="name">
<attribute name="name" type="string" tooltip="The name of the file."/>
<attribute name="id" type="string" tooltip="The id of the file."/>
</artifact>

<artifact class="decl">
<attribute name="isStatic" type="boolean" tooltip="Returns true if decl is considered static"/>
</artifact>

<artifact class="call" default="name">
<attribute name="name" type="string" tooltip="The name of the function called."/>
<attribute name="function" type="function" tooltip="The function called."/>
</artifact>


<artifact class="classType" default="name">
<attribute name="name" type="string" tooltip="The name of the interface."/>
<attribute name="methods" type="method[]" tooltip="The methods of this interface"/>
<attribute name="allMethods" type="method[]"
tooltip="The methods of this interface and the methods of the super interfaces"/>
<attribute name="interfaces" type="interface[]" tooltip="The interfaces that this interface DIRECTLY extends"/>
<attribute name="allInterfaces" type="interface[]" tooltip="The interfaces that this interface extends"/>
</artifact>

<artifact class="interface" default="name">

</artifact>

<artifact class="class" default="name">
<attribute name="id" type="string" tooltip="The id of the class."/>
<attribute name="superClasses" type="class[]" tooltip="The superClasses this class extends."/>
<attribute name="allSuperClasses" type="class[]"
tooltip="The superClasses this class and its superClasses extends."/>
<attribute name="listOfAllMethods" type="method[]"
tooltip="All the methods of this class and superClasses, interfaces."/>
<attribute name="constructors" type="constructor[]" tooltip="The constructors of this class."/>
<attribute name="fields" type="field[]" tooltip="The fields of this class."/>
<attribute name="kind" type="string" tooltip="The kind of record."/>
<attribute name="isCustom" type="boolean" tooltip="Check if the class is defined by the user."/>
<attribute name="isAbstract" type="boolean" tooltip="Check if the class is abstract."/>
</artifact>

<artifact class="method" default="name">
<attribute name="id" type="string" tooltip="The id of the method."/>
<attribute name="class" type="class" tooltip="The class of the method."/>
<attribute name="isCustom" type="boolean" tooltip="Check if the class is defined by the user."/>
</artifact>

<artifact class="field" default="name">
<attribute name="id" type="string" tooltip="The id of the field."/>
<attribute name="name" type="string" tooltip="The name of the field."/>
<attribute name="class" type="class" tooltip="The class of the field."/>
<attribute name="type" type="type"/>
</artifact>

<artifact class="function" default="name">
<attribute name="id" type="string" tooltip="The id of the function."/>
<attribute name="name" type="string" tooltip="The name of the function."/>
<attribute name="signature" type="string" tooltip="The signature of the function."/>
<attribute name="returnType" type="type"/>
<attribute name="params" type="param[]"/>
<attribute name="stmts" type="stmt[]"/>
<attribute name="hasBody" type="Boolean"/>
</artifact>

<artifact class="memberCall" default="name">
<attribute name="class" type="class" tooltip="The class of the method called."/>
<attribute name="method" type="method" tooltip="The method called."/>
</artifact>

<artifact class="constructor" default="name">
<attribute name="superCalls" type="constructorCall[]" tooltip=""/>
</artifact>

<artifact class="constructorCall" default="name">
<attribute name="constructor" type="constructor" tooltip="The constructor called."/>
</artifact>


<artifact class="fieldRef" default="name">
<attribute name="name" type="string" tooltip="The name of the field referenced."/>
<attribute name="field" type="method" tooltip="The field referenced."/>
<attribute name="class" type="class" tooltip="The class of the field referenced."/>
</artifact>

<artifact class="type">
<attribute name="isArray" type="Boolean"/>
<attribute name="isPointer" type="Boolean"/>
<attribute name="isPrimitive" type="Boolean"/>
<attribute name="isClass" type="Boolean"/>
<attribute name="isInterface" type="Boolean"/>
<attribute name="isClassType" type="Boolean"/>
<attribute name="classType" type="classType"/>
</artifact>

<artifact class="varRef" default="name">
<attribute name="name" type="string" tooltip="The name of the variable referenced."/>
<attribute name="decl" type="varDecl" tooltip="The declaration of the variable."/>
</artifact>

<artifact class="varDecl" default="name">
<attribute name="name" type="string" tooltip="The name of the variable declared."/>
<attribute name="isParam" type="string" tooltip="Check if the var is a param."/>
</artifact>

<artifact class="param" default="name">
<attribute name="function" type="function" tooltip="The function where the param is declared."/>
</artifact>

<!--<artifact class="binaryOp" default="kind">-->
<artifact class="binary" default="kind">
<attribute name="kind" type="string" tooltip="Gets the kind of this binary operator."/>
<attribute name="isInnerExpr" type="Boolean" tooltip="Check if this expr is inside another expr."/>
<attribute name="outerExpr" type="expr" tooltip="Gets the outer expr."/>
</artifact>

<artifact class="loop">
<attribute name="condition" type="expr"
tooltip="Gets the boolean expression that represents the loop's condition."/>
<attribute name="hasCondition" type="Boolean" tooltip="Check if the loop has a condition."/>
</artifact>

<artifact class="if">
<attribute name="condition" type="expr"
tooltip="Gets the boolean expression that represents the if's condition."/>
<attribute name="then" type="stmt" tooltip=""/>
<attribute name="else" type="stmt" tooltip=""/>
<attribute name="hasElse" type="boolean" tooltip=""/>
<attribute name="isElseIf" type="boolean" tooltip=""/>
</artifact>

<artifact class="else">
<attribute name="isElseIf" type="boolean" tooltip=""/>
</artifact>


</artifacts>
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
/**
* Copyright 2020 SPeCS.
*
* <p>
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* 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. under the License.
*/

package pt.up.fe.specs.lara.commonlang;

import static pt.up.fe.specs.lara.commonlang.CommonLangResource.ACTIONS;
import static pt.up.fe.specs.lara.commonlang.CommonLangResource.ARTIFACTS;
import static pt.up.fe.specs.lara.commonlang.CommonLangResource.JOINPOINTS;
import org.lara.language.specification.dsl.LanguageSpecificationV2;
import pt.up.fe.specs.lara.commonlang.generator.CommonLangGenerator;
import pt.up.fe.specs.util.providers.ResourceProvider;

import java.util.ArrayList;
import java.util.List;

import org.lara.language.specification.LanguageSpecification;

import pt.up.fe.specs.lara.commonlang.generator.CommonLangGenerator;
import pt.up.fe.specs.util.providers.ResourceProvider;
import static pt.up.fe.specs.lara.commonlang.CommonLangResource.*;

public class LaraCommonLang {

public static LanguageSpecification getLanguageSpecification() {
return LanguageSpecification.newInstance(JOINPOINTS, ARTIFACTS, ACTIONS, false);

public static LanguageSpecificationV2 getLanguageSpecification() {
return LanguageSpecificationV2.newInstance(JOINPOINTS, ARTIFACTS, ACTIONS);
}

public static List<ResourceProvider> getLaraCommonLangApi() {
Expand All @@ -42,12 +40,15 @@ public static List<ResourceProvider> getLaraCommonLangApi() {

return api;
}


/**
* Used by JS code.
*
* @param joinPointType
* @return
*/
public static String getDefaultAttribute(String joinPointType) {
var langSpec = getLanguageSpecification();
var artifact = langSpec.getArtifacts().getArtifact(joinPointType);
return artifact == null ? null :artifact.getDefault();

return getLanguageSpecification().getJoinPoint(joinPointType).getDefaultAttribute().orElse(null);
}

}
Loading

0 comments on commit 57b5030

Please sign in to comment.