• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wurstscript / WurstScript / 228

29 Nov 2023 05:00PM UTC coverage: 62.48% (-0.09%) from 62.574%
228

push

circleci

web-flow
Show dialog for choosing game path, cleanup (#1083)

* show dialog for choosing game path

* cleanup code

* remove logs and refactor

* remove confusing mpq error, make some mpq loads readonly

17295 of 27681 relevant lines covered (62.48%)

0.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/attributes/InterfaceInstances.java
1
package de.peeeq.wurstscript.attributes;
2

3
import com.google.common.collect.ImmutableCollection;
4
import com.google.common.collect.ImmutableCollection.Builder;
5
import com.google.common.collect.ImmutableList;
6
import de.peeeq.wurstscript.ast.ClassDef;
7
import de.peeeq.wurstscript.ast.InterfaceDef;
8
import de.peeeq.wurstscript.ast.TypeExpr;
9
import de.peeeq.wurstscript.types.VariableBinding;
10
import de.peeeq.wurstscript.types.WurstTypeClass;
11
import de.peeeq.wurstscript.types.WurstTypeInterface;
12
import de.peeeq.wurstscript.utils.Utils;
13
import org.eclipse.jdt.annotation.Nullable;
14

15
public class InterfaceInstances {
×
16

17

18
    public static ImmutableCollection<WurstTypeInterface> getImplementedInterfaces(ClassDef c) {
19
        ImmutableCollection.Builder<WurstTypeInterface> result = ImmutableList.builder();
×
20
        for (TypeExpr t : c.getImplementsList()) {
×
21
            addInterface(result, t, null);
×
22
        }
×
23

24
        if (c.getExtendedClass() instanceof TypeExpr) {
×
25
            addInterfacesFromExtends(result, ((TypeExpr) c.getExtendedClass()));
×
26
        }
27

28
        return result.build();
×
29
    }
30

31
    public static ImmutableCollection<WurstTypeInterface> getExtendedInterfaces(InterfaceDef in) {
32
        ImmutableCollection.Builder<WurstTypeInterface> result = ImmutableList.builder();
×
33
        for (TypeExpr t : in.getExtendsList()) {
×
34
            addInterface(result, t, in);
×
35
        }
×
36
        return result.build();
×
37
    }
38

39
    private static void addInterface(Builder<WurstTypeInterface> result, TypeExpr t, @Nullable InterfaceDef in) {
40
        if (t.attrTyp() instanceof WurstTypeInterface) {
×
41
            WurstTypeInterface i = (WurstTypeInterface) t.attrTyp();
×
42
            if (i.getDef() == in) {
×
43
                t.addError("Interfaces must not extend themselves.");
×
44
                return;
×
45
            }
46
            result.add(i);
×
47
            VariableBinding typeParamBounds = i.getTypeArgBinding();
×
48
            for (WurstTypeInterface i2 : i.extendedInterfaces()) {
×
49
                result.add((WurstTypeInterface) i2.setTypeArgs(typeParamBounds));
×
50
            }
×
51

52
        } else {
×
53
            t.addError(Utils.printElement(t) + " is not an interface.");
×
54
        }
55
    }
×
56

57
    private static void addInterfacesFromExtends(Builder<WurstTypeInterface> result, TypeExpr t) {
58
        if (t.attrTyp() instanceof WurstTypeClass) {
×
59
            WurstTypeClass wtc = (WurstTypeClass) t.attrTyp();
×
60
            VariableBinding typeParamBounds = wtc.getTypeArgBinding();
×
61
            for (WurstTypeInterface i2 : wtc.implementedInterfaces()) {
×
62
                result.add((WurstTypeInterface) i2.setTypeArgs(typeParamBounds));
×
63
            }
×
64
        }
65
    }
×
66

67

68

69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc