• 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

89.29
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/attributes/AttrTypeDef.java
1
package de.peeeq.wurstscript.attributes;
2

3
import de.peeeq.wurstscript.ast.*;
4
import de.peeeq.wurstscript.types.NativeTypes;
5
import de.peeeq.wurstscript.types.WurstType;
6
import de.peeeq.wurstscript.types.WurstTypeClass;
7
import de.peeeq.wurstscript.utils.Utils;
8
import org.eclipse.jdt.annotation.Nullable;
9

10

11
/**
12
 * this attribute finds the type definition for every tpye-reference
13
 */
14
public class AttrTypeDef {
×
15

16
    public static @Nullable TypeDef calculate(TypeExprResolved e) {
17
        return null;
1✔
18
    }
19

20

21
    public static @Nullable TypeDef calculate(TypeRef node) {
22
        WurstType scope = getTypeScope(node);
1✔
23
        String typeName = getTypeName(node);
1✔
24

25
        if (typeName == null) {
1✔
26
            // thistype has no typedef
27
            return null;
1✔
28
        }
29

30
        if (scope instanceof WurstTypeClass) {
1✔
31
            WurstTypeClass ct = (WurstTypeClass) scope;
1✔
32
            TypeDef r = ct.lookupInnerType(typeName);
1✔
33
            if (r == null) {
1✔
34
                node.addError("Could not find type " + typeName + " in class " + ct + ".");
×
35
            }
36
            return r;
1✔
37
        }
38

39
        WurstType nativeType = NativeTypes.nativeType(typeName, Utils.isJassCode(node));
1✔
40
        if (nativeType != null) {
1✔
41
            return null; // native types have no definitionPos
1✔
42
        }
43
        return node.lookupType(typeName);
1✔
44
    }
45

46
    private static WurstType getTypeScope(TypeRef node) {
47
        if (node instanceof TypeExprSimple) {
1✔
48
            TypeExprSimple t = (TypeExprSimple) node;
1✔
49
            OptTypeExpr scopeType = t.getScopeType();
1✔
50
            if (scopeType instanceof TypeExpr) {
1✔
51
                return scopeType.attrTyp();
1✔
52
            }
53
        }
54
        return null;
1✔
55

56
    }
57

58
    private static @Nullable String getTypeName(TypeRef node) {
59
        return node.match(new TypeRef.Matcher<String>() {
1✔
60

61
            @Override
62
            public String case_TypeExprSimple(TypeExprSimple typeExprSimple) {
63
                return typeExprSimple.getTypeName();
1✔
64
            }
65

66
            @Override
67
            public String case_ExprNewObject(ExprNewObject exprNewObject) {
68
                return exprNewObject.getTypeName();
1✔
69
            }
70

71
            @Override
72
            public @Nullable String case_TypeExprThis(TypeExprThis typeExprThis) {
73
                return null;
1✔
74
            }
75

76
            @Override
77
            public @Nullable String case_TypeExprArray(TypeExprArray typeExprArray) {
78
                return null;
1✔
79
            }
80

81
            @Override
82
            public String case_TypeExprResolved(TypeExprResolved t) {
83
                return t.attrTyp().getName();
×
84
            }
85

86
        });
87
    }
88

89

90
}
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