Skip to content

Commit

Permalink
Improve support for UE1, highlight class modifier localized, `expan…
Browse files Browse the repository at this point in the history
…ds` in struct and state, and recognize the `always` keyword in a replication block.
  • Loading branch information
EliotVU committed May 28, 2024
1 parent dce7b15 commit 49f67d4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions grammars/UCLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ KW_IF: 'if';
KW_IGNORES: 'ignores';
KW_UNRELIABLE: 'unreliable';
KW_RELIABLE: 'reliable';
KW_ALWAYS: 'always';
KW_CPPTEXT: 'cpptext';
KW_STRUCTCPPTEXT: 'structcpptext';
KW_CPPSTRUCT: 'cppstruct';
Expand Down
9 changes: 7 additions & 2 deletions grammars/UCParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ identifier
| 'ignores'
| 'unreliable'
| 'reliable'
| 'always'
| 'cpptext'
| 'cppstruct'
| 'structcpptext'
Expand Down Expand Up @@ -471,6 +472,7 @@ enumMember
;

structDecl
// UE1 doesn't support qualified 'expands'
: 'struct' ({ this.generation === 3 }? exportBlockText)? structModifier* identifier qualifiedExtendsClause?
OPEN_BRACE
structMember*
Expand Down Expand Up @@ -673,8 +675,11 @@ replicationModifier
;

replicationStatement
: replicationModifier? 'if' (OPEN_PARENS expr=expression CLOSE_PARENS)
identifier (COMMA identifier)* SEMICOLON
: replicationModifier?
// Unreal 1
({ this.generation === 1 }? 'always')?
'if' (OPEN_PARENS expr=expression CLOSE_PARENS)
identifier (COMMA identifier)* SEMICOLON
;

/* Parses:
Expand Down
5 changes: 3 additions & 2 deletions server/src/UC/Symbols/FieldSymbol.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Position } from 'vscode-languageserver-types';

import { UCDocument } from '../document';
import { indexDeclarationReference } from '../indexer';
import { config, indexDeclarationReference } from '../indexer';
import { isParamSymbol, ISymbol, ITypeSymbol, UCObjectSymbol, UCStructSymbol } from './';
import { UCGeneration } from '../settings';

export enum ModifierFlags {
None = 0x0000,
Expand Down Expand Up @@ -105,7 +106,7 @@ export abstract class UCFieldSymbol extends UCObjectSymbol {
text.push('protected');
} else if (modifiers & ModifierFlags.Private) {
text.push('private');
} else {
} else if (config.generation !== UCGeneration.UC1) {
text.push('public');
}

Expand Down
8 changes: 8 additions & 0 deletions server/src/UC/Symbols/StateSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export class UCStateSymbol extends UCStructSymbol {
return 'state';
}

public buildModifiers(modifiers = this.modifiers): string[] {
const text: string[] = [];

// none tracked yet

return text;
}

override getTooltip(): string {
const text: Array<string | undefined> = [];

Expand Down
10 changes: 6 additions & 4 deletions syntaxes/UnrealScript.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ repository:
'3':
name: entity.name.type.class.uc

- match: \b((?i)abstract|export|exportstructs|noexport|noexportheader|nativereplication|nativeonly|deprecated|transient|nontransient|nousercreate|notplaceable|placeable|safereplace|parseconfig|hidedropdown|editinlinenew|noteditinlinenew|cacheexempt|perobjectconfig|perobjectlocalized|forcescriptorder|instanced)\b
- match: \b((?i)abstract|export|exportstructs|noexport|noexportheader|nativereplication|nativeonly|deprecated|transient|nontransient|nousercreate|notplaceable|placeable|safereplace|parseconfig|hidedropdown|editinlinenew|noteditinlinenew|cacheexempt|perobjectconfig|perobjectlocalized|forcescriptorder|instanced|localized)\b
name: storage.modifier.uc

# modifiers with optional params
Expand Down Expand Up @@ -588,7 +588,7 @@ repository:
- name: storage.modifier.uc
match: \b((?i)native|intrinsic|transient|export|strictconfig|atomic|atomicwhencooked|immutable|immutablewhencooked|init|long)\b

- match: (\w+)\s*(?:((?i)extends)\b\s*(\w+))?
- match: (\w+)\s*(?:((?i)extends|expands)\b\s*(\w+))?
captures:
'0':
name: entity.name.type.struct.uc
Expand Down Expand Up @@ -874,7 +874,7 @@ repository:

state-declaration:
name: meta.state.declaration.uc
begin: \b((?i)state)\b(\s*\(\s*\))?\s*(\w+)(?:\s*((?i)extends)\s*(\w+))?
begin: \b((?i)state)\b(\s*\(\s*\))?\s*(\w+)(?:\s*((?i)extends|expands)\s*(\w+))?
beginCaptures:
'1':
name: storage.type.state.uc
Expand Down Expand Up @@ -963,11 +963,13 @@ repository:
name: punctuation.curlybrace.open.uc
patterns:
- include: '#comment'
- begin: \b((?i)unreliable|reliable)?\s*((?i)if)?
- begin: \b((?i)unreliable|reliable)?\s*((?i)always\s*)?((?i)if)?
beginCaptures:
'1':
name: keyword.other.modifier.uc
'2':
name: keyword.other.modifier.uc
'3':
name: keyword.control.conditional.uc
patterns:
- include: '#comment'
Expand Down

0 comments on commit 49f67d4

Please sign in to comment.