19 | * This class is the base class for all of our statement types. Any statement must extend this class to be recognised by
20 | * our Abstract Syntax Tree.
21 | *
22 | * @author Walied K. Yassen
23 | */
24 | public abstract class StatementSyntax extends Syntax {
25 |
26 | /**
27 | * Construct a new {@link StatementSyntax} type object instance.
28 | *
29 | * @param span the node source code range.
30 | */
31 | public StatementSyntax(Span span) {
32 | super(span);
33 | }
34 |
35 | /**
36 | * {@inheritDoc}
37 | */
38 | @Override
39 | public abstract T accept(SyntaxVisitor visitor);
40 | }
41 |
--------------------------------------------------------------------------------
/runescript-compiler/src/main/java/me/waliedyassen/runescript/compiler/syntax/stmt/loop/BreakStatementSyntax.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.syntax.stmt.loop;
9 |
10 | import lombok.Getter;
11 | import me.waliedyassen.runescript.commons.document.Span;
12 | import me.waliedyassen.runescript.compiler.syntax.SyntaxToken;
13 | import me.waliedyassen.runescript.compiler.syntax.stmt.StatementSyntax;
14 | import me.waliedyassen.runescript.compiler.syntax.visitor.SyntaxVisitor;
15 |
16 | /**
17 | * The Syntax Tree element for the break loop control statement syntax.
18 | *
19 | * @author Walied K. Yassen
20 | */
21 | public final class BreakStatementSyntax extends StatementSyntax {
22 |
23 | /**
24 | * The token of the control keyword.
25 | */
26 | @Getter
27 | private final SyntaxToken controlToken;
28 |
29 | /**
30 | * The token of the semicolon.
31 | */
32 | @Getter
33 | private final SyntaxToken semicolonToken;
34 |
35 | /**
36 | * Construct a new {@link BreakStatementSyntax} type object instance.
37 | *
38 | * @param span the node source code range.
39 | * @param controlToken the token of the control keyword.
40 | * @param semicolonToken the token of the semicolon.
41 | */
42 | public BreakStatementSyntax(Span span, SyntaxToken controlToken, SyntaxToken semicolonToken) {
43 | super(span);
44 | this.controlToken = controlToken;
45 | this.semicolonToken = semicolonToken;
46 | }
47 |
48 | /**
49 | * {@inheritDoc}
50 | */
51 | @Override
52 | public T accept(SyntaxVisitor visitor) {
53 | return visitor.visit(this);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/runescript-compiler/src/main/java/me/waliedyassen/runescript/compiler/syntax/stmt/loop/ContinueStatementSyntax.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.syntax.stmt.loop;
9 |
10 | import lombok.Getter;
11 | import me.waliedyassen.runescript.commons.document.Span;
12 | import me.waliedyassen.runescript.compiler.syntax.SyntaxToken;
13 | import me.waliedyassen.runescript.compiler.syntax.stmt.StatementSyntax;
14 | import me.waliedyassen.runescript.compiler.syntax.visitor.SyntaxVisitor;
15 |
16 | /**
17 | * The Syntax Tree element for the continue loop control statement syntax.
18 | *
19 | * @author Walied K. Yassen
20 | */
21 | public final class ContinueStatementSyntax extends StatementSyntax {
22 |
23 | /**
24 | * The toke nof the control keyword.
25 | */
26 | @Getter
27 | private final SyntaxToken controlToken;
28 |
29 | /**
30 | * The token of the semicolon.
31 | */
32 | @Getter
33 | private final SyntaxToken semicolon;
34 |
35 | /**
36 | * Construct a new {@link ContinueStatementSyntax} type object instance.
37 | *
38 | * @param span the node source code range.
39 | * @param controlToken the token of the control keyword.
40 | * @param semicolon the token of the semicolon.
41 | */
42 | public ContinueStatementSyntax(Span span, SyntaxToken controlToken, SyntaxToken semicolon) {
43 | super(span);
44 | this.controlToken = controlToken;
45 | this.semicolon = semicolon;
46 | }
47 |
48 | /**
49 | * {@inheritDoc}
50 | */
51 | @Override
52 | public T accept(SyntaxVisitor visitor) {
53 | return visitor.visit(this);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/runescript-compiler/src/main/java/me/waliedyassen/runescript/compiler/util/VariableScope.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.util;
9 |
10 | import me.waliedyassen.runescript.compiler.lexer.token.Kind;
11 |
12 | /**
13 | * Represents a variable scope, it tells from where the variable can be accessed.
14 | *
15 | * @author Walied K. Yassen
16 | */
17 | public enum VariableScope {
18 |
19 | /**
20 | * The variable is only available within the script its declared in.
21 | */
22 | LOCAL,
23 |
24 | /**
25 | * The variable is available in any script.
26 | */
27 | GLOBAL;
28 |
29 | /**
30 | * Attempts to find the {@link VariableScope} that is associated with the specified token {@link Kind kind}.
31 | *
32 | * @param kind
33 | * the scope token kind.
34 | *
35 | * @return the {@link VariableScope} if it was found otherwise {@code null}.
36 | */
37 | public static VariableScope forKind(Kind kind) {
38 | switch (kind) {
39 | case DOLLAR:
40 | return LOCAL;
41 | case MOD:
42 | return GLOBAL;
43 | default:
44 | return null;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/runescript-compiler/src/test/java/me/waliedyassen/runescript/compiler/TestHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler;
9 |
10 | import me.waliedyassen.runescript.compiler.codegen.Instruction;
11 | import me.waliedyassen.runescript.compiler.codegen.InstructionMap;
12 | import me.waliedyassen.runescript.compiler.codegen.opcode.CoreOpcode;
13 |
14 | public final class TestHelper {
15 |
16 | public static Instruction dummyInstruction() {
17 | return new Instruction(dummyOpcode(), 0);
18 | }
19 |
20 | public static InstructionMap.MappedOpcode dummyOpcode() {
21 | return new InstructionMap.MappedOpcode(CoreOpcode.POP_INT_DISCARD, 0, true);
22 | }
23 |
24 | private TestHelper() {
25 | // NOOP
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/runescript-compiler/src/test/java/me/waliedyassen/runescript/compiler/codegen/InstructionMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.codegen;
9 |
10 | import me.waliedyassen.runescript.compiler.codegen.opcode.CoreOpcode;
11 | import org.junit.jupiter.api.Test;
12 |
13 | import static org.junit.jupiter.api.Assertions.*;
14 |
15 | class InstructionMapTest {
16 |
17 | @Test
18 | void testReady() {
19 | var map = new InstructionMap();
20 | assertFalse(map.isReady());
21 | for (var opcode : CoreOpcode.values()) {
22 | map.registerCore(opcode, opcode.ordinal(), opcode.isLargeOperand());
23 | }
24 | assertTrue(map.isReady());
25 | }
26 |
27 | @Test
28 | void testLookup() {
29 | var map = new InstructionMap();
30 | for (var opcode : CoreOpcode.values()) {
31 | map.registerCore(opcode, opcode.ordinal(), opcode.isLargeOperand());
32 | }
33 | for (var opcode : CoreOpcode.values()) {
34 | var mapped = map.lookup(opcode);
35 | assertNotNull(mapped);
36 | assertEquals(opcode, mapped.getOpcode());
37 | assertEquals(opcode.ordinal(), mapped.getCode());
38 | assertEquals(opcode.isLargeOperand(), mapped.isLarge());
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/runescript-compiler/src/test/java/me/waliedyassen/runescript/compiler/codegen/LabelGeneratorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.codegen;
9 |
10 | import org.junit.jupiter.api.Test;
11 |
12 | import static org.junit.jupiter.api.Assertions.assertEquals;
13 |
14 | class LabelGeneratorTest {
15 |
16 | @Test
17 | void testGenerate() {
18 | var generator = new LabelGenerator();
19 | assertEquals(0, generator.generate("test").getId());
20 | assertEquals(1, generator.generate("test").getId());
21 | assertEquals(2, generator.generate("dummy").getId());
22 | assertEquals("test_2", generator.generate("test").getName());
23 | }
24 |
25 | @Test
26 | void testReset() {
27 | var generator = new LabelGenerator();
28 | assertEquals(0, generator.generate("test").getId());
29 | generator.reset();
30 | assertEquals(0, generator.generate("test").getId());
31 | }
32 | }
--------------------------------------------------------------------------------
/runescript-compiler/src/test/java/me/waliedyassen/runescript/compiler/codegen/block/BlockMapTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.codegen.block;
9 |
10 | import me.waliedyassen.runescript.compiler.codegen.LabelGenerator;
11 | import org.junit.jupiter.api.BeforeAll;
12 | import org.junit.jupiter.api.Test;
13 |
14 | import static org.junit.jupiter.api.Assertions.assertEquals;
15 | import static org.junit.jupiter.api.Assertions.assertNotNull;
16 |
17 | class BlockMapTest {
18 |
19 | static LabelGenerator labelGenerator;
20 |
21 | @BeforeAll
22 | static void setupLabelGenerator() {
23 | labelGenerator = new LabelGenerator();
24 | }
25 |
26 | @Test
27 | void testGenerate() {
28 | var map = new BlockMap();
29 | var label = labelGenerator.generate("test");
30 | assertEquals(map.generate(label).getLabel(), label);
31 | label = labelGenerator.generate("test");
32 | assertNotNull(map.newBlock(label));
33 | assertEquals(map.generate(label).getLabel(), label);
34 | assertEquals(2, map.getBlocks().size());
35 |
36 | }
37 |
38 | @Test
39 | void resetReset() {
40 | var map = new BlockMap();
41 | map.generate(labelGenerator.generate("test"));
42 | map.reset();
43 | assertEquals(0, map.getBlocks().size());
44 | }
45 | }
--------------------------------------------------------------------------------
/runescript-compiler/src/test/java/me/waliedyassen/runescript/compiler/codegen/block/LabelTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.codegen.block;
9 |
10 | import org.junit.jupiter.api.Test;
11 |
12 | import static org.junit.jupiter.api.Assertions.assertFalse;
13 | import static org.junit.jupiter.api.Assertions.assertTrue;
14 |
15 | class LabelTest {
16 |
17 | @Test
18 | void testEntryLabel() {
19 | assertTrue(new Label(0, "entry").isEntryLabel());
20 | assertFalse(new Label(1, "block").isEntryLabel());
21 | }
22 | }
--------------------------------------------------------------------------------
/runescript-compiler/src/test/java/me/waliedyassen/runescript/compiler/codegen/opcode/CoreOpcodeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.codegen.opcode;
9 |
10 | import org.junit.jupiter.api.Test;
11 |
12 | import static org.junit.jupiter.api.Assertions.assertFalse;
13 | import static org.junit.jupiter.api.Assertions.assertTrue;
14 |
15 | class CoreOpcodeTest {
16 |
17 | @Test
18 | void testLargeOperand() {
19 | for (var opcode : CoreOpcode.values()) {
20 | switch (opcode){
21 | case RETURN:
22 | case POP_INT_DISCARD:
23 | case POP_STRING_DISCARD:
24 | case ADD:
25 | case SUB:
26 | case MUL:
27 | case DIV:
28 | case MOD:
29 | case AND:
30 | case OR:
31 | assertFalse(opcode.isLargeOperand());
32 | break;
33 | default:
34 | assertTrue(opcode.isLargeOperand());
35 | break;
36 | }
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/runescript-compiler/src/test/java/me/waliedyassen/runescript/compiler/error/ThrowingErrorReporter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.error;
9 |
10 | import me.waliedyassen.runescript.compiler.CompilerError;
11 |
12 | public final class ThrowingErrorReporter extends ErrorReporter {
13 |
14 | @Override
15 | public void addError(CompilerError error) {
16 | throw error;
17 | }
18 | }
--------------------------------------------------------------------------------
/runescript-compiler/src/test/java/me/waliedyassen/runescript/compiler/util/VariableScopeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.compiler.util;
9 |
10 | import me.waliedyassen.runescript.compiler.lexer.token.Kind;
11 | import org.junit.jupiter.api.Test;
12 |
13 | import static org.junit.jupiter.api.Assertions.assertEquals;
14 |
15 | class VariableScopeTest {
16 |
17 | @Test
18 | void testLookup(){
19 | assertEquals(VariableScope.LOCAL, VariableScope.forKind(Kind.DOLLAR));
20 | assertEquals(VariableScope.GLOBAL, VariableScope.forKind(Kind.MOD));
21 | }
22 | }
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/codegen/local_01.rs2:
--------------------------------------------------------------------------------
1 | [clientscript,basic_defines](boolean $bool_param, int $int_param, string $string_param, long $long_param)
2 | def_int $my_int = 1234;
3 | def_string $my_string = "test";
4 | def_boolean $my_true_bool = true;
5 | def_long $my_long = 1234L;
6 | def_boolean $my_false_bool = false;
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/codegen/operator_bitwise_and.rs2:
--------------------------------------------------------------------------------
1 | [proc,and](int $a, int $b)(int)
2 | return(calc($a & $b));
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/codegen/operator_bitwise_or.rs2:
--------------------------------------------------------------------------------
1 | [proc,or](int $a, int $b)(int)
2 | return(calc($a | $b));
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/semantics/typecheck/array_01.rs2:
--------------------------------------------------------------------------------
1 | [clientscript,caller_01]
2 | def_int $array0(1);
3 | def_int $array1(1);
4 | def_int $array2(1);
5 | ~test_01(array0, 0, array2);
6 |
7 | [proc,test_01](intarray $array0, int $index, intarray $array1)(int)
8 | return($array0(index));
9 |
10 |
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/semantics/typecheck/array_02.rs2:
--------------------------------------------------------------------------------
1 | [clientscript,caller_02]
2 | def_int $array0(1);
3 | def_int $array2(1);
4 | ~test_02(array0, 0, array2);
5 |
6 | [proc,test_02](intarray $array0, int $index, intarray $array1)(int)
7 | return($array0(index));
8 |
9 |
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/semantics/typecheck/calc_01.rs2:
--------------------------------------------------------------------------------
1 | [proc,calc_01](int $parameter)(int)
2 | def_int $first = calc($parameter * 2 + 1);
3 | def_int $second = calc($parameter % 2 + 1);
4 | def_int $third = calc($parameter / 2 + 1);
5 | return(calc($first + $second - $third));
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/semantics/typecheck/calc_02.rs2:
--------------------------------------------------------------------------------
1 | [clientscript,calc_02](boolean $parameter)
2 | // calc boolean + boolean should produce an error
3 | def_int $first = calc($parameter + true);
4 | // calc boolean + int should produce an error
5 | def_int $second = calc($parameter + 2);
6 | // this calc should produce no error
7 | def_int $third = calc(2 / 2 + 1);
8 | // arithmetic without calc should produce an error
9 | def_int $fourth = 2 + 2 / 2;
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/semantics/typecheck/call_01.rs2:
--------------------------------------------------------------------------------
1 | [clientscript,main]
2 | ~main(true);
3 |
4 | [proc,main](boolean $call_sub_01)
5 | if ($call_sub_01 = true) {
6 | @sub_01(0);
7 | }
8 |
9 | [label,sub_01](int $parameter)
10 | ~main(false);
11 | @sub_02(calc($parameter + 1));
12 |
13 | [label,sub_02](int $parameter)
14 |
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/semantics/typecheck/operator_bitwise_and.rs2:
--------------------------------------------------------------------------------
1 | [proc,test](int $a, int $b)(int)
2 | return(calc($a & $b));
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/me/waliedyassen/runescript/compiler/semantics/typecheck/operator_bitwise_or.rs2:
--------------------------------------------------------------------------------
1 | [proc,or](int $a, int $b)(int)
2 | return(calc($a | $b));
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/parse-script.rs2:
--------------------------------------------------------------------------------
1 | [trigger,name]
2 | // the first statement.
3 | if (true) {
4 |
5 | }
6 | // the second statement.
7 | if (false) {
8 |
9 | }
--------------------------------------------------------------------------------
/runescript-compiler/src/test/resources/visitor-tree-script.rs2:
--------------------------------------------------------------------------------
1 | [clientscript,visitor_tree_test](int $int0, string $string1, int $int1, long $long0)(boolean)
2 | def_int $local0 = 0;
3 | def_long $local1; $local1 = ll;
4 | def_string $string1 = "string literal";
5 | def_string $concatenation = "hello<^my_string_constant>";
6 | dynamic_0;
7 | command(false);
8 | if ($local1 = 1l) {
9 | another_command(true);
10 | }
11 | if (false) {
12 | another_command(true);
13 | } else {
14 |
15 | }
16 | switch_int($local0) {
17 | case 0,1,2,3,4,5 :
18 | $string1 = "Less than 5";
19 | case 6,7,8,9 :
20 | $string1 = "More than 5";
21 | case default :
22 | $string1 = "Not a single digit";
23 | }
24 | def_string $string2;
25 | switch_int($local0) {
26 | case 0,1,2,3,4,5 :
27 | $string2 = "Less than 5";
28 | case 6,7,8,9 :
29 | $string2 = "More than 5";
30 | }
31 | while ($int0 > 0) {
32 | $int0 = sub($int0, 1);
33 | }
34 |
35 | def_coord $coord = 0_50_50_32_32;
36 | return(~gosub_test($local0,$string1));
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/file/FileType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.file;
9 |
10 | import me.waliedyassen.runescript.editor.ui.editor.Editor;
11 |
12 | import javax.swing.*;
13 | import java.nio.file.Path;
14 |
15 | /**
16 | * Represents a file type in our editor.
17 | *
18 | * @author Walied K. Yassen
19 | */
20 | public interface FileType {
21 |
22 | /**
23 | * Creates an {@link Editor} for this file type.
24 | *
25 | * @param path the path of the file we are creating the editor for.
26 | * @return the created {@link Editor} type object instance.
27 | */
28 | Editor> createEditor(Path path);
29 |
30 | /**
31 | * Returns the name of the file type.
32 | *
33 | * @return the name of the file type.
34 | */
35 | String getName();
36 |
37 | /**
38 | * Returns the description of the file type.
39 | *
40 | * @return the description of the file type.
41 | */
42 | String getDescription();
43 |
44 | /**
45 | * Returns the extensions that are supported by this file type.
46 | *
47 | * @return the extensions that are supported by this file type.
48 | */
49 | String[] getExtensions();
50 |
51 | /**
52 | * Returns the icon of the file type.
53 | *
54 | * @return the icon of the file type.
55 | */
56 | Icon getIcon();
57 | }
58 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/file/impl/PlainFileType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.file.impl;
9 |
10 | import me.waliedyassen.runescript.editor.EditorIcons;
11 | import me.waliedyassen.runescript.editor.file.FileType;
12 | import me.waliedyassen.runescript.editor.ui.editor.Editor;
13 | import me.waliedyassen.runescript.editor.ui.editor.code.FileEditor;
14 |
15 | import javax.swing.*;
16 | import java.nio.file.Path;
17 |
18 | /**
19 | * The default file type that will be used in-case no file type was found.
20 | *
21 | * @author Walied K. Yassen
22 | */
23 | public final class PlainFileType implements FileType {
24 |
25 | /**
26 | * {@inheritDoc}
27 | */
28 | @Override
29 | public Editor> createEditor(Path path) {
30 | return new FileEditor(this, path);
31 | }
32 |
33 | /**
34 | * {@inheritDoc}
35 | */
36 | @Override
37 | public String getName() {
38 | return "Plain Text File";
39 | }
40 |
41 | /**
42 | * {@inheritDoc}
43 | */
44 | @Override
45 | public String getDescription() {
46 | return "Plain Text File";
47 | }
48 |
49 | /**
50 | * {@inheritDoc}
51 | */
52 | @Override
53 | public String[] getExtensions() {
54 | return new String[0];
55 | }
56 |
57 | /**
58 | * {@inheritDoc}
59 | */
60 | @Override
61 | public Icon getIcon() {
62 | return EditorIcons.FILETYPE_FILE_ICON;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/file/impl/ProjectFileType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.file.impl;
9 |
10 | import me.waliedyassen.runescript.editor.Api;
11 | import me.waliedyassen.runescript.editor.EditorIcons;
12 | import me.waliedyassen.runescript.editor.file.FileType;
13 | import me.waliedyassen.runescript.editor.ui.editor.Editor;
14 | import me.waliedyassen.runescript.editor.ui.editor.project.ProjectEditor;
15 |
16 | import javax.swing.*;
17 | import java.nio.file.Path;
18 |
19 | /**
20 | * Represents the RuneScript Project File file type.
21 | *
22 | * @author Walied K. Yassen
23 | */
24 | public final class ProjectFileType implements FileType {
25 |
26 | /**
27 | * {@inheritDoc}
28 | */
29 | @Override
30 | public Editor> createEditor(Path path) {
31 | var currentProject = Api.getApi().getProjectManager().getCurrentProject().get();
32 | return new ProjectEditor(path, currentProject);
33 | }
34 |
35 | /**
36 | * {@inheritDoc}
37 | */
38 | @Override
39 | public String getName() {
40 | return "RuneScript Project File";
41 | }
42 |
43 | /**
44 | * {@inheritDoc}
45 | */
46 | @Override
47 | public String getDescription() {
48 | return "RuneScript Project File";
49 | }
50 |
51 | /**
52 | * {@inheritDoc}
53 | */
54 | @Override
55 | public String[] getExtensions() {
56 | return new String[]{"rsproj"};
57 | }
58 |
59 | /**
60 | * {@inheritDoc}
61 | */
62 | @Override
63 | public Icon getIcon() {
64 | return EditorIcons.FILETYPE_FILE_ICON;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/file/impl/ScriptFileType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.file.impl;
9 |
10 | import me.waliedyassen.runescript.editor.EditorIcons;
11 | import me.waliedyassen.runescript.editor.file.FileType;
12 | import me.waliedyassen.runescript.editor.ui.editor.Editor;
13 | import me.waliedyassen.runescript.editor.ui.editor.code.CodeEditor;
14 |
15 | import javax.swing.*;
16 | import java.nio.file.Path;
17 |
18 | /**
19 | * Represent the RuneScript Script file type.
20 | *
21 | * @author Walied K. Yassen
22 | */
23 | public final class ScriptFileType implements FileType {
24 |
25 | /**
26 | * An array of all the extensions this type su
27 | */
28 | private static final String[] EXTENSIONS = new String[]{"cs2", "rs2"};
29 |
30 | /**
31 | * {@inheritDoc}
32 | */
33 | @Override
34 | public Editor> createEditor(Path path) {
35 | return new CodeEditor(this, path);
36 | }
37 |
38 | /**
39 | * {@inheritDoc}
40 | */
41 | @Override
42 | public String getName() {
43 | return "RuneScript Script File";
44 | }
45 |
46 | /**
47 | * {@inheritDoc}
48 | */
49 | @Override
50 | public String getDescription() {
51 | return "RuneScript Script File";
52 | }
53 |
54 | /**
55 | * {@inheritDoc}
56 | */
57 | @Override
58 | public String[] getExtensions() {
59 | return EXTENSIONS;
60 | }
61 |
62 | /**
63 | * {@inheritDoc}
64 | */
65 | @Override
66 | public Icon getIcon() {
67 | return EditorIcons.FILETYPE_SCRIPT_ICON;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/job/WorkExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.job;
9 |
10 | import lombok.Getter;
11 |
12 | import java.util.concurrent.Executors;
13 | import java.util.concurrent.ScheduledExecutorService;
14 |
15 | /**
16 | * A static-class which contains the common executors we are using in the IDE.
17 | *
18 | * @author Walied K. Yassen
19 | */
20 | public final class WorkExecutor {
21 |
22 | /**
23 | * A scheduled executor which uses only one thread to schedule all of it's jobs, it's used for low priority tasks.
24 | */
25 | @Getter
26 | private static final ScheduledExecutorService singleThreadScheduler = Executors.newScheduledThreadPool(1);
27 |
28 | private WorkExecutor() {
29 | // NOOP
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/pack/Pack.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.pack;
9 |
10 | /**
11 | * The interface which should be implemented by all of the packing methods.
12 | *
13 | * @author Walied K. Yassen
14 | */
15 | public interface Pack {
16 |
17 | /**
18 | * Packs the specified {@link PackFile} using this method.
19 | *
20 | * @param file the file to pack using this method.
21 | */
22 | void pack(PackFile file);
23 | }
24 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/pack/PackFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.pack;
9 |
10 | import lombok.Data;
11 |
12 | /**
13 | * Contains the data about a specific file that we want to pack.
14 | *
15 | * @author Walied K. Yassen
16 | */
17 | @Data
18 | public final class PackFile {
19 |
20 | /**
21 | * The id that was assigned to the file.
22 | */
23 | private final int id;
24 |
25 | /**
26 | * The name of the file.
27 | */
28 | private final String name;
29 |
30 | /**
31 | * The binary data of file.
32 | */
33 | private final byte[] data;
34 | }
35 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/pack/impl/FlatPack.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.pack.impl;
9 |
10 | import lombok.RequiredArgsConstructor;
11 | import lombok.SneakyThrows;
12 | import lombok.extern.slf4j.Slf4j;
13 | import me.waliedyassen.runescript.editor.pack.Pack;
14 | import me.waliedyassen.runescript.editor.pack.PackFile;
15 |
16 | import java.nio.file.Files;
17 | import java.nio.file.Path;
18 | import java.nio.file.StandardOpenOption;
19 |
20 |
21 | /**
22 | * Represents a {@link Pack} implementation that packs to a directory
23 | *
24 | * @author Walied K. Yassen
25 | */
26 | @Slf4j
27 | @RequiredArgsConstructor
28 | public final class FlatPack implements Pack {
29 |
30 | /**
31 | * The path of hte directory we will be packing in.
32 | */
33 | private final Path path;
34 |
35 | /**
36 | * {@inheritDoc}
37 | */
38 | @SneakyThrows
39 | @Override
40 | public void pack(PackFile file) {
41 | var path = this.path.resolve(String.format("%d-%s", file.getId(), file.getName()));
42 | Files.write(path, file.getData(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/pack/provider/PackProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.pack.provider;
9 |
10 | import me.waliedyassen.runescript.editor.pack.Pack;
11 |
12 | /**
13 | * A provider interface for {@link Pack} objects which requires an extension to be provided for each {@link Pack}.
14 | *
15 | * @author Walied K. Yassen
16 | */
17 | public interface PackProvider {
18 |
19 | /**
20 | * Creates a new {@link Pack} object for the specified {@code packName}.
21 | *
22 | * @param packName the pack database name to create the {@link Pack} object for.
23 | * @return the created {@link Pack} object or {@code null} if we failed to open one.
24 | */
25 | Pack create(String packName);
26 | }
27 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/pack/provider/impl/FlatPackProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.pack.provider.impl;
9 |
10 | import lombok.RequiredArgsConstructor;
11 | import lombok.SneakyThrows;
12 | import me.waliedyassen.runescript.editor.pack.impl.FlatPack;
13 | import me.waliedyassen.runescript.editor.pack.provider.PackProvider;
14 |
15 | import java.nio.file.Files;
16 | import java.nio.file.Path;
17 |
18 | /**
19 | * A {@link PackProvider} implementation that is responsible for providing {@link FlatPack}.
20 | *
21 | * @author Walied K. Yassen
22 | */
23 | @RequiredArgsConstructor
24 | public final class FlatPackProvider implements PackProvider {
25 |
26 | /**
27 | * The path which leads to the root directory that contains the pack databases.
28 | */
29 | private final Path path;
30 |
31 | /**
32 | * {@inheritDoc}
33 | */
34 | @SneakyThrows
35 | @Override
36 | public FlatPack create(String packName) {
37 | var directory = path.resolve(packName);
38 | if (!Files.exists(directory)) {
39 | Files.createDirectories(directory);
40 | }
41 | if (!Files.isDirectory(directory)) {
42 | throw new IllegalArgumentException();
43 | }
44 | return new FlatPack(directory);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/pack/provider/impl/SQLitePackProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.pack.provider.impl;
9 |
10 | import lombok.RequiredArgsConstructor;
11 | import me.waliedyassen.runescript.editor.pack.Pack;
12 | import me.waliedyassen.runescript.editor.pack.impl.SQLitePack;
13 | import me.waliedyassen.runescript.editor.pack.provider.PackProvider;
14 |
15 | import java.nio.file.Path;
16 |
17 | /**
18 | * A {@link PackProvider} implementation that is responsible for providing {@link SQLitePack}.
19 | *
20 | * @author Walied K. Yassen
21 | */
22 | @RequiredArgsConstructor
23 | public final class SQLitePackProvider implements PackProvider {
24 |
25 | /**
26 | * The path which leads to the root directory that contains the SQLite databases.
27 | */
28 | private final Path path;
29 |
30 | /**
31 | * {@inheritDoc}
32 | */
33 | @Override
34 | public Pack create(String packName) {
35 | return new SQLitePack(path.resolve(packName + ".db").toAbsolutePath().toString());
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/project/PackType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.project;
9 |
10 | import me.waliedyassen.runescript.editor.pack.provider.PackProvider;
11 | import me.waliedyassen.runescript.editor.pack.provider.impl.FlatPackProvider;
12 | import me.waliedyassen.runescript.editor.pack.provider.impl.SQLitePackProvider;
13 |
14 | import java.nio.file.Path;
15 |
16 | /**
17 | * The packing type of a project.
18 | *
19 | * @author Walied K. Yassen
20 | */
21 | public enum PackType {
22 | /**
23 | * Stores the output as files in the pack directory.
24 | */
25 | FLATFILE {
26 | @Override
27 | public PackProvider newInstance(Path directory) {
28 | return new FlatPackProvider(directory);
29 | }
30 | },
31 |
32 | /**
33 | * STore the output as entries in a sqlite database
34 | */
35 | SQLITE {
36 | @Override
37 | public PackProvider newInstance(Path directory) {
38 | return new SQLitePackProvider(directory);
39 | }
40 | };
41 |
42 | /**
43 | * Creates new {@link PackProvider} instance object.
44 | *
45 | * @param directory the directory which the packed database will be placed in.
46 | * @return the created {@link PackProvider} object.
47 | */
48 | public abstract PackProvider newInstance(Path directory);
49 | }
50 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/project/ProjectException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.project;
9 |
10 | /**
11 | * A {@link RuntimeException} implementation for exceptions or errors that happen during the execution of the {@link
12 | * ProjectManager} functions.
13 | *
14 | * @author Walied K. Yassen
15 | */
16 | public final class ProjectException extends RuntimeException {
17 |
18 | /**
19 | * Constructs a new {@link ProjectException} type object instance.
20 | *
21 | * @param message
22 | * the error message of the exception.
23 | */
24 | public ProjectException(String message) {
25 | super(message);
26 | }
27 |
28 |
29 | /**
30 | * Constructs a new {@link ProjectException} type object instance.
31 | *
32 | * @param message
33 | * the error message of the exception.
34 | * @param cause
35 | * the original cause of the exception.
36 | */
37 | public ProjectException(String message, Throwable cause) {
38 | super(message, cause);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/project/cache/CachedError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.project.cache;
9 |
10 | import lombok.Getter;
11 | import lombok.RequiredArgsConstructor;
12 | import me.waliedyassen.runescript.commons.document.Span;
13 |
14 | /**
15 | * A cached error that is stored in a cached file.
16 | *
17 | * @author Walied K. Yassen
18 | */
19 | @RequiredArgsConstructor
20 | public final class CachedError {
21 |
22 | /**
23 | * The range of the error in the source code.
24 | */
25 | @Getter
26 | private final Span span;
27 |
28 | /**
29 | * The line which contains the error.
30 | */
31 | @Getter
32 | private final int line;
33 |
34 | /**
35 | * The message of the error.
36 | */
37 | @Getter
38 | private final String message;
39 | }
40 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/project/compile/CompileResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.project.compile;
9 |
10 | import lombok.Getter;
11 | import lombok.RequiredArgsConstructor;
12 | import me.waliedyassen.runescript.compiler.syntax.SyntaxBase;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * An object that holds the result of a compile call within a project.
19 | *
20 | * @author Walied K. Yassen
21 | */
22 | @RequiredArgsConstructor
23 | public final class CompileResult {
24 |
25 | /**
26 | * A list of all the parsed script syntax.
27 | */
28 | @Getter
29 | private final List syntax = new ArrayList<>();
30 | }
31 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/project/compile/ProjectCompiler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.project.compile;
9 |
10 | import me.waliedyassen.runescript.compiler.CompiledUnit;
11 | import me.waliedyassen.runescript.compiler.Input;
12 | import me.waliedyassen.runescript.compiler.Output;
13 | import me.waliedyassen.runescript.compiler.syntax.SyntaxBase;
14 | import me.waliedyassen.runescript.editor.project.cache.unit.CacheUnit;
15 |
16 | import java.io.IOException;
17 |
18 | /**
19 | * Represents a bridge between the project and the compiler of a specific type of files.
20 | *
21 | * @param the type of Syntax Tree node this compiler produces.
22 | * @param the type of the compilation unit this compiler produces.
23 | * @author Walied K. Yassen
24 | */
25 | public interface ProjectCompiler> {
26 |
27 | /**
28 | * Performs a compile call using the underlying compiler.
29 | *
30 | * @param input the input of the compiler.
31 | * @return the output of the compiler.
32 | */
33 | Output compile(Input input) throws IOException;
34 |
35 | /**
36 | * Creates a new {@link CacheUnit} implementation object.
37 | *
38 | * @param path the file path of the cache unit.
39 | * @param fileName the file name of the cache unit.
40 | * @return the created {@link CacheUnit} object.
41 | */
42 | CacheUnit> createUnit(String path, String fileName);
43 | }
44 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/project/compile/ProjectCompilerProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.project.compile;
9 |
10 | import java.util.HashMap;
11 | import java.util.Map;
12 |
13 | /**
14 | * Responsible for managing and providing {@link ProjectCompiler} objects from file name extensions.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | public final class ProjectCompilerProvider {
19 |
20 | /**
21 | * ِA map of all the registered compilers in this provider.
22 | */
23 | private final Map> compilers = new HashMap<>();
24 |
25 | /**
26 | * Registers the {@link ProjectCompiler} for the specified {@code extension}.
27 | *
28 | * @param extension the file name extension to register the compiler for.
29 | * @param compiler the compiler that we want to register.
30 | */
31 | public void register(String extension, ProjectCompiler, ?> compiler) {
32 | compilers.put(extension, compiler);
33 | }
34 |
35 | /**
36 | * Returns the {@link ProjectCompiler} that is registered for the specified {@code extension}.
37 | *
38 | * @param extension the file name extension that we want to retrieve it's associated compiler.
39 | * @return the {@link ProjectCompiler} object if found otherwise {@code null}.
40 | */
41 | public ProjectCompiler, ?> get(String extension) {
42 | return compilers.get(extension);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/project/dependency/CircularDependencyException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.project.dependency;
9 |
10 | /**
11 | * a {@link RuntimeException} implementation which is raised when a circular dependency was found in a dependency
12 | * graph.
13 | *
14 | * @author Walied K. Yassen
15 | */
16 | public final class CircularDependencyException extends RuntimeException {
17 |
18 | /**
19 | * Constructs a new {@link CircularDependencyException} type object instance.
20 | *
21 | * @param message the message of the exception.
22 | */
23 | public CircularDependencyException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * Constructs a new {@link CircularDependencyException} type object instance.
29 | *
30 | * @param message the message of the exception.
31 | * @param cause the cause of the exception.
32 | */
33 | public CircularDependencyException(String message, Throwable cause) {
34 | super(message, cause);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/property/PropertyChangeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.property;
9 |
10 | /**
11 | * A listener that listens to changes in a specific property or properties value.
12 | *
13 | * @param
14 | * the type of value the property or properties hold.
15 | */
16 | @FunctionalInterface
17 | public interface PropertyChangeListener {
18 |
19 | /**
20 | * Invokes the listener. This will get called when a value is set and is different than the old value in a specific
21 | * property.
22 | *
23 | * @param property
24 | * the property which it's the value was changed.
25 | * @param oldValue
26 | * the old value of the property.
27 | * @param newValue
28 | * the new value of the property.
29 | */
30 | void propertyChanged(Property property, T oldValue, T newValue);
31 | }
32 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/property/impl/BooleanProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.property.impl;
9 |
10 | import me.waliedyassen.runescript.editor.property.Property;
11 |
12 | /**
13 | * A {@link Property} implementation that holds a {@link Boolean} value.
14 | *
15 | * @author Walied K. Yassen
16 | */
17 | public final class BooleanProperty extends Property {
18 |
19 | /**
20 | * Constructs a new {@link BooleanProperty} type object instance.
21 | */
22 | public BooleanProperty() {
23 | this(false);
24 | }
25 |
26 | /**
27 | * Constructs a new {@link BooleanProperty} type object instance.
28 | *
29 | * @param value
30 | * the initial value of the property.
31 | */
32 | public BooleanProperty(Boolean value) {
33 | super(value);
34 | }
35 |
36 | /**
37 | * Returns a {@link BooleanProperty} that will always hold the opposite value of this property, except for when the
38 | * value is {@code null} the returned property will also hold a {@code null} value.
39 | *
40 | * @return the negated {@link BooleanProperty} object.
41 | */
42 | public BooleanProperty negate() {
43 | var negated = new BooleanProperty();
44 | bind(value -> negated.set(value == null ? null : !value));
45 | return negated;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/property/impl/ReferenceProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.property.impl;
9 |
10 | import me.waliedyassen.runescript.editor.property.Property;
11 |
12 | /**
13 | * A {@link Property} implementation that holds a reference value of type {@link T}.
14 | *
15 | * @author Walied K. Yassen
16 | */
17 | public final class ReferenceProperty extends Property {
18 |
19 | /**
20 | * Constructs a new {@link ReferenceProperty} type object instance.
21 | */
22 | public ReferenceProperty() {
23 | this(null);
24 | }
25 |
26 | /**
27 | * Constructs a new {@link ReferenceProperty} type object instance.
28 | *
29 | * @param value
30 | * the initial value of the reference.
31 | */
32 | public ReferenceProperty(T value) {
33 | super(value);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/property/impl/StringProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.property.impl;
9 |
10 | import me.waliedyassen.runescript.editor.property.Property;
11 |
12 | /**
13 | * A {@link Property} implementation that holds a {@link String} value.
14 | *
15 | * @author Walied K. Yassen
16 | */
17 | public final class StringProperty extends Property {
18 |
19 | /**
20 | * Constructs a new {@link StringProperty} type object instance.
21 | */
22 | public StringProperty() {
23 | this("");
24 | }
25 |
26 | /**
27 | * Constructs a new {@link StringProperty} type object instance.
28 | *
29 | * @param value
30 | * the initial value of the property.
31 | */
32 | public StringProperty(String value) {
33 | super(value);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/settings/state/SettingsState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.settings.state;
9 |
10 | /**
11 | * The base class for all of the settings states.
12 | *
13 | * @author Walied K. Yassen
14 | */
15 | public interface SettingsState {
16 | // NOOP
17 | }
18 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/shortcut/Shortcut.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.shortcut;
9 |
10 | import lombok.AccessLevel;
11 | import lombok.Getter;
12 | import lombok.RequiredArgsConstructor;
13 |
14 | import javax.swing.*;
15 |
16 | /**
17 | * A single shortcut in the shortcut system.
18 | *
19 | * @author Walied K. Yassen
20 | */
21 | @RequiredArgsConstructor(access = AccessLevel.PACKAGE)
22 | public final class Shortcut {
23 |
24 | /**
25 | * The name of the shortcut.
26 | */
27 | @Getter
28 | private final String name;
29 |
30 | /**
31 | * The key stroke of the shortcut.
32 | */
33 | @Getter
34 | private final KeyStroke keyStroke;
35 |
36 | /**
37 | * The action to perform when the callback is executed.
38 | */
39 | @Getter
40 | private final UiAction action;
41 | }
42 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/shortcut/UiAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.shortcut;
9 |
10 | /**
11 | * A functional interface that represents an UI action.
12 | *
13 | * @author Walied K. Yassen
14 | */
15 | @FunctionalInterface
16 | public interface UiAction {
17 |
18 | /**
19 | * Gets called when the ui action is being executed.
20 | *
21 | * @param source
22 | * the source UI attachment object.
23 | */
24 | void execute(Object source);
25 | }
26 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/shortcut/common/CommonGroups.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.shortcut.common;
9 |
10 | import me.waliedyassen.runescript.editor.shortcut.ShortcutGroup;
11 | import me.waliedyassen.runescript.editor.shortcut.ShortcutManager;
12 |
13 | /**
14 | * Holds all of the common shortcut groups.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | public interface CommonGroups {
19 | /**
20 | * The explorer tree shortcuts.
21 | */
22 | ShortcutGroup EXPLORER = ShortcutManager.getInstance().createGroup("Explorer Shortcuts");
23 |
24 | /**
25 | * The editor view shortcuts.
26 | */
27 | ShortcutGroup EDITOR = ShortcutManager.getInstance().createGroup("Editor Shortcuts");
28 |
29 | /**
30 | * The errors view shortcuts.
31 | */
32 | ShortcutGroup ERRORS = ShortcutManager.getInstance().createGroup("Errors Shortcuts");
33 | }
34 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/shortcut/common/CommonShortcuts.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.shortcut.common;
9 |
10 | /**
11 | * Holds all of the common shortcut names.
12 | *
13 | * @author WaliedK. Yassen
14 | */
15 | public interface CommonShortcuts {
16 |
17 | /**
18 | * The explorer close project shortcut name.
19 | */
20 | String EXPLORER_CLOSE_PROJECT = "Explorer Close Project";
21 |
22 | /**
23 | * The explorer close project shortcut name.
24 | */
25 | String EXPLORER_DELETE = "Explorer Delete";
26 |
27 | /**
28 | * The editor close file shortcut name.
29 | */
30 | String EDITOR_CLOSE_FILE = "Close Editor File";
31 |
32 | /**
33 | * The editor close file shortcut name.
34 | */
35 | String EDITOR_SAVE_FILE = "Save Editor File";
36 | }
37 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/dialog/DialogResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.dialog;
9 |
10 | /**
11 | * An enum holding all of the possible option dialog results.
12 | *
13 | * @author Walied K. Yassen
14 | */
15 | public enum DialogResult {
16 |
17 | /**
18 | * The "Yes" option was selected in the dialog.
19 | */
20 | YES,
21 |
22 | /**
23 | * The "No" option was selected in the dialog.
24 | */
25 | NO,
26 |
27 | /**
28 | * The "Cancel" option was selected in the dialog.
29 | */
30 | CANCEL,
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/editor/code/completion/cache/AutoCompleteCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.editor.code.completion.cache;
9 |
10 | import lombok.Getter;
11 | import lombok.RequiredArgsConstructor;
12 | import me.waliedyassen.runescript.editor.ui.editor.code.completion.impl.CodeCompletion;
13 | import org.fife.ui.autocomplete.Completion;
14 | import org.fife.ui.autocomplete.CompletionProvider;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Collections;
18 | import java.util.List;
19 |
20 | /**
21 | * A cache of {@link CodeCompletion} objects that are related.
22 | *
23 | * @author Walied K. Yassen
24 | */
25 | @RequiredArgsConstructor
26 | public final class AutoCompleteCache {
27 |
28 | /**
29 | * A list of all the cached {@link CodeCompletion} objects.
30 | */
31 | @Getter
32 | private final List completions = new ArrayList<>();
33 |
34 | /**
35 | * The provider which instantiated this completion cache.
36 | */
37 | @Getter
38 | private final CompletionProvider provider;
39 |
40 | /**
41 | * Adds a new {@link Completion} to the completions list in the appropriate place.
42 | *
43 | * @param completion the completion that we want to add to the completions list.
44 | */
45 | public void addSorted(Completion completion) {
46 | var index = Collections.binarySearch(completions, completion);
47 | if (index < 0) {
48 | index = -(index + 1);
49 | }
50 | completions.add(index, completion);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/editor/code/completion/impl/CodeCompletion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.editor.code.completion.impl;
9 |
10 | /**
11 | * The base class for all of our completion implementation.
12 | *
13 | * @author Walied K. Yassen
14 | */
15 | public interface CodeCompletion {
16 |
17 | /**
18 | * {@inheritDoc}
19 | */
20 | @Override
21 | boolean equals(Object o);
22 |
23 | /**
24 | * {@inheritDoc}
25 | */
26 | @Override
27 | int hashCode();
28 | }
29 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/editor/code/completion/impl/KeywordCompletion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.editor.code.completion.impl;
9 |
10 | import org.fife.ui.autocomplete.BasicCompletion;
11 | import org.fife.ui.autocomplete.CompletionProvider;
12 |
13 | /**
14 | * Represents a {@link CodeCompletion} implementation for a keyword.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | public final class KeywordCompletion extends BasicCompletion implements CodeCompletion {
19 |
20 | /**
21 | * The keyword that we are auto completing.
22 | */
23 | private final String keyword;
24 |
25 | /**
26 | * Constructs a new {@link KeywordCompletion} type object instance.
27 | *
28 | * @param provider the provider of the auto completion.
29 | * @param keyword the keyword that we are auto completing.
30 | */
31 | public KeywordCompletion(CompletionProvider provider, String keyword) {
32 | super(provider, keyword, "Insert " + keyword + " keyword.", "Inserts a '" + keyword + "' at keyword at the current position.");
33 | this.keyword = keyword;
34 | setRelevance(5);
35 | }
36 |
37 | /**
38 | * {@inheritDoc}
39 | */
40 | @Override
41 | public boolean equals(Object o) {
42 | return keyword.equals(o);
43 | }
44 |
45 | /**
46 | * {@inheritDoc}
47 | */
48 | @Override
49 | public int hashCode() {
50 | return keyword.hashCode();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/editor/code/parser/notice/ErrorNotice.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.editor.code.parser.notice;
9 |
10 | import org.fife.ui.rsyntaxtextarea.parser.DefaultParserNotice;
11 | import org.fife.ui.rsyntaxtextarea.parser.Parser;
12 |
13 | import java.awt.*;
14 |
15 | /**
16 | * A parser notice that indicates there is an error somewhere.
17 | *
18 | * @author Walied K. Yassen
19 | */
20 | public final class ErrorNotice extends DefaultParserNotice {
21 |
22 | /**
23 | * Constructs a new {@link ErrorNotice} type object instance.
24 | *
25 | * @param parser the parser which produced this error notice.
26 | * @param message the message of the error.
27 | * @param line the line which the error is located at.
28 | * @param offset the start offset of the error in source code.
29 | * @param width the width of the error in source code.
30 | */
31 | public ErrorNotice(Parser parser, String message, int line, int offset, int width) {
32 | super(parser, message, line, offset, width);
33 | setLevel(Level.ERROR);
34 | setColor(Color.red);
35 | }
36 | }
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/editor/code/tokenMaker/CodeTokens.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.editor.code.tokenMaker;
9 |
10 | import org.fife.ui.rsyntaxtextarea.TokenTypes;
11 |
12 | /**
13 | * Holds all of the RuneScript code tokens that we are using for syntax highlighting and other stuff.
14 | *
15 | * @author Walied K. Yassen
16 | */
17 | public interface CodeTokens {
18 | int NULL = TokenTypes.NULL;
19 | int WHITESPACE = TokenTypes.WHITESPACE;
20 | int STRING_LITERAL = TokenTypes.LITERAL_STRING_DOUBLE_QUOTE;
21 | int LINE_COMMENT = TokenTypes.COMMENT_EOL;
22 | int MULTILINE_COMMENT = TokenTypes.COMMENT_MULTILINE;
23 | int NUMBER_LITERAL = TokenTypes.LITERAL_NUMBER_DECIMAL_INT;
24 | int HEX_LITERAL = TokenTypes.LITERAL_NUMBER_HEXADECIMAL;
25 | int LOCAL_VARIABLE = TokenTypes.VARIABLE;
26 | int IDENTIFIER = TokenTypes.IDENTIFIER;
27 | int KEYWORD = TokenTypes.RESERVED_WORD;
28 | int TYPE_NAME = TokenTypes.RESERVED_WORD_2;
29 | int UNDEFINED = TokenTypes.DEFAULT_NUM_TOKEN_TYPES;
30 | int SEPARATOR = TokenTypes.SEPARATOR;
31 | int OPERATOR = TokenTypes.OPERATOR;
32 | int DECLARATION = UNDEFINED + 1;
33 | int STRING_INTERPOLATE = DECLARATION + 1;
34 | int COORDGRID_LITERAL = STRING_INTERPOLATE + 1;
35 | int GLOBAL_VARIABLE = COORDGRID_LITERAL + 1;
36 | int CONSTANT = GLOBAL_VARIABLE + 1;
37 | int COMMAND = CONSTANT + 1;
38 | int NUM_TOKENS = COMMAND + 1;
39 | }
40 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/explorer/ExplorerView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.explorer;
9 |
10 | import lombok.Getter;
11 | import me.waliedyassen.runescript.editor.ui.explorer.tree.ExplorerTree;
12 |
13 | import javax.swing.*;
14 | import java.awt.*;
15 |
16 | /**
17 | * The explorer file tree docking view.
18 | *
19 | * @author Walied K. Yassen
20 | */
21 | public final class ExplorerView extends JPanel {
22 |
23 | /**
24 | * The docking {@code ID} for the explorer docking component.
25 | */
26 | public static final String DOCK_ID = "explorer.dock";
27 |
28 | /**
29 | * The tree of the explorer.
30 | */
31 | @Getter
32 | private final ExplorerTree tree = new ExplorerTree();
33 |
34 | /**
35 | * Constructs a new {@link ExplorerView} type object instance.
36 | */
37 | public ExplorerView() {
38 | setLayout(new BorderLayout());
39 | add(new JScrollPane(tree), BorderLayout.CENTER);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/explorer/tree/ExplorerModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package me.waliedyassen.runescript.editor.ui.explorer.tree;
10 |
11 | import javax.swing.tree.DefaultTreeModel;
12 | import javax.swing.tree.TreeNode;
13 |
14 | /**
15 | * The tree model of the project explorer tree.
16 | *
17 | * @author Walied K. Yassen
18 | */
19 | public final class ExplorerModel extends DefaultTreeModel {
20 |
21 | /**
22 | * Constructs a new {@link ExplorerModel} type object instance.
23 | *
24 | * @param root
25 | * the root node of the explorer.
26 | */
27 | public ExplorerModel(TreeNode root) {
28 | super(root);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/explorer/tree/ExplorerNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.explorer.tree;
9 |
10 | import lombok.Getter;
11 | import lombok.RequiredArgsConstructor;
12 | import me.waliedyassen.runescript.editor.ui.menu.action.ActionSource;
13 |
14 | import javax.swing.tree.DefaultMutableTreeNode;
15 |
16 | /**
17 | * The base class for all of the tree nodes in the project explorer tree.
18 | *
19 | * @author Walied K. Yassen
20 | */
21 | @RequiredArgsConstructor
22 | public abstract class ExplorerNode extends DefaultMutableTreeNode implements ActionSource {
23 |
24 | /**
25 | * The tree which owns this explorer node.
26 | */
27 | @Getter
28 | protected final ExplorerTree tree;
29 |
30 | /**
31 | * The value of the explorer node.
32 | */
33 | @Getter
34 | protected final T value;
35 |
36 | /**
37 | * Gets called when we double click the node in the tree.
38 | */
39 | public void onActionClick() {
40 | // NOOP
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/explorer/tree/lazy/LoadingNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.explorer.tree.lazy;
9 |
10 | import me.waliedyassen.runescript.editor.ui.explorer.tree.ExplorerNode;
11 | import me.waliedyassen.runescript.editor.ui.explorer.tree.ExplorerTree;
12 | import me.waliedyassen.runescript.editor.ui.menu.action.list.ActionList;
13 |
14 | /**
15 | * A placeholder node used to make the tree expandable so it will trigger the expand listener.
16 | *
17 | * @author Walied K. Yassen
18 | */
19 | public final class LoadingNode extends ExplorerNode {
20 |
21 | /**
22 | * Constructs a new {@link LoadingNode} type object instance.
23 | *
24 | * @param tree the owner tree of the explorer node.
25 | */
26 | public LoadingNode(ExplorerTree tree) {
27 | super(tree, null);
28 | setUserObject("Loading");
29 | setAllowsChildren(false);
30 | }
31 |
32 | /**
33 | * {@inheritDoc}
34 | */
35 | @Override
36 | public void populateActions(ActionList actionList) {
37 | // NOOP
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/menu/action/Action.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.menu.action;
9 |
10 | import javax.swing.*;
11 |
12 | /**
13 | * The base class for every menu action in our system.
14 | *
15 | * @author Walied K. Yassen
16 | */
17 | public interface Action {
18 |
19 | /**
20 | * Creates a new {@link JComponent} object which represents the action.
21 | *
22 | * @return the created {@link JComponent} object.
23 | */
24 | JComponent createComponent();
25 | }
26 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/menu/action/ActionManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.menu.action;
9 |
10 | import lombok.Getter;
11 | import me.waliedyassen.runescript.editor.ui.menu.action.list.ActionList;
12 |
13 | /**
14 | * The action manager of the context and popup menu(s) of the editor.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | public final class ActionManager {
19 |
20 | /**
21 | * The singleton instance of the {@link ActionManager} type.
22 | */
23 | @Getter
24 | private static final ActionManager instance = new ActionManager();
25 |
26 | /**
27 | * Prevent the creation of this type outside this class.
28 | */
29 | private ActionManager() {
30 | // NOOP
31 | }
32 |
33 | /**
34 | * Creates anew {@link ActionList} type object instance.
35 | *
36 | * @param source
37 | * the source of the action list.
38 | *
39 | * @return the created {@link ActionList} object.
40 | */
41 | public ActionList createList(Object source) {
42 | return new ActionList(source);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/menu/action/ActionSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.menu.action;
9 |
10 | import me.waliedyassen.runescript.editor.ui.menu.action.list.ActionList;
11 |
12 | /**
13 | * An interface which should be implemented in components they represent an action source which is basically any
14 | * component that should have right click action menu.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | public interface ActionSource {
19 |
20 | /**
21 | * Populates the actions of the action source into the specified {@link ActionList}.
22 | *
23 | * @param actionList
24 | * the actions list to populate the actions into.
25 | */
26 | void populateActions(ActionList actionList);
27 | }
28 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/menu/action/impl/Menu.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.menu.action.impl;
9 |
10 | import me.waliedyassen.runescript.editor.ui.menu.action.Action;
11 | import me.waliedyassen.runescript.editor.ui.menu.action.list.ActionList;
12 |
13 | import javax.swing.*;
14 |
15 | /**
16 | * An {@link Action} implementation which creates a {@link JMenu} object.
17 | *
18 | * @author Walied K. Yassen
19 | */
20 | public final class Menu extends ActionList implements Action {
21 |
22 | /**
23 | * The title of the menu.
24 | */
25 | private final String title;
26 |
27 | /**
28 | * Constructs a new {@link Menu} type object instance.
29 | *
30 | * @param source
31 | */
32 | public Menu(Object source, String title) {
33 | super(source);
34 | this.title = title;
35 | }
36 |
37 | /**
38 | * {@inheritDoc}
39 | */
40 | @Override
41 | public JComponent createComponent() {
42 | var menu = new JMenu(title);
43 | createComponents().forEach(menu::add);
44 | return menu;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/menu/action/impl/Separator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.menu.action.impl;
9 |
10 | import me.waliedyassen.runescript.editor.ui.menu.action.Action;
11 |
12 | import javax.swing.*;
13 |
14 | /**
15 | * An {@link Action} implementation which creates a {@link JPopupMenu.Separator} object.
16 | *
17 | * @author Walied K. Yassen
18 | */
19 | public final class Separator implements Action {
20 |
21 | /**
22 | * {@inheritDoc}
23 | */
24 | @Override
25 | public JComponent createComponent() {
26 | return new JPopupMenu.Separator();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/tabbedpane/TabComponent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.tabbedpane;
9 |
10 | import javax.swing.*;
11 | import java.awt.*;
12 |
13 | /**
14 | * Represents a tab component for the tabbed pane.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | public abstract class TabComponent extends JPanel {
19 |
20 | /**
21 | * Constructs a new {@link TabComponent} type object instance.
22 | *
23 | * @param layout the layout manager the component follows.
24 | */
25 | public TabComponent(LayoutManager layout) {
26 | super(layout);
27 | setOpaque(false);
28 | }
29 |
30 | /**
31 | * Updates the title of the tab component.
32 | *
33 | * @param title the new tile of the tab component.
34 | */
35 | public abstract void setTitle(String title);
36 |
37 | /**
38 | * Updates tooltip of the tab component.
39 | *
40 | * @param tooltip the new tooltip of the tab component.
41 | */
42 | public abstract void setTooltip(String tooltip);
43 | }
44 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/tabbedpane/TabbedPane.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package me.waliedyassen.runescript.editor.ui.tabbedpane;
10 |
11 | import javax.swing.*;
12 |
13 | /**
14 | * Represents a UI tabbed pane implementation.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | public final class TabbedPane extends JTabbedPane {
19 | // NOOP
20 | }
21 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/ui/util/DelegatingMouseListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.ui.util;
9 |
10 | import lombok.RequiredArgsConstructor;
11 |
12 | import java.awt.event.MouseEvent;
13 | import java.awt.event.MouseListener;
14 |
15 | /**
16 | * A delegating {@link MouseListener} implementation that delegates all of the calls to another specific {@link
17 | * MouseListener} object.
18 | *
19 | * @author Walied K. Yassen
20 | */
21 | @RequiredArgsConstructor
22 | public abstract class DelegatingMouseListener implements MouseListener {
23 |
24 | /**
25 | * The delegate listener which we want to call.
26 | */
27 | private final MouseListener delegate;
28 |
29 | /**
30 | * {@inheritDoc}
31 | */
32 | @Override
33 | public void mouseClicked(MouseEvent e) {
34 | delegate.mouseClicked(e);
35 | }
36 |
37 | /**
38 | * {@inheritDoc}
39 | */
40 | @Override
41 | public void mousePressed(MouseEvent e) {
42 | delegate.mousePressed(e);
43 | }
44 |
45 | /**
46 | * {@inheritDoc}
47 | */
48 | @Override
49 | public void mouseReleased(MouseEvent e) {
50 | delegate.mouseReleased(e);
51 | }
52 |
53 | /**
54 | * {@inheritDoc}
55 | */
56 | @Override
57 | public void mouseEntered(MouseEvent e) {
58 | delegate.mouseEntered(e);
59 | }
60 |
61 | /**
62 | * {@inheritDoc}
63 | */
64 | @Override
65 | public void mouseExited(MouseEvent e) {
66 | delegate.mouseExited(e);
67 | }
68 | }
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/util/ex/SwingUtilitiesEx.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.util.ex;
9 |
10 |
11 | import javax.swing.*;
12 | import java.awt.*;
13 |
14 | /**
15 | * An extension class for {@link SwingUtilities} utility class.
16 | *
17 | * @author Walied K. Yassen
18 | */
19 | public final class SwingUtilitiesEx {
20 |
21 | /**
22 | * Returns the hit test spot boundary of the specified {@link Component component}.
23 | *
24 | * @param component the component which we want the the hit test spot boundary for.
25 | * @return the hit test spot boundary of the specified component as a {@link Rectangle} object.
26 | */
27 | public static Rectangle getComponentHitTestBounds(Component component) {
28 | var location = component.getLocationOnScreen();
29 | return new Rectangle(Math.max(location.x - 2, 0), location.y, component.getWidth(), component.getHeight());
30 | }
31 |
32 | private SwingUtilitiesEx() {
33 | // NOOP
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/java/me/waliedyassen/runescript/editor/vfs/VFSFileListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.editor.vfs;
9 |
10 | import java.nio.file.Path;
11 |
12 | /**
13 | * Represents a listener that can be found to a {@link VFSFile} and listen to it's events.
14 | *
15 | * @author Walied K. Yassen
16 | */
17 | public interface VFSFileListener {
18 |
19 | /**
20 | * Gets called when an entity was just created.
21 | *
22 | * @param path the path of the entity that was created.
23 | */
24 | void onEntityCreate(Path path);
25 |
26 | /**
27 | * Gets called when an entity was just deleted.
28 | *
29 | * @param path the path of the entity that was deleted.
30 | */
31 | void onEntityDelete(Path path);
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/com/formdev/flatlaf/FlatDarculaLaf.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | #
4 | # This Source Code Form is subject to the terms of the Mozilla Public
5 | # License, v. 2.0. If a copy of the MPL was not distributed with this
6 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | #
8 |
9 | #---- Button ----
10 |
11 | Button.default.boldText=true
12 | @menuBackground=@background
13 | MenuBar.background=@menuBackground
14 |
15 | #---- Component ----
16 |
17 | Component.focusWidth=0
18 | Component.innerFocusWidth=0
19 | Component.innerOutlineWidth=0
20 | Component.arrowType=triangle
21 |
22 |
23 | #---- ProgressBar ----
24 |
25 | ProgressBar.foreground=#a0a0a0
26 | ProgressBar.selectionForeground=@background
27 |
28 |
29 | #---- RadioButton ----
30 |
31 | RadioButton.icon.centerDiameter=5
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/icons/favicon.png
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/idea/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The icons in this folder are from IntelliJ IDEA Community Edition,
2 | which is licensed under the Apache 2.0 license. Copyright 2000-2020 JetBrains s.r.o.
3 | See: https://github.com/JetBrains/intellij-community/
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/idea/close.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/idea/close_dark.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/idea/close_hovered.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/idea/settings.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/idea/settings_dark.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/tree/config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/icons/tree/config.png
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/tree/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/icons/tree/file.png
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/tree/folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/icons/tree/folder.png
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/icons/tree/script.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/icons/tree/script.png
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/project/osrs_default_triggers.toml:
--------------------------------------------------------------------------------
1 | [clientscript]
2 | support_returns=false
3 | support_arguments=true
4 | hook=true
5 |
6 | [proc]
7 | operator="tilde"
8 | opcode="gosub_with_params"
9 | support_returns=true
10 | support_arguments=true
11 |
12 | [label]
13 | operator="at"
14 | opcode="jump_with_params"
15 | support_returns=false
16 | support_arguments=true
17 |
18 | [if_button1]
19 | support_returns=false
20 | support_argument=false
21 |
22 | [if_button2]
23 | support_returns=false
24 | support_argument=false
25 |
26 | [if_button3]
27 | support_returns=false
28 | support_argument=false
29 |
30 | [if_button4]
31 | support_returns=false
32 | support_argument=false
33 |
34 | [if_button5]
35 | support_returns=false
36 | support_argument=false
37 |
38 | [if_button6]
39 | support_returns=false
40 | support_argument=false
41 |
42 | [if_button7]
43 | support_returns=false
44 | support_argument=false
45 |
46 | [if_button8]
47 | support_returns=false
48 | support_argument=false
49 |
50 | [if_button9]
51 | support_returns=false
52 | support_argument=false
53 |
54 | [if_button10]
55 | support_returns=false
56 | support_argument=false
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Bold-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Bold-Italic.ttf
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Bold.ttf
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-ExtraBold-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-ExtraBold-Italic.ttf
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-ExtraBold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-ExtraBold.ttf
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Italic.ttf
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Medium-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Medium-Italic.ttf
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Medium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Medium.ttf
--------------------------------------------------------------------------------
/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/waleedyaseen/RuneScript/ed82ac7831d559e3d1c93c204f03f5c0a8ebf7b7/runescript-editor/src/main/resources/me/waliedyassen/runescript/editor/util/JetBrainsMono-Regular.ttf
--------------------------------------------------------------------------------
/runescript-runtime/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 | runescript-parent
12 | me.waliedyassen.runescript
13 | 0.6-SNAPSHOT
14 |
15 | 4.0.0
16 | runescript-runtime
17 | 0.6-SNAPSHOT
18 |
--------------------------------------------------------------------------------
/runescript-runtime/src/main/java/me/waliedyassen/runescript/runtime/ScriptRuntimeSetup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.runtime;
9 |
10 | /**
11 | * An interface which is responsible for setting up the runtime context.
12 | *
13 | * @param the type of the runtime.
14 | * @author Walied K. Yassen
15 | */
16 | @FunctionalInterface
17 | public interface ScriptRuntimeSetup {
18 |
19 | /**
20 | * Sets-up the context of the specified {@link R runtime}.
21 | *
22 | * @param runtime the runetime to setup the context.
23 | */
24 | void setup(R runtime);
25 | }
26 |
--------------------------------------------------------------------------------
/runescript-runtime/src/main/java/me/waliedyassen/runescript/runtime/cache/ScriptCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.runtime.cache;
9 |
10 | import lombok.RequiredArgsConstructor;
11 | import me.waliedyassen.runescript.runtime.script.Script;
12 |
13 | /**
14 | * Represents a script cache that can be used for loading and storing the loaded scripts in memory for faster access.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | @RequiredArgsConstructor
19 | public abstract class ScriptCache {
20 |
21 | /**
22 | * Returns the {@link Script} object with the specified {@code name}.
23 | *
24 | * @param id the id of the script to get.
25 | * @return the {@link Script} object if found otherwise {@code null}.
26 | */
27 | public abstract Script get(int id);
28 |
29 | /**
30 | * Returns the {@link Script} object with the specified {@code name}.
31 | *
32 | * @param name the name of the script to get.
33 | * @return the {@link Script} object if found otherwise {@code null}.
34 | */
35 | public abstract Script get(String name);
36 | }
37 |
--------------------------------------------------------------------------------
/runescript-runtime/src/main/java/me/waliedyassen/runescript/runtime/executor/ExecutionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.runtime.executor;
9 |
10 | /**
11 | * A {@link RuntimeException} implementation that is raised when a problem occurs during the execution of a script of an
12 | * instruction.
13 | *
14 | * @author Walied K. Yassen
15 | */
16 | public final class ExecutionException extends RuntimeException {
17 |
18 | /**
19 | * Constructs a {@link ExecutionException} type object instance.
20 | *
21 | * @param message
22 | * the error message of the exception
23 | */
24 | public ExecutionException(String message) {
25 | super(message);
26 | }
27 |
28 | /**
29 | * Constructs a {@link ExecutionException} type object instance.
30 | *
31 | * @param message
32 | * the error message of the exception
33 | * @param cause
34 | * the parent cause of the exception.
35 | */
36 | public ExecutionException(String message, Throwable cause) {
37 | super(message, cause);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/runescript-runtime/src/main/java/me/waliedyassen/runescript/runtime/executor/ScriptFramePool.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.runtime.executor;
9 |
10 | import me.waliedyassen.runescript.runtime.ScriptFrame;
11 |
12 | import java.util.Stack;
13 |
14 | /**
15 | * Represents a pool for {@link ScriptFrame} objects.
16 | *
17 | * @author Walied K. Yassen
18 | */
19 | public final class ScriptFramePool {
20 |
21 | /**
22 | * The maximum amount of objects that can be pushed onto the pool stack.
23 | */
24 | private static final int POOL_SIZE = 512;
25 |
26 | /**
27 | * The stack which contains the pool objects.
28 | */
29 | private static final Stack frames = new Stack<>();
30 |
31 | /**
32 | * Pushes the specified {@link ScriptFrame} object back into the pool.
33 | *
34 | * @param frame the frame object to push back into the pool.
35 | */
36 | public static void push(ScriptFrame frame) {
37 | if (frames.size() >= POOL_SIZE) {
38 | return;
39 | }
40 | frames.push(frame);
41 | }
42 |
43 | /**
44 | * Pops a {@link ScriptFrame} object from the pool or create new one if the pool had no objects available.
45 | *
46 | * @return the {@link ScriptFrame} object.
47 | */
48 | public static ScriptFrame pop() {
49 | if (frames.isEmpty()) {
50 | return new ScriptFrame();
51 | }
52 | return frames.pop();
53 | }
54 |
55 | private ScriptFramePool() {
56 | // NOOP
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/runescript-runtime/src/main/java/me/waliedyassen/runescript/runtime/executor/impl/ConsoleOps.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.runtime.executor.impl;
9 |
10 | import me.waliedyassen.runescript.runtime.ScriptRuntime;
11 | import me.waliedyassen.runescript.runtime.executor.instruction.InstructionExecutor;
12 |
13 |
14 | /**
15 | * Contains all of the common console operations.
16 | *
17 | * @author Walied K. Yassen
18 | */
19 | public interface ConsoleOps {
20 |
21 | /**
22 | * An instruction which writes to the console of the host VM.
23 | */
24 | InstructionExecutor extends ScriptRuntime> WRITECONSOLE = runtime -> System.out.println(runtime.popString());
25 | }
26 |
--------------------------------------------------------------------------------
/runescript-runtime/src/main/java/me/waliedyassen/runescript/runtime/executor/impl/StringOps.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.runtime.executor.impl;
9 |
10 | import me.waliedyassen.runescript.runtime.ScriptRuntime;
11 | import me.waliedyassen.runescript.runtime.executor.instruction.InstructionExecutor;
12 |
13 | /**
14 | * Contains all of the common string operations.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | public interface StringOps {
19 |
20 | /**
21 | * Takes an X integer and turn it into a string form.
22 | */
23 | InstructionExecutor extends ScriptRuntime> TOSTRING = runtime -> runtime.pushString(Integer.toString(runtime.popInt()));
24 | }
25 |
--------------------------------------------------------------------------------
/runescript-runtime/src/main/java/me/waliedyassen/runescript/runtime/executor/instruction/InstructionExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Walied K. Yassen, All rights reserved.
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 | package me.waliedyassen.runescript.runtime.executor.instruction;
9 |
10 | import me.waliedyassen.runescript.runtime.ScriptRuntime;
11 | import me.waliedyassen.runescript.runtime.executor.ExecutionException;
12 |
13 | /**
14 | * An instruction executor, it is responsible for executing a specific instruction(s) in a runtime.
15 | *
16 | * @author Walied K. Yassen
17 | */
18 | @FunctionalInterface
19 | public interface InstructionExecutor {
20 |
21 | /**
22 | * Executes the instruction in the specified runtime.
23 | *
24 | * @param runtime the runtime we are executing the instruction in.
25 | * @throws ExecutionException if anything occurs during the execution of the instruction.
26 | */
27 | void execute(R runtime) throws ExecutionException;
28 | }
29 |
--------------------------------------------------------------------------------
/version-rules.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 | (?i).*M(?:-?\d+)?
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------