mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-14 04:59:57 +00:00
Fixed broken .d.ts fields parsing logic
This commit is contained in:
1 parent
f1d902849e
commit
5b8827549f
2 files changed
+13
-8
No files matched your search
@@ -202,9 +202,11 @@ public final class FieldInfo {
|
||||
*/
|
||||
public static FieldInfo fromJSField(JSFieldInfo jsField, TypeInfo containingType) {
|
||||
String name = jsField.getName();
|
||||
|
||||
// Resolve the type from the JS type registry
|
||||
TypeInfo type = resolveJSType(jsField.getType());
|
||||
|
||||
TypeInfo type = jsField.getResolvedType(containingType);
|
||||
if (type == null || !type.isResolved()) {
|
||||
type = resolveJSType(jsField.getType());
|
||||
}
|
||||
|
||||
// JS fields are public by default, readonly maps to final
|
||||
int modifiers = Modifier.PUBLIC;
|
||||
|
||||
+8
-5
@@ -587,13 +587,16 @@ public class TypeScriptDefinitionParser {
|
||||
// Parse fields (that aren't method signatures)
|
||||
Matcher fieldMatcher = FIELD_PATTERN.matcher(body);
|
||||
while (fieldMatcher.find()) {
|
||||
String fieldText = fieldMatcher.group(0);
|
||||
// Skip if this looks like a method (has parentheses in the match)
|
||||
if (fieldText.contains("(")) continue;
|
||||
|
||||
boolean readonly = fieldMatcher.group(1) != null;
|
||||
String fieldName = fieldMatcher.group(2);
|
||||
|
||||
// CNPC+ base event implementation CustomNPCsEvent exposes a public "API" field that
|
||||
// ends up polluting autocomplete on every event via ICustomNPCsEvent inheritance.
|
||||
// Keep parsing other fields, but skip this one.
|
||||
if ("ICustomNPCsEvent".equals(typeInfo.getSimpleName()) && "API".equals(fieldName))
|
||||
continue;
|
||||
|
||||
String fieldType = cleanType(fieldMatcher.group(3));
|
||||
boolean readonly = fieldMatcher.group(1) != null;
|
||||
|
||||
JSFieldInfo field = new JSFieldInfo(fieldName, fieldType, readonly);
|
||||
|
||||
|
||||
Reference in new issue
Block a user