Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 896x 896x 1x 1x 22x 22x 22x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 1x 1x 2x 2x 2x 1x 1x 2x 2x 2x 1x 1x 6x 6x 6x 6x 6x 1x 1x 11x 11x 6x 6x 5x 5x 11x 5x 5x 1x 1x 237x 237x 237x 1x 1x 12x 12x 1x 1x 208x 208x 208x 208x 208x 208x 208x 208x 208x 208x 208x 208x 208x 208x 208x 208x 1x 1x 318x 83x 83x 235x 235x 235x 235x 235x 318x 9x 9x 9x 9x 9x 4x 4x 4x 4x 4x 4x 4x 9x 4x 4x 4x 4x 4x 4x 4x 8x 9x 9x 9x 9x 9x 9x 9x 9x 9x 1x 1x 9x 9x 9x 226x 226x 318x 226x 318x 318x 318x 318x 59x 59x 59x 59x 59x 59x 59x 59x 226x 318x 318x 318x 3x 3x 3x 3x 3x 3x 226x 226x 318x 318x 318x 318x 318x 318x 318x 318x 318x 318x 318x 1x 1x 38x 38x 38x 1x 1x 11x 11x 11x 1x 1x 240x 240x 1x 1x | import {AbstractObject} from "./_abstract_object";
import {AbstractType} from "../abap/types/basic/_abstract_type";
import * as Types from "../abap/types/basic";
import {IRegistry} from "../_iregistry";
import {DDIC} from "../ddic";
import {xmlToArray} from "../xml_utils";
import {Identifier} from "../abap/4_file_information/_identifier";
import {Identifier as IdentifierToken} from "../abap/1_lexer/tokens/identifier";
import {Position} from "../position";
export interface DomainValue {
language: string,
low: string,
high: string,
description: string
}
export interface DomainValueTranslation {
language: string,
description: string
}
function toNumber(value: string | undefined): number | undefined {
const parsed = parseInt(value ?? "", 10);
return isNaN(parsed) ? undefined : parsed;
}
export class Domain extends AbstractObject {
private parsedXML: {
description?: string,
datatype?: string,
length?: string,
decimals?: string,
conversionExit?: string,
values?: DomainValue[],
valuesTranslations?: DomainValueTranslation[],
} | undefined;
public getType(): string {
return "DOMA";
}
public getDescription(): string | undefined {
this.parse();
return this.parsedXML?.description;
}
public getConversionExit(): string | undefined {
this.parse();
return this.parsedXML?.conversionExit;
}
public getDataType(): string | undefined {
this.parse();
return this.parsedXML?.datatype;
}
public getLength(): number | undefined {
this.parse();
return toNumber(this.parsedXML?.length);
}
public getDecimals(): number | undefined {
this.parse();
return toNumber(this.parsedXML?.decimals);
}
public getAllowedNaming() {
return {
maxLength: 30,
allowNamespace: true,
};
}
public getIdentifier(): Identifier | undefined {
const xmlIdentifier = super.getIdentifier();
if (xmlIdentifier) {
return xmlIdentifier;
}
const file = this.getAFFFile();
if (file === undefined) {
return undefined;
}
return new Identifier(new IdentifierToken(new Position(1, 1), this.getName()), file.getFilename());
}
public setDirty(): void {
this.parsedXML = undefined;
super.setDirty();
}
public parseType(reg: IRegistry): AbstractType {
return this.parseDomainType(reg);
}
public parseDomainType(reg: IRegistry, dataElement?: string, description?: string): AbstractType {
// dont cache the DOMA parsed type, they are cached on DTEL level
// also note that the type carries the name of the DTEL
if (this.parsedXML === undefined) {
this.parse();
}
if (this.parsedXML === undefined) {
return new Types.UnknownType("Domain " + this.getName() + " parser error", this.getName());
}
const ddic = new DDIC(reg);
return ddic.textToType({
text: this.parsedXML.datatype,
length: this.parsedXML.length,
decimals: this.parsedXML.decimals,
infoText: this.getName(),
qualifiedName: dataElement,
conversionExit: this.parsedXML.conversionExit,
ddicName: dataElement,
description: description,
});
}
public parse() {
if (this.parsedXML) {
return {updated: false, runtime: 0};
}
const start = Date.now();
this.parsedXML = {};
const jsonFile = this.getAFFFile();
if (jsonFile) {
try {
const parsed = JSON.parse(jsonFile.getRaw());
const language = parsed.header?.originalLanguage;
const values: DomainValue[] = [];
for (const fixedValue of parsed.fixedValues ?? []) {
values.push({
low: fixedValue?.fixedValue,
high: "",
description: fixedValue?.description,
language: language,
});
}
for (const interval of parsed.fixedValueIntervals ?? []) {
values.push({
low: interval?.lowLimit,
high: interval?.highLimit,
description: interval?.description,
language: language,
});
}
this.parsedXML = {
description: parsed.header?.description,
datatype: parsed.format?.dataType,
length: parsed.format?.length?.toString(),
decimals: parsed.format?.decimals?.toString(),
conversionExit: parsed.outputCharacteristics?.conversionRoutine,
values: values,
valuesTranslations: [],
};
} catch {
// handled by parseType()
}
const end = Date.now();
return {updated: true, runtime: end - start};
}
const parsed = super.parseRaw2();
if (parsed === undefined) {
return {updated: false, runtime: 0};
}
const dd01v = parsed.abapGit?.["asx:abap"]?.["asx:values"]?.DD01V;
const dd07v_tab = xmlToArray(parsed.abapGit?.["asx:abap"]?.["asx:values"]?.DD07V_TAB?.DD07V);
const values: DomainValue[] = [];
for (const ddo7v of dd07v_tab) {
const value: DomainValue = {
description: ddo7v?.DDTEXT,
low: ddo7v?.DOMVALUE_L,
high: ddo7v?.DOMVALUE_H,
language: ddo7v?.DDLANGUAGE,
};
values.push(value);
}
const dd07v_texts = xmlToArray(parsed.abapGit?.["asx:abap"]?.["asx:values"]?.DD07_TEXTS?.item);
const translationValues: DomainValueTranslation[] = [];
for (const dd07v of dd07v_texts) {
const value: DomainValueTranslation = {
language: dd07v?.DDLANGUAGE,
description: dd07v?.DDTEXT,
};
translationValues.push(value);
}
this.parsedXML = {
description: dd01v?.DDTEXT,
datatype: dd01v?.DATATYPE,
length: dd01v?.LENG,
conversionExit: dd01v?.CONVEXIT,
decimals: dd01v?.DECIMALS,
values: values,
valuesTranslations: translationValues,
};
const end = Date.now();
return {updated: true, runtime: end - start};
}
public getFixedValues() {
this.parse();
return this.parsedXML?.values ?? [];
}
public getFixedValuesTranslations() {
this.parse();
return this.parsedXML?.valuesTranslations ?? [];
}
private getAFFFile() {
return this.getFiles().find(file => file.getFilename().toLowerCase().endsWith(".doma.json"));
}
}
|