Skip to content

Commit

Permalink
Fixed alloy instances viz
Browse files Browse the repository at this point in the history
  • Loading branch information
soaibsafi committed Jun 25, 2024
1 parent 21de688 commit 89a68cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions frontend/src/assets/js/alloyUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@ export function getGraphData(alloyInstance) {
const label = field['label'];
// relationship is computed from the field label and the types of the atoms
const atomTypes = [];
// collect type elements in field['types'] types
for (const type of field['types']['type'] || {}) {
atomTypes.push(type['ID']);
// check length of types array
if (field['types']['type']) {
// collect type elements in field['types'] types
for (const type of field['types']['type'] || {}) {
atomTypes.push(type['ID']);
}
} else {
for (const obj of field['types'] || {}) {
for (const type of obj['type'] || {}) {
atomTypes.push(type['ID']);
}
}
}
const relationship = field['label'] + ' (' + atomTypes.join('_') + ')';
const tupleField = field['tuple'] || {};
Expand Down Expand Up @@ -112,7 +121,7 @@ export function getGraphData(alloyInstance) {

export function parseAlloyErrorMessage(error) {
let message = '';
if (error.includes('Syntax error') && error.includes('.als') && error.includes('line')) {
if (error.includes('error') && error.includes('.als') && error.includes('line')) {
message = error.replace(/ in .+\.als/, '');
}
return message;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Playground/alloy/AlloyOutput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const AlloyOutput = ({ alloyInstance, setAlloyInstance, height, isFullScreen, se
if (alloyInstance["error"].includes("No instance found")) {
setIsInstance(false);
setAlloyErrorMessage("No instance found");
} else if (alloyInstance["error"].includes("Syntax error")) {
} else if (alloyInstance["error"]) {
setIsInstance(false);
setAlloyErrorMessage(parseAlloyErrorMessage(alloyInstance["error"]));
setLineToHighlight(getLineToHighlight(alloyInstance["error"], 'alloy'));
Expand Down

0 comments on commit 89a68cc

Please sign in to comment.