Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SasinduDilshara committed Mar 14, 2023
2 parents b887fe6 + 14f888c commit 7a2f1e0
Show file tree
Hide file tree
Showing 2,195 changed files with 69,258 additions and 39,995 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/daily_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ jobs:
restore-keys: ${{ runner.os }}-gradle

- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '22.2.0'
java-version: '11'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
set-java-home: 'false'
uses: graalvm/setup-graalvm@v1
with:
version: '22.2.0'
java-version: '11'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
set-java-home: 'false'

- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
run: |
export DISPLAY=':99.0'
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/language_server_simulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
branch: ["master", "2201.2.x", "2201.3.x", "2201.3.0-stage"]
branch: ["master", "2201.2.x", "2201.3.x", "2201.4.x", "2201.4.0-stage"]
skipGenerators: ["", "IMPORT_STATEMENT"]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly_publish_timestamped_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
branch: ['master', '2201.2.x', '2201.3.x']
branch: ['master', '2201.2.x', '2201.3.x', '2201.4.x']
timeout-minutes: 240
if: github.repository_owner == 'ballerina-platform'
steps:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/pull_request_full_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ jobs:
strategy:
fail-fast: false
matrix:
level: [ 1, 2, 3, 4, 5, 6, 7, 8 ]
level: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

steps:
- name: Setup NodeJs
uses: actions/setup-node@v3
with:
node-version: 10.22.1
- name: Download Ballerina Lang Artifacts
uses: actions/download-artifact@v2
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pull_request_ubuntu_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
set-java-home: 'false'

- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
run: |
export DISPLAY=':99.0'
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pull_request_windows_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@ jobs:
restore-keys: ${{ runner.os }}-gradle

- name: Build with Gradle
run: ./gradlew.bat build --continue -x :ballerina-lang:test -x :jballerina-integration-test:test -x :ballerina-shell:shell-cli:test -x :jballerina-debugger-integration-test:test -x createJavadoc --stacktrace -scan --console=plain --no-daemon --no-parallel
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew.bat build --continue -x :ballerina-lang:test -x :jballerina-integration-test:test -x :ballerina-shell:shell-cli:test -x createJavadoc --stacktrace -scan --console=plain --no-daemon --no-parallel

2 changes: 2 additions & 0 deletions .github/workflows/push_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ jobs:
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: "${{ env.SONAR_TOKEN != '' }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static MapType createMapType(String typeName, Type constraint, Module mod
*/
public static RecordType createRecordType(String typeName, Module module, long flags, boolean sealed,
int typeFlags) {
return new BRecordType(typeName, module, flags, sealed, typeFlags);
return new BRecordType(typeName, typeName, module, flags, sealed, typeFlags);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,7 @@
public class MapUtils {

public static void handleMapStore(MapValue<BString, Object> mapValue, BString fieldName, Object value) {
Type mapType = mapValue.getType();
switch (mapType.getTag()) {
case TypeTags.MAP_TAG:
handleInherentTypeViolatingMapUpdate(value, (BMapType) mapType);
mapValue.put(fieldName, value);
break;
case TypeTags.RECORD_TYPE_TAG:
if (handleInherentTypeViolatingRecordUpdate(mapValue, fieldName, value, (BRecordType) mapType,
false)) {
mapValue.put(fieldName, value);
} else {
mapValue.remove(fieldName);
}
break;
}
updateMapValue(mapValue.getType(), mapValue, fieldName, value);
}

public static void handleInherentTypeViolatingMapUpdate(Object value, BMapType mapType) {
Expand Down Expand Up @@ -156,4 +142,23 @@ public static void checkIsMapOnlyOperation(Type mapType, String op) {
throw createOpNotSupportedError(mapType, op);
}
}

private static void updateMapValue(Type mapType, MapValue<BString, Object> mapValue, BString fieldName,
Object value) {
switch (mapType.getTag()) {
case TypeTags.MAP_TAG:
handleInherentTypeViolatingMapUpdate(value, (BMapType) mapType);
mapValue.put(fieldName, value);
return;
case TypeTags.RECORD_TYPE_TAG:
if (handleInherentTypeViolatingRecordUpdate(mapValue, fieldName, value, (BRecordType) mapType, false)) {
mapValue.put(fieldName, value);
return;
}
mapValue.remove(fieldName);
return;
case TypeTags.TYPE_REFERENCED_TYPE_TAG:
updateMapValue(((BTypeReferenceType) mapType).getReferredType(), mapValue, fieldName, value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.ballerina.runtime.internal.values.IteratorValue;
import io.ballerina.runtime.internal.values.MapValue;
import io.ballerina.runtime.internal.values.RefValue;
import io.ballerina.runtime.internal.values.RegExpValue;
import io.ballerina.runtime.internal.values.TableValue;

import java.util.Map;
Expand Down Expand Up @@ -93,6 +94,8 @@ public static Long hash(Object obj, Node parent) {
result = 31 * result + hash(tableIterator.next(), node);
}
return result;
} else if (refValue instanceof RegExpValue) {
return (long) refValue.toString().hashCode();
} else {
return (long) obj.hashCode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,62 +335,7 @@ public static boolean checkIsLikeType(Object sourceValue, Type targetType, boole
* @return true if the two types are same; false otherwise
*/
public static boolean isSameType(Type sourceType, Type targetType) {

int sourceTypeTag = sourceType.getTag();
int targetTypeTag = targetType.getTag();

if (sourceType == targetType) {
return true;
}
if (sourceTypeTag == targetTypeTag) {
if (sourceType.equals(targetType)) {
return true;
}
switch (sourceTypeTag) {
case TypeTags.ARRAY_TAG:
return checkArrayEquivalent(sourceType, targetType);
case TypeTags.FINITE_TYPE_TAG:
// value space should be same
Set<Object> sourceValueSpace = ((BFiniteType) sourceType).valueSpace;
Set<Object> targetValueSpace = ((BFiniteType) targetType).valueSpace;
if (sourceValueSpace.size() != targetValueSpace.size()) {
return false;
}

for (Object sourceVal : sourceValueSpace) {
if (!containsType(targetValueSpace, getType(sourceVal))) {
return false;
}
}
return true;
default:
break;

}
}

// all the types in a finite type may evaluate to target type
switch (sourceTypeTag) {
case TypeTags.FINITE_TYPE_TAG:
for (Object value : ((BFiniteType) sourceType).valueSpace) {
if (!isSameType(getType(value), targetType)) {
return false;
}
}
return true;
default:
break;
}

if (targetTypeTag == TypeTags.FINITE_TYPE_TAG) {
for (Object value : ((BFiniteType) targetType).valueSpace) {
if (!isSameType(getType(value), sourceType)) {
return false;
}
}
return true;
}
return false;
return sourceType == targetType || sourceType.equals(targetType);
}

public static Type getType(Object value) {
Expand Down Expand Up @@ -584,14 +529,6 @@ public static TypedescValue getTypedesc(Object value) {
* @param annotTag The annot-tag-reference
* @return the annotation value if present, nil else
*/
public static Object getAnnotValue(TypedescValue typedescValue, String annotTag) {
Type describingType = typedescValue.getDescribingType();
if (!(describingType instanceof BAnnotatableType)) {
return null;
}
return ((BAnnotatableType) describingType).getAnnotation(StringUtils.fromString(annotTag));
}

public static Object getAnnotValue(TypedescValue typedescValue, BString annotTag) {
Type describingType = typedescValue.getDescribingType();
if (!(describingType instanceof BAnnotatableType)) {
Expand Down Expand Up @@ -1875,16 +1812,16 @@ private static Optional<MethodType> getMatchingInvokableType(List<MethodType> rh
return Optional.empty();
}

List<Type> lhsFuncResourcePathTypes = ((BResourceMethodType) lhsFunc).resourcePathType.getTupleTypes();
List<Type> rhsFuncResourcePathTypes = ((BResourceMethodType) matchingFunc).resourcePathType.getTupleTypes();
Type[] lhsFuncResourcePathTypes = ((BResourceMethodType) lhsFunc).pathSegmentTypes;
Type[] rhsFuncResourcePathTypes = ((BResourceMethodType) matchingFunc).pathSegmentTypes;

int lhsFuncResourcePathTypesSize = lhsFuncResourcePathTypes.size();
if (lhsFuncResourcePathTypesSize != rhsFuncResourcePathTypes.size()) {
int lhsFuncResourcePathTypesSize = lhsFuncResourcePathTypes.length;
if (lhsFuncResourcePathTypesSize != rhsFuncResourcePathTypes.length) {
return Optional.empty();
}

for (int i = 0; i < lhsFuncResourcePathTypesSize; i++) {
if (!checkIsType(lhsFuncResourcePathTypes.get(i), rhsFuncResourcePathTypes.get(i))) {
if (!checkIsType(lhsFuncResourcePathTypes[i], rhsFuncResourcePathTypes[i])) {
return Optional.empty();
}
}
Expand Down Expand Up @@ -2109,17 +2046,6 @@ private static boolean isMutable(Object value, Type sourceType) {
return !((RefValue) value).isFrozen();
}

private static boolean checkArrayEquivalent(Type actualType, Type expType) {
if (expType.getTag() == TypeTags.ARRAY_TAG && actualType.getTag() == TypeTags.ARRAY_TAG) {
// Both types are array types
BArrayType lhrArrayType = (BArrayType) expType;
BArrayType rhsArrayType = (BArrayType) actualType;
return checkIsArrayType(rhsArrayType, lhrArrayType, new ArrayList<>());
}
// Now one or both types are not array types and they have to be equal
return expType == actualType;
}

private static boolean checkIsNeverTypeOrStructureTypeWithARequiredNeverMember(Type type) {
Set<String> visitedTypeSet = new HashSet<>();
return checkIsNeverTypeOrStructureTypeWithARequiredNeverMember(type, visitedTypeSet);
Expand Down Expand Up @@ -3602,15 +3528,6 @@ private static boolean containsElement(Set<Object> valueSpace, String e) {
return false;
}

private static boolean containsType(Set<Object> valueSpace, Type type) {
for (Object value : valueSpace) {
if (!isSameType(type, getType(value))) {
return false;
}
}
return true;
}

public static Object handleAnydataValues(Object sourceVal, Type targetType) {
if (sourceVal != null && !(sourceVal instanceof Number) && !(sourceVal instanceof BString) &&
!(sourceVal instanceof Boolean) && !(sourceVal instanceof BValue)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,19 @@ public static BTypedesc getTypedescValue(Type type, BValue value) {
return new TypedescValueImpl(type);
}

/**
* Provide the Typedesc Value depending on the immutability of a value.
* @param readOnly Indicates that the type is a subtype of readonly
* @param value Ballerina value
* @param inherentType Inherent type of the value
* @return typedesc with the suitable type
*/
public static BTypedesc getTypedescValue(Boolean readOnly, BValue value, TypedescValueImpl inherentType) {
if (readOnly) {
TypedescValueImpl typedesc = (TypedescValueImpl) createSingletonTypedesc(value);
typedesc.annotations = inherentType.annotations;
return typedesc;
}
return inherentType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.ballerina.runtime.internal.values.XmlPi;
import io.ballerina.runtime.internal.values.XmlQName;
import io.ballerina.runtime.internal.values.XmlSequence;
import io.ballerina.runtime.internal.values.XmlText;

import java.io.Reader;
import java.io.StringReader;
Expand Down Expand Up @@ -147,7 +148,7 @@ private void readPI(XMLStreamReader xmlStreamReader) {
}

private void readText(XMLStreamReader xmlStreamReader) {
siblingDeque.peek().add(XmlFactory.createXMLText(xmlStreamReader.getText()));
siblingDeque.peek().add(new XmlText(xmlStreamReader.getText()));
}

private void readComment(XMLStreamReader xmlStreamReader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private String getErrorMessage(List<Diagnostic> diagnosticList) {
StringBuilder errorMessage = new StringBuilder("\n");
for (Diagnostic diagnostic : diagnosticList) {
LineRange lineRange = getOneBasedLineRange(diagnostic.location().lineRange());
errorMessage.append("[").append(lineRange.filePath()).append(":")
errorMessage.append("[").append(lineRange.fileName()).append(":")
.append(lineRange).append("] ").append(diagnostic.message()).append("\n");
}
return errorMessage.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ static String getLineRange(TomlNode node) {
return CONFIG_FILE_NAME;
}
LineRange oneBasedLineRange = getOneBasedLineRange(node.location().lineRange());
return oneBasedLineRange.filePath() + ":" + oneBasedLineRange;
return oneBasedLineRange.fileName() + ":" + oneBasedLineRange;
}

static LineRange getOneBasedLineRange(LineRange lineRange) {
return LineRange.from(
lineRange.filePath(),
lineRange.fileName(),
LinePosition.from(lineRange.startLine().line() + 1, lineRange.startLine().offset() + 1),
LinePosition.from(lineRange.endLine().line() + 1, lineRange.endLine().offset() + 1));
}
Expand Down
Loading

0 comments on commit 7a2f1e0

Please sign in to comment.