Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ for (const func of Query.search('function')) {
- `scripts/`: Build and interface generation tools

**Entry Points**:
- `core.ts`: Global imports and initialization
- `weaver/Weaver.ts`: Main weaver utilities
- `LaraJoinPoint.ts`: Base join point implementation
Comment thread
lm-sousa marked this conversation as resolved.

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ant-lara-2.0-legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

# Daily at midnight
schedule:
- cron: '0 0 * * *'
- cron: '0 0 1 * *'
Comment thread
lm-sousa marked this conversation as resolved.
jobs:
build:

Expand All @@ -23,7 +23,7 @@ jobs:

steps:

- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Because of scheduled runs, by default run on default branch
with:
ref: lara-2.0-legacy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public DefaultWeaver() {
public boolean begin(List<File> sources, File output, DataStore args) {

this.args = args;
root = new DWorkspace();
root = new DWorkspace(this);
for (File source : sources) {
if (source.isDirectory()) {
root.addFolder(source);
Expand Down Expand Up @@ -140,10 +140,6 @@ public String getName() {
return "LaraI";
}

public static DefaultWeaver getDefaultWeaver() {
return (DefaultWeaver) getThreadLocalWeaver();
}

public DataStore getArgs() {
return args;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
package org.lara.interpreter.weaver.defaultweaver.joinpoints;

import java.io.File;

import org.lara.interpreter.weaver.defaultweaver.DefaultWeaver;
import org.lara.interpreter.weaver.defaultweaver.abstracts.joinpoints.AFile;

public class DWFile extends AFile {

private final File file;

public DWFile(File f) {
public DWFile(File f, DefaultWeaver weaver) {
super(weaver);
file = f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.List;

import org.lara.interpreter.weaver.defaultweaver.DefaultWeaver;
import org.lara.interpreter.weaver.defaultweaver.abstracts.joinpoints.AFolder;

public class DWFolder extends AFolder {
Expand All @@ -24,7 +25,8 @@ public class DWFolder extends AFolder {
private final List<DWFile> files;
private final String path;

public DWFolder(File source) {
public DWFolder(File source, DefaultWeaver weaver) {
super(weaver);
path = source.getAbsolutePath();
files = new ArrayList<>();
createFiles(source);
Expand All @@ -36,7 +38,7 @@ public void createFiles(File folder) {
if (f.isDirectory() && getFilesRecursively) {
createFiles(f);
} else if (f.getName().endsWith(".c")) {
files.add(new DWFile(f));
files.add(new DWFile(f, getWeaverEngine()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
*/
package org.lara.interpreter.weaver.defaultweaver.joinpoints;

import org.lara.interpreter.weaver.defaultweaver.DefaultWeaver;
import org.lara.interpreter.weaver.defaultweaver.abstracts.joinpoints.AFunction;
import org.lara.interpreter.weaver.interf.JoinPoint;

public class DWFunction extends AFunction {

private final String name;

public DWFunction(String element) {
public DWFunction(String element, DefaultWeaver weaver) {
super(weaver);
name = element;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.HashMap;
import java.util.Map;

import org.lara.interpreter.weaver.defaultweaver.DefaultWeaver;
import org.lara.interpreter.weaver.defaultweaver.abstracts.joinpoints.AWorkspace;

import pt.up.fe.specs.util.SpecsIo;
Expand All @@ -32,14 +33,15 @@ public class DWorkspace extends AWorkspace {

private final Map<File, DWFolder> folders;

public DWorkspace() {
public DWorkspace(DefaultWeaver weaver) {
super(weaver);
folders = new HashMap<>();
}

public void addFolder(File dir) {
File canonicalFile = SpecsIo.getCanonicalFile(dir.getAbsoluteFile());
if (!folders.containsKey(canonicalFile)) {
folders.put(canonicalFile, new DWFolder(canonicalFile));
folders.put(canonicalFile, new DWFolder(canonicalFile, getWeaverEngine()));
}
}

Expand Down
1 change: 0 additions & 1 deletion LARAI/src/org/lara/interpreter/cli/CLIOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
public enum CLIOption implements WeaverOption {

help("h", "print this message", LaraiKeys.SHOW_HELP),
version("v", "print version information and exit", null),
debug("d", "show all process information", LaraiKeys.DEBUG_MODE),
argv("av", OptionArguments.ONE_ARG, "arguments",
"arguments for the main aspect. Supports passing a .properties file with the arguments",
Expand Down
8 changes: 0 additions & 8 deletions LARAI/src/org/lara/interpreter/cli/JOptionsInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import pt.up.fe.specs.util.SpecsEnums;
import pt.up.fe.specs.util.SpecsLogs;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand All @@ -44,8 +43,6 @@ public class JOptionsInterface {

}

private static final EnumSet<CLIOption> IGNORE_SET = EnumSet.of(CLIOption.version);

public static DataStore getDataStore(String name, Properties properties) {

DataStore data = DataStore.newInstance(name);
Expand All @@ -59,11 +56,6 @@ public static DataStore getDataStore(String name, Properties properties) {
continue;
}

// Just ignore
if (JOptionsInterface.IGNORE_SET.contains(option)) {
continue;
}

DataKey<?> datakey = JOptionsInterface.CONVERSION_MAP.get(option);
// New key that forgot to be added
if (datakey == null) {
Expand Down
24 changes: 7 additions & 17 deletions LARAI/src/org/lara/interpreter/cli/OptionsParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.suikasoft.jOptions.storedefinition.StoreDefinitionBuilder;

import pt.up.fe.specs.util.SpecsIo;
import pt.up.fe.specs.util.lazy.Lazy;

/**
* @author Tiago
Expand All @@ -53,7 +54,6 @@ public class OptionsParser {
*/
public static Collection<Option> buildLaraIOptionGroup() {
final Option help = OptionsBuilderUtils.newOption(CLIOption.help);
final Option version = OptionsBuilderUtils.newOption(CLIOption.version);
final Option debug = OptionsBuilderUtils.newOption(CLIOption.debug);

final Option outDir = OptionsBuilderUtils.newOption(CLIOption.output);
Expand All @@ -66,7 +66,6 @@ public static Collection<Option> buildLaraIOptionGroup() {

Options options = new Options()
.addOption(help)
.addOption(version)
.addOption(argv)
.addOption(debug)
.addOption(outDir)
Expand All @@ -80,20 +79,18 @@ public static Collection<Option> buildLaraIOptionGroup() {

public static CommandLine parse(String[] args, Options options) {

Lazy<String> help = Lazy
.newInstance(() -> OptionsParser.getHelp(options));

if (args.length < 1) {
throw new IllegalArgumentException("LARA aspect file is required.\n" + OptionsParser.getHelp(options));
throw new IllegalArgumentException("LARA aspect file is required.\n" + help.get());
}

try {

final CommandLineParser parser = new DefaultParser();

return parser.parse(options, args);

} catch (final ParseException e) {
// System.out.println(e.getMessage());
String help = getHelp(options);
throw new LaraIException(e.getMessage() + "\n" + help);
throw new LaraIException(e.getMessage() + "\n" + help.get());
}
}

Expand Down Expand Up @@ -151,14 +148,7 @@ public static String getHelp(Options options, int leftPadding) {
"", options, leftPadding, formatter.getDescPadding(), "", false);
pw.flush();

var output = sw.toString();

if (WeaverEngine.isWeaverSet()) {
var weaver = WeaverEngine.getThreadLocalWeaver();
output = weaver.getNameAndBuild() + "\n" + output;
}

return output;
return sw.toString();
}

public static Collection<Option> buildConfigOptions() {
Expand Down
11 changes: 1 addition & 10 deletions LARAI/src/org/lara/interpreter/utils/LaraIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.apache.commons.cli.Options;
import org.lara.interpreter.cli.CLIOption;
import org.lara.interpreter.cli.OptionsParser;

import larai.LaraI;
import pt.up.fe.specs.util.SpecsSystem;
import pt.up.fe.specs.util.utilities.JarPath;
Expand All @@ -27,16 +28,6 @@ public static boolean printHelp(CommandLine cmd, Options options) {
System.out.println(OptionsParser.getHelp(options));
return true;
}
if (cmd.hasOption(CLIOption.version.shortOption())) {
var implVersion = SpecsSystem.getBuildNumber();
if (implVersion == null) {
implVersion = "<build number not found>";
}

System.out.println("Build: " + implVersion);

return true;
}
return false;
}

Expand Down
17 changes: 0 additions & 17 deletions LARAI/test/org/lara/interpreter/cli/CLIOptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,6 @@ void testHelpOption() {
assertThat(helpOption.dataKey()).isNotNull();
}

@Test
@DisplayName("version option should have correct properties")
void testVersionOption() {
// Given
CLIOption versionOption = CLIOption.version;

// Then
assertThat(versionOption.shortOption()).isEqualTo("v");
assertThat(versionOption.description()).isEqualTo("print version information and exit");
assertThat(versionOption.args()).isEqualTo(OptionArguments.NO_ARGS);
assertThat(versionOption.longOption()).isEqualTo("version");
assertThat(versionOption.dataKey()).isNull(); // Version option has no data key
}

@Test
@DisplayName("debug option should have correct properties")
void testDebugOption() {
Expand Down Expand Up @@ -129,7 +115,6 @@ void testLogOption() {
void testGetArgumentByShortName() {
// When/Then
assertThat(CLIOption.getArgumentByShortName("h")).isEqualTo(CLIOption.help);
assertThat(CLIOption.getArgumentByShortName("v")).isEqualTo(CLIOption.version);
assertThat(CLIOption.getArgumentByShortName("d")).isEqualTo(CLIOption.debug);
assertThat(CLIOption.getArgumentByShortName("o")).isEqualTo(CLIOption.output);
assertThat(CLIOption.getArgumentByShortName("p")).isEqualTo(CLIOption.workspace);
Expand All @@ -152,7 +137,6 @@ void testGetArgumentByShortName_Unknown() {
void testContains() {
// When/Then
assertThat(CLIOption.contains("help")).isTrue();
assertThat(CLIOption.contains("version")).isTrue();
assertThat(CLIOption.contains("debug")).isTrue();
assertThat(CLIOption.contains("argv")).isTrue();
assertThat(CLIOption.contains("output")).isTrue();
Expand All @@ -177,7 +161,6 @@ void testContains_Invalid() {
void testContainsShort() {
// When/Then
assertThat(CLIOption.containsShort("h")).isTrue();
assertThat(CLIOption.containsShort("v")).isTrue();
assertThat(CLIOption.containsShort("d")).isTrue();
assertThat(CLIOption.containsShort("av")).isTrue();
assertThat(CLIOption.containsShort("o")).isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ void testNewOption_CLIOption_WithArgs() {
@DisplayName("newOption() with CLIOption should create valid option without arguments")
void testNewOption_CLIOption_NoArgs() {
// Given
CLIOption cliOption = CLIOption.version;
CLIOption cliOption = CLIOption.log;

// When
Option option = OptionsBuilderUtils.newOption(cliOption, "show version");
Option option = OptionsBuilderUtils.newOption(cliOption, "show logs");

// Then
assertThat(option).isNotNull();
assertThat(option.getOpt()).isEqualTo(cliOption.shortOption());
assertThat(option.getLongOpt()).isEqualTo(cliOption.name());
assertThat(option.getDescription()).isEqualTo("show version");
assertThat(option.getDescription()).isEqualTo("show logs");
assertThat(option.hasArg()).isFalse();
assertThat(option.hasArgs()).isFalse();
}
Expand Down
1 change: 0 additions & 1 deletion LARAI/test/org/lara/interpreter/cli/OptionsParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void testBuildLaraIOptionGroup() {

// Should contain basic LARAI options
assertThat(options.stream().anyMatch(opt -> "h".equals(opt.getOpt()))).isTrue(); // help
assertThat(options.stream().anyMatch(opt -> "v".equals(opt.getOpt()))).isTrue(); // version
}

@Test
Expand Down
Loading
Loading