Skip to content

Commit

Permalink
Encapsulate Name.value
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow-Devil committed Sep 16, 2024
1 parent 7b63113 commit 37cf61e
Show file tree
Hide file tree
Showing 158 changed files with 989 additions and 965 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ private boolean isResourceFunction(BSymbol symbol) {
}

private boolean isIgnorableSelfSymbol(Name name, BSymbol symbol, BSymbol symbolEnvScopeOwner) {
return name.value.equals("self") && !symbol.owner.owner.equals(symbolEnvScopeOwner.owner);
return name.getValue().equals("self") && !symbol.owner.owner.equals(symbolEnvScopeOwner.owner);
}

private boolean isFilteredVarSymbol(BSymbol symbol, Set<DiagnosticState> states) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ private Optional<TypeSymbol> getParamType(BLangInvocation bLangNode, int argumen
//Skip the first n arguments where n is the number of positional arguments specified by the user.
int numOfPositionalArgs = argumentIndex - namedArgs.size();
return invokableSymbol.params.subList(numOfPositionalArgs, paramsSize)
.stream().filter(param -> !namedArgs.contains(param.name.value))
.stream().filter(param -> !namedArgs.contains(param.name.getValue()))
.findFirst().flatMap(this::getSymbolType);
}
if (invokableSymbol.restParam != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private LangLibrary(CompilerContext context) {
PackageID moduleID = module.pkgID;

if (isLangLibModule(moduleID)) {
if (!LANG_VALUE.equals(moduleID.nameComps.get(1).value)) {
addLangLibMethods(moduleID.nameComps.get(1).value, module, this.langLibMethods, types);
if (!LANG_VALUE.equals(moduleID.nameComps.get(1).getValue())) {
addLangLibMethods(moduleID.nameComps.get(1).getValue(), module, this.langLibMethods, types);
} else {
populateLangValueLibrary(module, this.langLibMethods);
}
Expand Down Expand Up @@ -186,7 +186,7 @@ private static void addLangLibMethods(String basicType, BPackageSymbol langLibMo
(!invSymbol.params.isEmpty() && equalsToBasicType(invSymbol.params.get(0).type, basicType) ||
invSymbol.restParam != null &&
equalsToBasicType(((BArrayType) invSymbol.restParam.type).eType, basicType))) {
methods.put(invSymbol.name.value, invSymbol);
methods.put(invSymbol.name.getValue(), invSymbol);
}
}

Expand All @@ -204,7 +204,7 @@ private static void populateLangValueLibrary(BPackageSymbol langValue,
continue;
}

methods.put(symbol.name.value, (BInvokableSymbol) symbol);
methods.put(symbol.name.getValue(), (BInvokableSymbol) symbol);
}

langLibMethods.put(LANG_VALUE, methods);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ private void findRefsInResourceAccessPathSegments(BLangInvocation.BLangResourceA
}

BLangLiteral literal = (BLangLiteral) expr;
if (literal.value.equals(pathSymbol.name.value) && addIfSameSymbol(pathSymbol, expr.pos)) {
if (literal.value.equals(pathSymbol.name.getValue()) && addIfSameSymbol(pathSymbol, expr.pos)) {
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public BallerinaEnumSymbol createEnumSymbol(BEnumSymbol enumSymbol, String name)

List<ConstantSymbol> members = new ArrayList<>();
for (BConstantSymbol member : enumSymbol.members) {
members.add(this.createConstantSymbol(member, member.name.value));
members.add(this.createConstantSymbol(member, member.name.getValue()));
}

for (AnnotationAttachmentSymbol annot : enumSymbol.getAnnotations()) {
Expand Down Expand Up @@ -766,7 +766,7 @@ private String getMethodName(BInvokableSymbol method, BObjectTypeSymbol owner) {
for (BAttachedFunction mthd : methods) {
if (method == mthd.symbol) {
if (mthd instanceof BResourceFunction bResourceFunction) {
return bResourceFunction.accessor.value;
return bResourceFunction.accessor.getValue();
}
return mthd.symbol.getOriginalName().getValue();
}
Expand All @@ -788,7 +788,7 @@ private void addIfFlagSet(BallerinaClassSymbol.ClassSymbolBuilder symbolBuilder,
}

private BField getBField(BVarSymbol symbol) {
String fieldName = symbol.name.value;
String fieldName = symbol.name.getValue();
BStructureType type = (BStructureType) symbol.owner.type;
return type.fields.get(fieldName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public Optional<ModuleSymbol> getModule() {
SymbolTable symTable = SymbolTable.getInstance(this.context);
SymbolFactory symFactory = SymbolFactory.getInstance(this.context);
this.module = (ModuleSymbol) symFactory.getBCompiledSymbol(symTable.langIntModuleSymbol,
symTable.langIntModuleSymbol
.getOriginalName().value);
symTable.langIntModuleSymbol
.getOriginalName().getValue());
return Optional.of(this.module);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public Optional<ModuleSymbol> getModule() {
SymbolTable symTable = SymbolTable.getInstance(this.context);
SymbolFactory symFactory = SymbolFactory.getInstance(this.context);
this.module = (ModuleSymbol) symFactory.getBCompiledSymbol(symTable.langXmlModuleSymbol,
symTable.langXmlModuleSymbol
.getOriginalName().value);
symTable.langXmlModuleSymbol
.getOriginalName().getValue());
return Optional.of(this.module);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Map<String, ClassFieldSymbol> fieldDescriptors() {
BObjectType type = (BObjectType) this.getBType();

for (BField field : type.fields.values()) {
fields.put(field.symbol.getOriginalName().value, new BallerinaClassFieldSymbol(this.context, field));
fields.put(field.symbol.getOriginalName().getValue(), new BallerinaClassFieldSymbol(this.context, field));
}

this.classFields = Collections.unmodifiableMap(fields);
Expand All @@ -108,8 +108,8 @@ public Optional<MethodSymbol> initMethod() {
if (this.initMethod == null && this.internalSymbol.initializerFunc != null) {
SymbolFactory symbolFactory = SymbolFactory.getInstance(this.context);
this.initMethod = symbolFactory.createMethodSymbol(internalSymbol.initializerFunc.symbol,
internalSymbol.initializerFunc.symbol
.getOriginalName().value);
internalSymbol.initializerFunc.symbol
.getOriginalName().getValue());
}

return Optional.ofNullable(this.initMethod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public TypeDescKind typeKind() {

@Override
public String signature() {
return this.getInternalSymbol().name.value;
return this.getInternalSymbol().name.getValue();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Optional<ModuleSymbol> getModule() {
}

SymbolFactory symbolFactory = SymbolFactory.getInstance(this.context);
this.module = symbolFactory.createModuleSymbol((BPackageSymbol) symbol, symbol.name.value);
this.module = symbolFactory.createModuleSymbol((BPackageSymbol) symbol, symbol.name.getValue());
return Optional.of(this.module);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class BallerinaObjectFieldSymbol extends BallerinaSymbol implements Objec
private List<io.ballerina.compiler.api.symbols.AnnotationAttachmentSymbol> annotAttachments;

public BallerinaObjectFieldSymbol(CompilerContext context, BField bField, SymbolKind kind) {
super(bField.symbol.getOriginalName().value, kind, bField.symbol, context);
super(bField.symbol.getOriginalName().getValue(), kind, bField.symbol, context);
this.bField = bField;
this.docAttachment = new BallerinaDocumentation(bField.symbol.markdownDocumentation);
this.deprecated = Symbols.isFlagOn(bField.symbol.flags, Flags.DEPRECATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Map<String, ObjectFieldSymbol> fieldDescriptors() {
BObjectType type = (BObjectType) this.getBType();

for (BField field : type.fields.values()) {
fields.put(field.symbol.getOriginalName().value, new BallerinaObjectFieldSymbol(this.context, field));
fields.put(field.symbol.getOriginalName().getValue(), new BallerinaObjectFieldSymbol(this.context, field));
}

this.objectFields = Collections.unmodifiableMap(fields);
Expand All @@ -113,11 +113,11 @@ public Map<String, MethodSymbol> methods() {
for (BAttachedFunction attachedFunc : ((BObjectTypeSymbol) this.getBType().tsymbol).attachedFuncs) {
if (attachedFunc instanceof BResourceFunction resFn) {
String resPath = resFn.pathSegmentSymbols.stream()
.map(p -> p.name.value).collect(Collectors.joining("/"));
methods.put(resFn.accessor.value + " " + resPath,
.map(p -> p.name.getValue()).collect(Collectors.joining("/"));
methods.put(resFn.accessor.getValue() + " " + resPath,
symbolFactory.createResourceMethodSymbol(attachedFunc.symbol));
} else {
methods.put(attachedFunc.funcName.value,
methods.put(attachedFunc.funcName.getValue(),
symbolFactory.createMethodSymbol(attachedFunc.symbol,
attachedFunc.symbol.getOriginalName().getValue()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class BallerinaRecordFieldSymbol extends BallerinaSymbol implements Recor
private boolean deprecated;

public BallerinaRecordFieldSymbol(CompilerContext context, BField bField) {
super(bField.symbol.getOriginalName().value, SymbolKind.RECORD_FIELD, bField.symbol, context);
super(bField.symbol.getOriginalName().getValue(), SymbolKind.RECORD_FIELD, bField.symbol, context);
this.bField = bField;
this.docAttachment = new BallerinaDocumentation(bField.symbol.markdownDocumentation);
this.deprecated = Symbols.isFlagOn(bField.symbol.flags, Flags.DEPRECATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Map<String, RecordFieldSymbol> fieldDescriptors() {
BRecordType type = (BRecordType) this.getBType();

for (BField field : type.fields.values()) {
fields.put(field.symbol.getOriginalName().value, new BallerinaRecordFieldSymbol(this.context, field));
fields.put(field.symbol.getOriginalName().getValue(), new BallerinaRecordFieldSymbol(this.context, field));
}

this.fieldSymbols = Collections.unmodifiableMap(fields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Optional<ModuleSymbol> getModule() {
SymbolTable symTable = SymbolTable.getInstance(this.context);
SymbolFactory symFactory = SymbolFactory.getInstance(this.context);
this.module = (ModuleSymbol) symFactory.getBCompiledSymbol(symTable.langRegexpModuleSymbol,
symTable.langRegexpModuleSymbol.getOriginalName().value);
symTable.langRegexpModuleSymbol.getOriginalName().getValue());
}
return Optional.ofNullable(this.module);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,6 @@ private BResourceFunction getBResourceFunction(List<BAttachedFunction> methods,
}

throw new IllegalStateException(
"Matching BResourceFunction not found for internal symbol: " + internalSymbol.name.value);
"Matching BResourceFunction not found for internal symbol: " + internalSymbol.name.getValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public Map<String, ClassFieldSymbol> fieldDescriptors() {
Map<String, ClassFieldSymbol> fields = new LinkedHashMap<>();

for (BField field : classType.fields.values()) {
fields.put(field.name.value, new BallerinaClassFieldSymbol(this.context, field));
fields.put(field.name.getValue(), new BallerinaClassFieldSymbol(this.context, field));
}

this.fields = Collections.unmodifiableMap(fields);
Expand All @@ -146,14 +146,15 @@ public Map<String, ClassFieldSymbol> fieldDescriptors() {
StringJoiner stringJoiner = new StringJoiner("/");

for (BResourcePathSegmentSymbol pathSegmentSym : resFn.pathSegmentSymbols) {
stringJoiner.add(pathSegmentSym.name.value);
stringJoiner.add(pathSegmentSym.name.getValue());
}

methods.put(resFn.accessor.value + " " + stringJoiner.toString(),
methods.put(resFn.accessor.getValue() + " " + stringJoiner.toString(),
symbolFactory.createResourceMethodSymbol(method.symbol));
} else {
methods.put(method.funcName.value,
symbolFactory.createMethodSymbol(method.symbol, method.symbol.getOriginalName().value));
methods.put(
method.funcName.getValue(),
symbolFactory.createMethodSymbol(method.symbol, method.symbol.getOriginalName().getValue()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public Optional<ModuleSymbol> getModule() {
SymbolTable symTable = SymbolTable.getInstance(this.context);
SymbolFactory symFactory = SymbolFactory.getInstance(this.context);
this.module = (ModuleSymbol) symFactory.getBCompiledSymbol(symTable.langStringModuleSymbol,
symTable.langStringModuleSymbol
.getOriginalName().value);
symTable.langStringModuleSymbol
.getOriginalName().getValue());
return Optional.of(this.module);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Optional<ModuleSymbol> getModule() {
}

SymbolFactory symbolFactory = SymbolFactory.getInstance(this.context);
this.module = symbolFactory.createModuleSymbol((BPackageSymbol) symbol, symbol.name.value);
this.module = symbolFactory.createModuleSymbol((BPackageSymbol) symbol, symbol.name.getValue());
return Optional.of(this.module);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private TypeSymbol createTypeDescriptor(BType bType, BTypeSymbol tSymbol) {
case OBJECT:
ObjectTypeSymbol objType = new BallerinaObjectTypeSymbol(this.context, (BObjectType) bType);
if (Symbols.isFlagOn(tSymbol.flags, Flags.CLASS)) {
return symbolFactory.createClassSymbol((BClassSymbol) tSymbol, tSymbol.name.value, objType);
return symbolFactory.createClassSymbol((BClassSymbol) tSymbol, tSymbol.name.getValue(), objType);
}
return objType;
case RECORD:
Expand Down Expand Up @@ -302,7 +302,7 @@ public boolean isTypeReference(BType bType, BSymbol tSymbol, boolean rawTypeOnly
return false;
}

if (!isBuiltinNamedType(bType.tag) && !(tSymbol.name.value.isEmpty()
if (!isBuiltinNamedType(bType.tag) && !(tSymbol.name.getValue().isEmpty()
|| anonymousModelHelper.isAnonymousType(tSymbol))) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public List<PathParameterSymbol> pathParameters() {
for (int i = 0; i < segments.size(); i++) {
Name internalSegment = segments.get(i);
BResourcePathSegmentSymbol pathSegSymbol = this.internalPathSegmentSymbols.get(i);
switch (internalSegment.value) {
switch (internalSegment.getValue()) {
case "^":
BVarSymbol paramVarSymbol = this.internalPathParams.get(internalPathParamCount++);
pathParams.add(symbolFactory.createPathParamSymbol(paramVarSymbol.getOriginalName().getValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private static void getConfigVars(Module module, Collection<Scope.ScopeEntry> sc
// Get description
String description = getDescriptionValue(varSymbol, module);
configVariables.add(new ConfigVariable(
varSymbol.name.value.replace("\\", ""), varSymbol.type,
varSymbol.name.getValue().replace("\\", ""), varSymbol.type,
Symbols.isFlagOn(varSymbol.flags, Flags.REQUIRED), description));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ private Set<ModuleLoadRequest> getModuleLoadRequests(ModuleDescriptor currentMod
TransactionImportValidator trxImportValidator = new TransactionImportValidator();

if (trxImportValidator.shouldImportTransactionPackage(modulePartNode) &&
!currentModuleDesc.name().toString().equals(Names.TRANSACTION.value)) {
String moduleName = Names.TRANSACTION.value;
!currentModuleDesc.name().toString().equals(Names.TRANSACTION.getValue())) {
String moduleName = Names.TRANSACTION.getValue();
ModuleLoadRequest ballerinaiLoadReq = new ModuleLoadRequest(
PackageOrg.from(Names.BALLERINA_INTERNAL_ORG.value),
PackageOrg.from(Names.BALLERINA_INTERNAL_ORG.getValue()),
moduleName, scope, DependencyResolutionType.PLATFORM_PROVIDED);
moduleLoadRequestSet.add(ballerinaiLoadReq);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ private CompilerBackend.TargetPlatform getTargetPlatform(PackageResolution pkgRe

// 1) Check direct dependencies of imports in the package have any `ballerina/java` dependency
for (ResolvedPackageDependency dependency : resolvedPackageDependencies) {
if (dependency.packageInstance().packageOrg().value().equals(Names.BALLERINA_ORG.value) &&
dependency.packageInstance().packageName().value().equals(Names.JAVA.value) &&
if (dependency.packageInstance().packageOrg().value().equals(Names.BALLERINA_ORG.getValue()) &&
dependency.packageInstance().packageName().value().equals(Names.JAVA.getValue()) &&
!dependency.scope().equals(PackageDependencyScope.TEST_ONLY)) {
return this.backend.targetPlatform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private LinkedHashSet<ModuleLoadRequest> getModuleLoadRequestsOfDirectDependenci
{
String moduleName = Names.OBSERVE.getValue();
ModuleLoadRequest observeModuleLoadReq = new ModuleLoadRequest(
PackageOrg.from(Names.BALLERINA_INTERNAL_ORG.value), moduleName,
PackageOrg.from(Names.BALLERINA_INTERNAL_ORG.getValue()), moduleName,
PackageDependencyScope.DEFAULT, DependencyResolutionType.PLATFORM_PROVIDED);
allModuleLoadRequests.add(observeModuleLoadReq);
}
Expand All @@ -338,7 +338,7 @@ private LinkedHashSet<ModuleLoadRequest> getModuleLoadRequestsOfDirectDependenci
"choreo".equals(compilationOptions.getCloud())) {
String moduleName = Names.CLOUD.getValue();
ModuleLoadRequest c2cModuleLoadReq = new ModuleLoadRequest(
PackageOrg.from(Names.BALLERINA_ORG.value), moduleName,
PackageOrg.from(Names.BALLERINA_ORG.getValue()), moduleName,
PackageDependencyScope.DEFAULT, DependencyResolutionType.COMPILER_PLUGIN);
allModuleLoadRequests.add(c2cModuleLoadReq);
}
Expand Down
Loading

0 comments on commit 37cf61e

Please sign in to comment.