Skip to content

Commit e148928

Browse files
committed
Refactor: Remove unused methods and clean up code
1 parent 2ea9388 commit e148928

File tree

10 files changed

+1
-141
lines changed

10 files changed

+1
-141
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import Strings from "@specs-feup/lara/api/lara/Strings.js";
22

3-
console.log("Escaped HTML: " + Strings.escapeHtml("<h1>Hello</h1>"));
4-
53
// Replacer
64
console.log("Replacer 1: " + Strings.replacer("WWRWW", "WRW", "W"));
75
console.log("Replacer 2: " + Strings.replacer("W R W", /\s/g, ""));
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
Escaped HTML: &lt;h1&gt;Hello&lt;/h1&gt;
21
Replacer 1: WWW
32
Replacer 2: WRW

LARAI/src/org/lara/interpreter/cli/JOptionsInterface.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package org.lara.interpreter.cli;
1515

1616
import org.lara.interpreter.joptions.config.interpreter.LaraiKeys;
17-
import org.lara.interpreter.utils.LaraIUtils;
1817
import org.lara.interpreter.weaver.options.WeaverOption;
1918
import org.suikasoft.jOptions.Datakey.DataKey;
2019
import org.suikasoft.jOptions.Interfaces.DataStore;
@@ -28,8 +27,6 @@
2827

2928
public class JOptionsInterface {
3029

31-
private static final String LARAPATH = "$LARAI";
32-
3330
private static final Map<WeaverOption, DataKey<?>> CONVERSION_MAP;
3431

3532
static {
@@ -71,7 +68,6 @@ public static DataStore getDataStore(String name, Properties properties) {
7168
}
7269

7370
String property = properties.getProperty(key.toString());
74-
property.replace(LARAPATH, LaraIUtils.getJarFoldername());
7571
data.setString(datakey, property);
7672
}
7773

LARAI/src/org/lara/interpreter/joptions/config/interpreter/LaraIDataStore.java

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
import org.lara.interpreter.weaver.options.WeaverOption;
1919
import org.suikasoft.jOptions.Datakey.DataKey;
2020
import org.suikasoft.jOptions.Interfaces.DataStore;
21-
import org.suikasoft.jOptions.JOptionsUtils;
2221
import pt.up.fe.specs.util.SpecsIo;
23-
import pt.up.fe.specs.util.SpecsLogs;
2422
import java.io.File;
2523
import java.util.*;
2624

@@ -34,24 +32,16 @@
3432
public class LaraIDataStore implements LaraiKeys {
3533

3634
public static final String CONFIG_FILE_NAME = "larai.properties";
37-
private static final String SYSTEM_OPTIONS_FILENAME = "system_options.xml";
3835

3936
public static String getConfigFileName() {
4037
return CONFIG_FILE_NAME;
4138
}
4239

43-
public static String getSystemOptionsFilename() {
44-
return SYSTEM_OPTIONS_FILENAME;
45-
}
46-
4740
private final DataStore dataStore;
4841

4942
public LaraIDataStore(LaraI lara, DataStore dataStore, WeaverEngine weaverEngine) {
5043

51-
// Merge system-wise options with local options
52-
53-
// this.dataStore = dataStore;
54-
this.dataStore = mergeSystemAndLocalOptions(weaverEngine, dataStore);
44+
this.dataStore = dataStore;
5545

5646
for (WeaverOption option : weaverEngine.getOptions()) {
5747
DataKey<?> key = option.dataKey();
@@ -61,59 +51,6 @@ public LaraIDataStore(LaraI lara, DataStore dataStore, WeaverEngine weaverEngine
6151
setLaraProperties();
6252
}
6353

64-
private DataStore mergeSystemAndLocalOptions(WeaverEngine weaverEngine, DataStore localArgs) {
65-
var systemOptionsFilename = weaverEngine.getName() + "_" + getSystemOptionsFilename();
66-
67-
var storeDef = localArgs.getStoreDefinitionTry().orElse(null);
68-
69-
if (storeDef == null) {
70-
SpecsLogs.debug(() -> "Local data store does not have a store definition, system-wide options in file '"
71-
+ systemOptionsFilename + "' not supported");
72-
return localArgs;
73-
}
74-
75-
var persistence = localArgs.getPersistence().orElse(null);
76-
77-
if (persistence == null) {
78-
SpecsLogs.debug(
79-
() -> "Local data store does not have an instance of AppPersistence set, system-wide options in file '"
80-
+ systemOptionsFilename + "' not supported");
81-
return localArgs;
82-
}
83-
84-
DataStore defaultOptions = JOptionsUtils.loadDataStore(systemOptionsFilename, getClass(),
85-
storeDef, persistence);
86-
87-
defaultOptions.getConfigFile().ifPresent(defaultOptionsFile -> SpecsLogs
88-
.debug("Loading default options in file '" + defaultOptionsFile.getAbsolutePath() + "'"));
89-
90-
SpecsLogs.debug(() -> "Loading system-wide options");
91-
SpecsLogs.debug(() -> "Original options: " + localArgs);
92-
93-
// Merge default values in localArgs
94-
var localArgsKeys = localArgs.getKeysWithValues();
95-
96-
for (var key : defaultOptions.getKeysWithValues()) {
97-
98-
// Only set if no value is set yet
99-
if (localArgsKeys.contains(key)) {
100-
continue;
101-
}
102-
103-
// And if key is part of the store definition
104-
if (!storeDef.hasKey(key)) {
105-
continue;
106-
}
107-
108-
localArgs.setRaw(key, defaultOptions.get(key));
109-
}
110-
111-
SpecsLogs.debug(() -> "Merged options : " + localArgs);
112-
113-
// return mergedOptions;
114-
return localArgs;
115-
}
116-
11754
/**
11855
* Set an option on lara according to the value given, if the option exists on
11956
* the enum {@link Argument}

LARAI/src/org/lara/interpreter/joptions/config/interpreter/LaraiStoreDefinition.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Properties;
2323

2424
import org.lara.interpreter.cli.JOptionsInterface;
25-
import org.lara.interpreter.utils.LaraIUtils;
2625
import org.suikasoft.jOptions.Datakey.DataKey;
2726
import org.suikasoft.jOptions.Interfaces.DataStore;
2827
import org.suikasoft.jOptions.storedefinition.StoreDefinition;
@@ -56,12 +55,9 @@ private static DataStore getDefaultValues() {
5655
}
5756

5857
private static Properties getDefaultProperties() {
59-
String jarLoc = LaraIUtils.getJarFoldername();
6058
Properties properties = new Properties();
6159

62-
File globalFile = new File(jarLoc, LaraIDataStore.getConfigFileName());
6360
File localFile = new File(LaraIDataStore.getConfigFileName());
64-
loadProperties(properties, globalFile);
6561
loadProperties(properties, localFile);
6662

6763
return properties;

LARAI/src/org/lara/interpreter/utils/LaraIUtils.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
import org.apache.commons.cli.Options;
1717
import org.lara.interpreter.cli.CLIOption;
1818
import org.lara.interpreter.cli.OptionsParser;
19-
import larai.LaraI;
2019
import pt.up.fe.specs.util.SpecsSystem;
21-
import pt.up.fe.specs.util.utilities.JarPath;
2220

2321
public class LaraIUtils {
2422

@@ -39,18 +37,4 @@ public static boolean printHelp(CommandLine cmd, Options options) {
3937
}
4038
return false;
4139
}
42-
43-
/**
44-
* Enables lazy initialization of jarParth
45-
*
46-
* @author Joao Bispo
47-
*/
48-
private static class JarPathHolder {
49-
public static final String instance = new JarPath(LaraI.class, LaraI.PROPERTY_JAR_PATH).buildJarPath();
50-
51-
}
52-
53-
public static String getJarFoldername() {
54-
return JarPathHolder.instance;
55-
}
5640
}

LARAI/test/org/lara/interpreter/joptions/config/interpreter/LaraIDataStoreTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ void testGetConfigFileName() {
6969
assertThat(fileName).isEqualTo("larai.properties");
7070
}
7171

72-
@Test
73-
@DisplayName("getSystemOptionsFilename() should return correct file name")
74-
void testGetSystemOptionsFilename() {
75-
// When
76-
String fileName = LaraIDataStore.getSystemOptionsFilename();
77-
78-
// Then
79-
assertThat(fileName).isEqualTo("system_options.xml");
80-
}
81-
8272
@Test
8373
@DisplayName("constructor should create instance with empty weaver options")
8474
void testConstructor_EmptyWeaverOptions() {

LARAI/test/org/lara/interpreter/utils/LaraIUtilsTest.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,30 +105,6 @@ void testPrintHelp_NoOptions() {
105105
assertThat(outputStreamCaptor.toString()).isEmpty();
106106
}
107107

108-
@Test
109-
@DisplayName("getJarFoldername should return non-null jar path")
110-
void testGetJarFoldername() {
111-
// When
112-
String jarPath = LaraIUtils.getJarFoldername();
113-
114-
// Then
115-
assertThat(jarPath).isNotNull();
116-
// Note: The actual path depends on the runtime environment
117-
// We can only verify it's not null and is a string
118-
}
119-
120-
@Test
121-
@DisplayName("getJarFoldername should return same instance on multiple calls (lazy initialization)")
122-
void testGetJarFoldername_LazyInitialization() {
123-
// When
124-
String jarPath1 = LaraIUtils.getJarFoldername();
125-
String jarPath2 = LaraIUtils.getJarFoldername();
126-
127-
// Then
128-
assertThat(jarPath1).isEqualTo(jarPath2);
129-
assertThat(jarPath1).isSameAs(jarPath2); // Should be the same instance
130-
}
131-
132108
@Test
133109
@DisplayName("printHelp should handle both help and version options correctly")
134110
void testPrintHelp_PriorityHandling() {

Lara-JS/src-api/lara/Strings.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ export default class Strings {
3939
return string.replace(oldSequence, newSequence);
4040
}
4141

42-
/**
43-
* Escapes HTML code.
44-
*
45-
* @returns String with escaped code
46-
*/
47-
static escapeHtml(html: string) {
48-
return JavaTypes.ApacheStrings.escapeHtml(html);
49-
}
50-
5142
/**
5243
* Escapes JSON content.
5344
*

Lara-JS/src-api/lara/util/JavaTypes.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export namespace JavaClasses {
2929
escapeJson(str: string): string;
3030
}
3131
export interface SpecsSystem extends JavaClass {}
32-
export interface ApacheStrings extends JavaClass {}
3332
export interface StringLines extends JavaClass {}
3433
export interface LaraIo extends JavaClass {}
3534
export interface SpecsIo extends JavaClass {}
@@ -159,12 +158,6 @@ export default class JavaTypes {
159158
) as JavaClasses.SpecsSystem;
160159
}
161160

162-
static get ApacheStrings() {
163-
return JavaTypes.getType(
164-
"pt.up.fe.specs.lang.ApacheStrings"
165-
) as JavaClasses.ApacheStrings;
166-
}
167-
168161
static get StringLines() {
169162
return JavaTypes.getType(
170163
"pt.up.fe.specs.util.utilities.StringLines"

0 commit comments

Comments
 (0)