Skip to content

Commit 8f7652b

Browse files
committed
fixes
1 parent b229a6d commit 8f7652b

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/RunMap.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ public class RunMap extends MapRequest {
4949
public RunMap(ConfigProvider configProvider, WFile workspaceRoot, Optional<String> wc3Path, Optional<File> map,
5050
List<String> compileArgs) {
5151
super(configProvider, map, compileArgs, workspaceRoot, wc3Path);
52-
if (!configProvider.getConfig("safeRunmapTypecheck", "false").equals("true")) {
53-
safeCompilation = SafetyLevel.QuickAndDirty;
54-
}
52+
safeCompilation = SafetyLevel.QuickAndDirty;
5553
}
5654

5755
@Override

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/attributes/names/NameLinks.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static ImmutableMultimap<String, DefLink> calculate(ClassOrModuleOrModule
4444

4545
if (c instanceof ClassDef) {
4646
WurstTypeClass classType = ((ClassDef) c).attrTypC();
47-
addNamesFormSuperClass(result, classType, overrideCheckResults);
47+
addNamesFromSuperClass(result, classType, overrideCheckResults);
4848
addNamesFromImplementedInterfaces(result, classType, overrideCheckResults);
4949
}
5050

@@ -112,7 +112,7 @@ private static void addNamesFromImplementedInterfaces(Multimap<String, DefLink>
112112
}
113113
}
114114

115-
private static void addNamesFormSuperClass(Multimap<String, DefLink> result, WurstTypeClass c, Map<String, Map<FuncLink, OverrideCheckResult>> overrideCheckResults) {
115+
private static void addNamesFromSuperClass(Multimap<String, DefLink> result, WurstTypeClass c, Map<String, Map<FuncLink, OverrideCheckResult>> overrideCheckResults) {
116116
@Nullable WurstTypeClass superClass = c.extendedClass();
117117
if (superClass != null) {
118118
addNewNameLinks(result, overrideCheckResults, superClass.nameLinks(), false);

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/validation/WurstValidator.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,38 +2179,39 @@ private void checkForDuplicateNames(WScope scope) {
21792179
if (nameLinks.size() <= 1) {
21802180
continue;
21812181
}
2182-
List<FuncLink> funcs = Lists.newArrayList();
2183-
List<NameLink> other = Lists.newArrayList();
2182+
@Nullable List<FuncLink> funcs = null;
2183+
@Nullable List<NameLink> other = null;
21842184
for (NameLink nl : nameLinks) {
21852185
if (nl.getDefinedIn() == scope) {
21862186
if (nl instanceof FuncLink) {
2187-
funcs.add(((FuncLink) nl));
2187+
if (funcs == null) {
2188+
funcs = Lists.newArrayList();
2189+
}
2190+
FuncLink funcLink = (FuncLink) nl;
2191+
for (FuncLink link : funcs) {
2192+
if (!distinctFunctions(funcLink, link)) {
2193+
funcLink.getDef().addError(
2194+
"Function already defined : " + Utils.printElementWithSource(Optional.of(link.getDef())));
2195+
link.getDef().addError(
2196+
"Function already defined : " + Utils.printElementWithSource(Optional.of(funcLink.getDef())));
2197+
}
2198+
}
2199+
2200+
funcs.add(funcLink);
21882201
} else {
2202+
if (other == null) {
2203+
other = Lists.newArrayList();
2204+
}
21892205
other.add(nl);
21902206
}
21912207
}
21922208
}
2193-
if (other.size() > 1) {
2209+
if (other != null && other.size() > 1) {
21942210
other.sort(Comparator.comparingInt(o -> o.getDef().attrSource().getLeftPos()));
21952211
NameLink l1 = other.get(0);
21962212
for (int j = 1; j < other.size(); j++) {
21972213
other.get(j).getDef().addError("An element with name " + name + " already exists: "
2198-
+ Utils.printElementWithSource(Optional.of(l1.getDef())));
2199-
}
2200-
}
2201-
if (funcs.size() <= 1) {
2202-
continue;
2203-
}
2204-
for (int i = 0; i < funcs.size() - 1; i++) {
2205-
FuncLink f1 = funcs.get(i);
2206-
for (int j = i + 1; j < funcs.size(); j++) {
2207-
FuncLink f2 = funcs.get(j);
2208-
if (!distinctFunctions(f1, f2)) {
2209-
f1.getDef().addError(
2210-
"Function already defined : " + Utils.printElementWithSource(Optional.of(f2.getDef())));
2211-
f2.getDef().addError(
2212-
"Function already defined : " + Utils.printElementWithSource(Optional.of(f1.getDef())));
2213-
}
2214+
+ Utils.printElementWithSource(Optional.of(l1.getDef())));
22142215
}
22152216
}
22162217
}

0 commit comments

Comments
 (0)