Skip to content

Commit

Permalink
Move ModifierFlags to its own file; this is necessary to avoid recu…
Browse files Browse the repository at this point in the history
…rsive dependency import issues, when using the enum as a value.
  • Loading branch information
EliotVU committed Jun 22, 2024
1 parent b22a4cd commit 9506bbf
Show file tree
Hide file tree
Showing 30 changed files with 137 additions and 131 deletions.
3 changes: 2 additions & 1 deletion server/src/UC/SymbolTagsBuilderVisitor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SymbolTag } from 'vscode-languageserver';

import { ModifierFlags, UCClassSymbol, UCFieldSymbol, UCMethodSymbol, UCPropertySymbol } from './Symbols';
import { UCClassSymbol, UCFieldSymbol, UCMethodSymbol, UCPropertySymbol } from './Symbols';
import { ModifierFlags } from './Symbols/ModifierFlags';
import { DumbSymbolWalker } from './symbolWalker';

// Transform field modifiers to their corresponding SymbolTag counter-part.
Expand Down
4 changes: 2 additions & 2 deletions server/src/UC/Symbols/ArchetypeSymbol.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { UCDocument } from 'UC/document';
import { UCDocument } from '../document';
import { Name } from '../name';
import { SymbolWalker } from '../symbolWalker';
import {
ModifierFlags,
UCClassSymbol,
UCFieldSymbol,
UCObjectSymbol,
UCStructSymbol,
UCSymbolKind,
UCTypeKind,
} from './';
import { ModifierFlags } from './ModifierFlags';

/**
* Represents an instanced Archetype found within a defaultproperties block e.g. "begin object class=classID name=objectName".
Expand Down
2 changes: 1 addition & 1 deletion server/src/UC/Symbols/ArrayOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { toName } from '../name';
import { NAME_ARRAY } from '../names';
import {
DEFAULT_RANGE,
ModifierFlags,
StaticIntType,
StaticMetaType,
UCMethodLikeSymbol,
UCParamSymbol,
UCStructSymbol,
} from './';
import { ModifierFlags } from './ModifierFlags';

/** (defaultproperties) Acts as a template for array operations such as MyArray.Replace(item1, item2) etc. */
export const DefaultArray = new UCStructSymbol({ name: NAME_ARRAY, range: DEFAULT_RANGE }, DEFAULT_RANGE);
Expand Down
2 changes: 1 addition & 1 deletion server/src/UC/Symbols/ClassSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { SymbolWalker } from '../symbolWalker';
import {
ISymbol,
ITypeSymbol,
ModifierFlags,
UCArchetypeSymbol,
UCFieldSymbol,
UCObjectTypeSymbol,
Expand All @@ -16,6 +15,7 @@ import {
UCSymbolKind,
UCTypeKind,
} from './';
import { ModifierFlags } from './ModifierFlags';

export enum ClassModifierFlags {
None,
Expand Down
3 changes: 2 additions & 1 deletion server/src/UC/Symbols/ConstSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Position } from 'vscode-languageserver-types';
import { UCDocument } from '../document';
import { IExpression } from '../expressions';
import { SymbolWalker } from '../symbolWalker';
import { ModifierFlags, UCFieldSymbol, UCStructSymbol, UCSymbolKind, UCTypeKind } from './';
import { UCFieldSymbol, UCStructSymbol, UCSymbolKind, UCTypeKind } from './';
import { ModifierFlags } from './ModifierFlags';

export class UCConstSymbol extends UCFieldSymbol {
override kind = UCSymbolKind.Const;
Expand Down
2 changes: 1 addition & 1 deletion server/src/UC/Symbols/CoreSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
} from '../names';
import {
DEFAULT_RANGE,
ModifierFlags,
StaticIntType,
StaticNameType,
StaticObjectType,
Expand All @@ -49,6 +48,7 @@ import {
addHashedSymbol,
getSymbolOuterHash,
} from './';
import { ModifierFlags } from './ModifierFlags';

export const CORE_PACKAGE = new UCPackage(NAME_CORE);

Expand Down
3 changes: 2 additions & 1 deletion server/src/UC/Symbols/DefaultPropertiesBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { SymbolWalker } from '../symbolWalker';
import {
ContextKind,
getContext,
isArchetypeSymbol, ISymbol, ModifierFlags, UCClassSymbol, UCStructSymbol, UCSymbolKind
isArchetypeSymbol, ISymbol, UCClassSymbol, UCStructSymbol, UCSymbolKind
} from './';
import { ModifierFlags } from './ModifierFlags';

export class UCDefaultPropertiesBlock extends UCStructSymbol {
override kind = UCSymbolKind.DefaultPropertiesBlock;
Expand Down
5 changes: 3 additions & 2 deletions server/src/UC/Symbols/EnumMemberSymbol.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SymbolWalker } from '../symbolWalker';
import { ModifierFlags, UCFieldSymbol, UCSymbolKind, UCTypeKind } from './';
import { UCFieldSymbol, UCSymbolKind, UCTypeKind } from './';
import { ModifierFlags } from './ModifierFlags';

export class UCEnumMemberSymbol extends UCFieldSymbol {
override kind = UCSymbolKind.EnumTag;
Expand Down Expand Up @@ -34,4 +35,4 @@ export class UCEnumMemberSymbol extends UCFieldSymbol {
override accept<Result>(visitor: SymbolWalker<Result>): Result | void {
return visitor.visitEnumMember(this);
}
}
}
93 changes: 2 additions & 91 deletions server/src/UC/Symbols/FieldSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,97 +3,8 @@ import { Position } from 'vscode-languageserver-types';
import { UCDocument } from '../document';
import { config, indexDeclarationReference } from '../indexer';
import { UCGeneration } from '../settings';
import { ISymbol, ITypeSymbol, UCObjectSymbol, UCStructSymbol, isParamSymbol } from './';

export enum ModifierFlags {
None = 0x0000,

// FieldFlags

/** The field is marked as 'protected' */
Protected = 1 << 0,

/** The field is marked as 'private' */
Private = 1 << 1,

NotPublic = Protected | Private,

/** The field is marked as 'native' or 'intrinsic' */
Native = 1 << 2,

/** The field is marked as 'const' or treated as readonly (for intrinsics) */
ReadOnly = 1 << 3, // aka Const

/** The field has a specified element size. e.g. `var int MyVar[2];` */
WithDimension = 1 << 4, // A multiple dimension property

/** The field is marked as 'transient' */
Transient = 1 << 6,

// ParamFlags

/** The field is a parameter of a function. */
Param = 1 << 7,

/** The field is a return parameter (generated) of a function. */
ReturnParam = 1 << 8,

/** The field is marked as 'out' */
Out = 1 << 9,

/** The field is marked as 'optional' */
Optional = 1 << 10,

/** The field is marked as 'init' */
Init = 1 << 11, // NOT SUPPORTED

/** The field is marked as 'skip' */
Skip = 1 << 12, // NOT SUPPORTED

/** The field is marked as 'coerce' */
Coerce = 1 << 13,

// XCom

/** The field is marked as 'ref' */
Ref = 1 << 14, // NOT SUPPORTED

// LocalFlags

/** The field is a local field of a function or state. */
Local = 1 << 15,

// ClassFlags

/** The field is marked as 'abstract' */
Abstract = 1 << 16, // TODO: Unify with ClassModifiers?

// InternalFlags
/**
* Field is an intrisic symbol, not to be confused with the older 'intrinsic' native keyword.
* That means the symbol was not contructed from an UnrealScript counter part or is not designed in a way that it ever could be.
* For instance:
* - 'ArrayIterator' an iterator function symbol to deal with a `foreach` loop on a dynamic array.
* - 'IntrinsicVectLiteral' a function to represent a `vect(...)` literal.
* - 'Core.Class' a class with no UnrealScript counter part (a Class.uc file)
**/
Intrinsic = 1 << 17,

/** The field is a generated symbol, such as the return type of a function. */
Generated = 1 << 18,

/** The field is a keyword symbol, such as `Vect` */
Keyword = 1 << 19,

/** The field should not index a declaration reference. */
NoDeclaration = 1 << 20,

/** The field is marked as 'deprecated' */
Deprecated = 1 << 21,

// A private method can however be re-defined!
NonOverridable = Private | Intrinsic,
}
import { ITypeSymbol, UCObjectSymbol, UCStructSymbol, isParamSymbol } from './';
import { ModifierFlags } from './ModifierFlags';

export abstract class UCFieldSymbol extends UCObjectSymbol {
declare outer: UCObjectSymbol;
Expand Down
3 changes: 2 additions & 1 deletion server/src/UC/Symbols/InterfaceSymbol.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SymbolWalker } from '../symbolWalker';
import { ClassModifierFlags, ModifierFlags, UCClassSymbol, UCSymbolKind, UCTypeKind } from './';
import { ClassModifierFlags, UCClassSymbol, UCSymbolKind, UCTypeKind } from './';
import { ModifierFlags } from './ModifierFlags';

export class UCInterfaceSymbol extends UCClassSymbol {
static override readonly allowedKindsMask = 1 << UCSymbolKind.Enum
Expand Down
2 changes: 1 addition & 1 deletion server/src/UC/Symbols/IntrinsicArrayIterator.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
DEFAULT_RANGE,
MethodFlags,
ModifierFlags,
StaticIntType,
StaticMetaType,
UCMethodLikeSymbol,
UCParamSymbol,
} from '.';
import { toName } from '../name';
import { ModifierFlags } from './ModifierFlags';

export const ArrayIterator = new UCMethodLikeSymbol(toName('Iterator'));
ArrayIterator.modifiers |= ModifierFlags.Intrinsic | ModifierFlags.ReadOnly | ModifierFlags.NoDeclaration;
Expand Down
6 changes: 3 additions & 3 deletions server/src/UC/Symbols/IntrinsicSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { toName } from '../name';
import { NAME_ARRAY, NAME_RETURNVALUE } from '../names';
import {
DEFAULT_RANGE,
ModifierFlags,
StaticDelegateType,
StaticFloatType,
StaticIntType,
Expand All @@ -21,6 +20,7 @@ import {
UCStructSymbol,
UCSymbolKind,
} from './';
import { ModifierFlags } from './ModifierFlags';

export * from './CoreSymbols';
export * from './EngineSymbols';
Expand Down Expand Up @@ -163,15 +163,15 @@ IntrinsicNewConstructor.kind = UCSymbolKind.Operator;
IntrinsicNewConstructor.modifiers |= ModifierFlags.Keyword;
IntrinsicNewConstructor.description = createToken(`
Creates a new instanced object of the specified class.
Syntax:
${'`new [( [outer [, name [, flags]]] )] class [( template )]`'}
Usage:
${'```unrealscript'}
${`new (None, "MyObject", RF_Transient) Class'MyClass' (MyClass'MyTemplateObject')`}
${'```'}
${'For *Unreal Engine 2* the event `Object.Created()` will be instigated during the construction.'}
`);

Expand Down
5 changes: 3 additions & 2 deletions server/src/UC/Symbols/LocalSymbol.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SymbolWalker } from '../symbolWalker';
import { ModifierFlags, UCPropertySymbol, UCSymbolKind } from './';
import { UCPropertySymbol, UCSymbolKind } from './';
import { ModifierFlags } from './ModifierFlags';

export class UCLocalSymbol extends UCPropertySymbol {
override kind = UCSymbolKind.Local;
Expand All @@ -16,4 +17,4 @@ export class UCLocalSymbol extends UCPropertySymbol {
override accept<Result>(visitor: SymbolWalker<Result>): Result | void {
return visitor.visitLocal(this);
}
}
}
4 changes: 2 additions & 2 deletions server/src/UC/Symbols/MethodSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { Token } from 'antlr4ts/Token';
import { UCDocument } from '../document';
import { config } from '../indexer';
import { Name } from '../name';
import { NAME_ACTOR, NAME_CREATEDATAOBJECT, NAME_ENGINE, NAME_LOADDATAOBJECT, NAME_SPAWN } from '../names';
import { NAME_CREATEDATAOBJECT, NAME_LOADDATAOBJECT, NAME_SPAWN } from '../names';
import { UCGeneration } from '../settings';
import { SymbolWalker } from '../symbolWalker';
import {
ContextKind,
DEFAULT_RANGE,
ISymbol,
ModifierFlags,
SymbolReferenceFlags,
UCFieldSymbol,
UCObjectSymbol,
Expand All @@ -21,6 +20,7 @@ import {
UCTypeKind,
isFunction,
} from './';
import { ModifierFlags } from './ModifierFlags';

export enum MethodFlags {
None = 0x0000,
Expand Down
89 changes: 89 additions & 0 deletions server/src/UC/Symbols/ModifierFlags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* An all in one set of flags for UProperty kinds.
*
* Some flags are shared with @see MethodFlags and @see ClassModifiers.
*/
export const enum ModifierFlags {
None = 0,

// FieldFlags
/** The field is marked as 'protected' */
Protected = 1 << 0,

/** The field is marked as 'private' */
Private = 1 << 1,

NotPublic = Protected | Private,

/** The field is marked as 'native' or 'intrinsic' */
Native = 1 << 2,

/** The field is marked as 'const' or treated as readonly (for intrinsics) */
ReadOnly = 1 << 3, // aka Const

/** The field has a specified element size. e.g. `var int MyVar[2];` */
WithDimension = 1 << 4, // A multiple dimension property

/** The field is marked as 'transient' */
Transient = 1 << 6,

// ParamFlags
/** The field is a parameter of a function. */
Param = 1 << 7,

/** The field is a return parameter (generated) of a function. */
ReturnParam = 1 << 8,

/** The field is marked as 'out' */
Out = 1 << 9,

/** The field is marked as 'optional' */
Optional = 1 << 10,

/** The field is marked as 'init' */
Init = 1 << 11, // NOT SUPPORTED

/** The field is marked as 'skip' */
Skip = 1 << 12, // NOT SUPPORTED

/** The field is marked as 'coerce' */
Coerce = 1 << 13,

// XCom
/** The field is marked as 'ref' */
Ref = 1 << 14, // NOT SUPPORTED

// LocalFlags
/** The field is a local field of a function or state. */
Local = 1 << 15,

// ClassFlags
/** The field is marked as 'abstract' */
Abstract = 1 << 16, // TODO: Unify with ClassModifiers?

// InternalFlags
/**
* Field is an intrisic symbol, not to be confused with the older 'intrinsic' native keyword.
* That means the symbol was not contructed from an UnrealScript counter part or is not designed in a way that it ever could be.
* For instance:
* - 'ArrayIterator' an iterator function symbol to deal with a `foreach` loop on a dynamic array.
* - 'IntrinsicVectLiteral' a function to represent a `vect(...)` literal.
* - 'Core.Class' a class with no UnrealScript counter part (a Class.uc file)
**/
Intrinsic = 1 << 17,

/** The field is a generated symbol, such as the return type of a function. */
Generated = 1 << 18,

/** The field is a keyword symbol, such as `Vect` */
Keyword = 1 << 19,

/** The field should not index a declaration reference. */
NoDeclaration = 1 << 20,

/** The field is marked as 'deprecated' */
Deprecated = 1 << 21,

// A private method can however be re-defined!
NonOverridable = Private | Intrinsic,
}
Loading

0 comments on commit 9506bbf

Please sign in to comment.