mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-06 15:47:30 +08:00
Classes naming refactoring
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
|
||||
export default class FunctionReferenceEntity extends Entity {
|
||||
export default class FunctionReferenceEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
MemberParent: ObjectReferenceEntity,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
|
||||
export default class GuidEntity extends Entity {
|
||||
export default class GuidEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
value: String
|
||||
|
||||
110
js/entity/Entity.js → js/entity/IEntity.js
Executable file → Normal file
110
js/entity/Entity.js → js/entity/IEntity.js
Executable file → Normal file
@@ -1,55 +1,55 @@
|
||||
import TypeInitialization from "./TypeInitialization"
|
||||
import Utility from "../Utility"
|
||||
|
||||
export default class Entity {
|
||||
|
||||
constructor(options = {}) {
|
||||
/**
|
||||
*
|
||||
* @param {String[]} prefix
|
||||
* @param {Object} target
|
||||
* @param {Object} properties
|
||||
*/
|
||||
const defineAllAttributes = (prefix, target, properties) => {
|
||||
let fullKey = prefix.concat("")
|
||||
const last = fullKey.length - 1
|
||||
for (let property in properties) {
|
||||
fullKey[last] = property
|
||||
// Not instanceof because all objects are instenceof Object, exact match needed
|
||||
if (properties[property]?.constructor === Object) {
|
||||
target[property] = {}
|
||||
defineAllAttributes(fullKey, target[property], properties[property])
|
||||
continue
|
||||
}
|
||||
/*
|
||||
* The value can either be:
|
||||
* - Array: can contain multiple values, its property is assigned multiple times like (X=1, X=4, X="Hello World")
|
||||
* - TypeInitialization: contains the maximum amount of information about the attribute.
|
||||
* - A type: the default value will be default constructed object without arguments.
|
||||
* - A proper value.
|
||||
*/
|
||||
const value = Utility.objectGet(options, fullKey)
|
||||
if (value !== null) {
|
||||
target[property] = value
|
||||
continue
|
||||
}
|
||||
let defaultValue = properties[property]
|
||||
if (defaultValue instanceof TypeInitialization) {
|
||||
if (!defaultValue.showDefault) {
|
||||
continue
|
||||
}
|
||||
defaultValue = defaultValue.value
|
||||
}
|
||||
if (defaultValue instanceof Array) {
|
||||
target[property] = []
|
||||
continue
|
||||
}
|
||||
if (defaultValue instanceof Function) {
|
||||
defaultValue = TypeInitialization.sanitize(new defaultValue())
|
||||
}
|
||||
target[property] = defaultValue
|
||||
}
|
||||
}
|
||||
defineAllAttributes([], this, this.getAttributes())
|
||||
}
|
||||
}
|
||||
import TypeInitialization from "./TypeInitialization"
|
||||
import Utility from "../Utility"
|
||||
|
||||
export default class IEntity {
|
||||
|
||||
constructor(options = {}) {
|
||||
/**
|
||||
*
|
||||
* @param {String[]} prefix
|
||||
* @param {Object} target
|
||||
* @param {Object} properties
|
||||
*/
|
||||
const defineAllAttributes = (prefix, target, properties) => {
|
||||
let fullKey = prefix.concat("")
|
||||
const last = fullKey.length - 1
|
||||
for (let property in properties) {
|
||||
fullKey[last] = property
|
||||
// Not instanceof because all objects are instenceof Object, exact match needed
|
||||
if (properties[property]?.constructor === Object) {
|
||||
target[property] = {}
|
||||
defineAllAttributes(fullKey, target[property], properties[property])
|
||||
continue
|
||||
}
|
||||
/*
|
||||
* The value can either be:
|
||||
* - Array: can contain multiple values, its property is assigned multiple times like (X=1, X=4, X="Hello World")
|
||||
* - TypeInitialization: contains the maximum amount of information about the attribute.
|
||||
* - A type: the default value will be default constructed object without arguments.
|
||||
* - A proper value.
|
||||
*/
|
||||
const value = Utility.objectGet(options, fullKey)
|
||||
if (value !== null) {
|
||||
target[property] = value
|
||||
continue
|
||||
}
|
||||
let defaultValue = properties[property]
|
||||
if (defaultValue instanceof TypeInitialization) {
|
||||
if (!defaultValue.showDefault) {
|
||||
continue
|
||||
}
|
||||
defaultValue = defaultValue.value
|
||||
}
|
||||
if (defaultValue instanceof Array) {
|
||||
target[property] = []
|
||||
continue
|
||||
}
|
||||
if (defaultValue instanceof Function) {
|
||||
defaultValue = TypeInitialization.sanitize(new defaultValue())
|
||||
}
|
||||
target[property] = defaultValue
|
||||
}
|
||||
}
|
||||
defineAllAttributes([], this, this.getAttributes())
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
|
||||
export default class IntegerEntity extends Entity {
|
||||
export default class IntegerEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
value: Number
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
|
||||
export default class KeyBinding extends Entity {
|
||||
export default class KeyBinding extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
bCtrlDown: false,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
|
||||
export default class LocalizedTextEntity extends Entity {
|
||||
export default class LocalizedTextEntity extends IEntity {
|
||||
|
||||
static lookbehind = "NSLOCTEXT"
|
||||
static attributes = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
import FunctionReferenceEntity from "./FunctionReferenceEntity"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import IntegerEntity from "./IntegerEntity"
|
||||
@@ -7,7 +7,7 @@ import PinEntity from "./PinEntity"
|
||||
import TypeInitialization from "./TypeInitialization"
|
||||
import VariableReferenceEntity from "./VariableReferenceEntity"
|
||||
|
||||
export default class ObjectEntity extends Entity {
|
||||
export default class ObjectEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
Class: ObjectReferenceEntity,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
|
||||
export default class ObjectReferenceEntity extends Entity {
|
||||
export default class ObjectReferenceEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
type: String,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
|
||||
export default class PathSymbolEntity extends Entity {
|
||||
export default class PathSymbolEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
value: String
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import LocalizedTextEntity from "./LocalizedTextEntity"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
import PinReferenceEntity from "./PinReferenceEntity"
|
||||
import TypeInitialization from "./TypeInitialization"
|
||||
|
||||
export default class PinEntity extends Entity {
|
||||
export default class PinEntity extends IEntity {
|
||||
|
||||
static lookbehind = "Pin"
|
||||
static attributes = {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import PathSymbol from "./PathSymbolEntity"
|
||||
|
||||
export default class PinReferenceEntity extends Entity {
|
||||
export default class PinReferenceEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
objectName: PathSymbol,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Entity from "./Entity"
|
||||
import IEntity from "./IEntity"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
|
||||
export default class VariableReferenceEntity extends Entity {
|
||||
export default class VariableReferenceEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
MemberName: String,
|
||||
|
||||
Reference in New Issue
Block a user