Skip to content

Commit d88a84a

Browse files
committed
Finish function post-checking
1 parent 1119522 commit d88a84a

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>ch.njol</groupId>
44
<artifactId>skript</artifactId>
5-
<version>2.2-Fixes-V10</version>
5+
<version>2.2-dev13</version>
66
<name>Skript</name>
77
<description>A plugin for the Minecraft server API Bukkit that allows to create scripts in natural language.</description>
88
<url>http://njol.ch/projects/skript/</url>

src/main/java/ch/njol/skript/SkriptConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public EventPriority convert(final String s) {
151151
public final static Option<Integer> maxTargetBlockDistance = new Option<Integer>("maximum target block distance", 100);
152152

153153
public final static Option<Boolean> caseSensitive = new Option<Boolean>("case sensitive", false);
154-
public final static Option<Boolean> allowFunctionsBeforeDefs = new Option<Boolean>("allow function calls before definations", true);
154+
public final static Option<Boolean> allowFunctionsBeforeDefs = new Option<Boolean>("allow function calls before definations", false);
155155

156156
public final static Option<Boolean> disableVariableConflictWarnings = new Option<Boolean>("disable variable conflict warnings", false);
157157
public final static Option<Boolean> disableObjectCannotBeSavedWarnings = new Option<Boolean>("disable variable will not be saved warnings", false);

src/main/java/ch/njol/skript/lang/SkriptParser.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -728,14 +728,10 @@ public final <T> FunctionReference<T> parseFunction(final @Nullable Class<? exte
728728
}
729729

730730
final Function<?> function = Functions.getFunction(functionName);
731-
if (function == null) {
732-
if (SkriptConfig.allowFunctionsBeforeDefs.value()) {
733-
Functions.addPostCheck(new FunctionReference<T>(functionName, SkriptLogger.getNode(), ScriptLoader.currentScript != null ? ScriptLoader.currentScript.getFile() : null, types, params));
734-
} else {
735-
Skript.error("The function '" + functionName + "' does not exist");
736-
log.printError();
737-
return null;
738-
}
731+
if (function == null && !SkriptConfig.allowFunctionsBeforeDefs.value()) {
732+
Skript.error("The function '" + functionName + "' does not exist");
733+
log.printError();
734+
return null;
739735
}
740736

741737
// final List<Expression<?>> params = new ArrayList<Expression<?>>();
@@ -756,7 +752,7 @@ public final <T> FunctionReference<T> parseFunction(final @Nullable Class<? exte
756752
// }
757753
// @SuppressWarnings("null")
758754
final FunctionReference<T> e = new FunctionReference<T>(functionName, SkriptLogger.getNode(), ScriptLoader.currentScript != null ? ScriptLoader.currentScript.getFile() : null, types, params);//.toArray(new Expression[params.size()]));
759-
if (!e.validateFunction(true)) {
755+
if (!SkriptConfig.allowFunctionsBeforeDefs.value() && !e.validateFunction(true)) {
760756
log.printError();
761757
return null;
762758
}

src/main/java/ch/njol/skript/lang/function/Functions.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,18 @@ public final static void addPostCheck(FunctionReference<?> ref) {
241241
}
242242

243243
public final static void postCheck() {
244-
for (FunctionReference<?> ref : postCheckNeeded) {
244+
if (postCheckNeeded.isEmpty()) return;
245+
246+
final ParseLogHandler log = SkriptLogger.startParseLogHandler();
247+
for (final FunctionReference<?> ref : postCheckNeeded) {
245248
if (!ref.validateFunction(true)) {
246-
// TODO Do something
249+
log.printError();
247250
}
248251
}
252+
log.printLog();
249253

250254
postCheckNeeded.clear();
255+
log.stop();
251256
}
252257

253258
}

src/main/resources/config.sk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ case sensitive: false
145145
# This e.g. applies to the effect 'replace' and the conditions 'contains' and 'is/is not'.
146146
# Variable names are case-insensitive irrespective of this setting.
147147

148-
allow function calls before definations: true
148+
allow function calls before definations: false
149149
# Whether scripts should be allowed to call functions that are not yet defined.
150-
# If enabled, functions' existence are checked after loading ALL scripts.
150+
# If enabled, functions' existences are checked after loading ALL scripts.
151+
# Warning: Unless you have text editor with good directory-search, it can be hard to find your functions!
151152

152153
disable variable conflict warnings: false
153154
# Disables warnings of potential variable name conflicts if set to true.

0 commit comments

Comments
 (0)