Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] some xqlint errors are not displayed #1

Closed
wants to merge 13 commits into from
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"baseUrl": "http://localhost:8080/exist/apps",
"projectId": "6tyg6v"
"projectId": "6tyg6v",
"experimentalSessionAndOrigin": true
}
402 changes: 402 additions & 0 deletions cypress/integration/dbmanager.spec.js

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions cypress/integration/exide_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@ describe('eXide', function() {
cy.reload(true)

})
it('should display editor', function () {
cy.get('.path')
cy.contains('__new__1')
})

// more tests here
})
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"doc": "docs"
},
"scripts": {
"build": "node scripts/build.js prepare && npm run xqlint && node scripts/build.js",
"build:dev": "node scripts/build.js prepare && npm run xqlint && node scripts/build.js --dev",
"build": "node scripts/build.js prepare && npm run xqlint && node scripts/build.js --deploy=localhost",
"build:dev": "node scripts/build.js prepare && npm run xqlint && node scripts/build.js --dev --deploy=localhost",
"clean": "node scripts/build.js clean",
"xqlint": "cd support/xqlint && node r.js -o build.js && cd ../..",
"cypress": "cypress run"
Expand Down
2 changes: 1 addition & 1 deletion src/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ eXide.edit.Directory = (function () {
}
return fn(d)
}
d3.json("modules/collections.xq?root=" + (sel.datum().key || "/db") + "&view=r", function(error, data){
d3.json("modules/collections.xq?root=" + encodeURIComponent(sel.datum().key || "/db") + "&view=r", function(error, data){
if(error) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion src/eXide.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ eXide.app = (function(util) {

updateStatus: function(doc) {
$("#syntax").val(doc.getSyntax());
$("#status .path").text(util.normalizePath(doc.getPath()));
$("#status .path").text(decodeURI(util.normalizePath(doc.getPath())));
if (!doc.isNew() && (doc.getSyntax() == "xquery" || doc.getSyntax() == "html" || doc.getSyntax() == "xml")) {
$("#status a").attr("href", doc.getExternalLink());
$("#status a").css("visibility", "visible");
Expand Down
30 changes: 14 additions & 16 deletions src/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ eXide.browse.ResourceBrowser = (function () {
var coll;
if (params.data.name == "..")
coll = this.dataSource.collection.replace(/\/[^\/]+$/, "");
else coll = this.dataSource.collection + "/" + params.data.name;
else coll = params.data.key;
this.$triggerEvent("activateCollection", [coll, params.data.writable]);
this.update(coll, false);
} else {
eXide.app.openSelectedDocument({
name: params.data.name,
path: this.dataSource.collection + "/" + params.data.name,
path: params.data.key,
writable: params.data.writable
});
}
Expand Down Expand Up @@ -226,13 +226,13 @@ eXide.browse.ResourceBrowser = (function () {
if (e.data.name === "..")
coll = this.dataSource.collection.replace(/\/[^\/]+$/, "")
else
coll = this.dataSource.collection + "/" + e.data.name;
coll = e.data.key;
this.$triggerEvent("activateCollection", [ coll, e.data.writable ]);
this.update(coll, false);
} else {
eXide.app.openSelectedDocument({
name: e.data.name,
path: this.dataSource.collection + "/" + e.data.name,
path: e.data.key,
writable: e.data.writable,
});
}
Expand Down Expand Up @@ -305,13 +305,13 @@ eXide.browse.ResourceBrowser = (function () {
}
};
this.gridOptions.onCellValueChanged = (params) => {
if (!this.oldValue) {
if (!params.oldValue) {
return;
}
params.column.colDef.editable = false;
$.getJSON("modules/collections.xq", {
target: params.data.name,
rename: this.oldValue,
target: encodeURI(params.newValue),
rename: encodeURI(params.oldValue),
root: this.dataSource.collection
}, (data) => {
if (data.status == "fail") {
Expand Down Expand Up @@ -340,7 +340,7 @@ eXide.browse.ResourceBrowser = (function () {
}
var resources = [];
for (var i = 0; i < selected.length; i++) {
resources.push($this.dataSource.collection + "/" + selected[i].name);
resources.push(selected[i].key);
}
var params = $("form", dialog).serialize();
params = params + "&" + $.param({ "modify[]": resources});
Expand All @@ -367,6 +367,7 @@ eXide.browse.ResourceBrowser = (function () {
this.breadcrumbs.empty();
var self = this;
var parts = this.dataSource.collection.split("/");
parts = parts.map(part => decodeURI(part));
var span = $("<span>/</span>");
var path = "/";
for (var i = 0; i < parts.length; i++) {
Expand Down Expand Up @@ -418,8 +419,7 @@ eXide.browse.ResourceBrowser = (function () {
const selected = this.gridOptions.api.getSelectedRows();
if (selected.length == 0) {
return null;
}

}
return selected;
};

Expand All @@ -428,7 +428,7 @@ eXide.browse.ResourceBrowser = (function () {
if (cell.column.colId !== 'name') {
return;
}
this.oldValue = this.dataSource.data[cell.rowIndex].name;
this.oldValue = this.dataSource.data[cell.rowIndex].key;
cell.column.colDef.editable = true;
this.inEditor = true;
this.gridOptions.api.startEditingCell({
Expand Down Expand Up @@ -520,7 +520,7 @@ eXide.browse.ResourceBrowser = (function () {
var resources = [];
for (var i = 0; i < selected.length; i++) {
if (selected[i].name != "..") {
resources.push(this.dataSource.collection + "/" + selected[i].name);
resources.push(selected[i].key);
}
}
if (resources.length > 0) {
Expand All @@ -545,10 +545,8 @@ eXide.browse.ResourceBrowser = (function () {
}
this.clipboard = [];
for (var i = 0; i < selected.length; i++) {
var path = selected[i].name;
if (path.substr(0, 1) != "/") {
path = this.dataSource.collection + "/" + path;
}
var path = selected[i].key;

this.clipboard.push(path);
}
$.log("Clipboard: %o", this.clipboard);
Expand Down
7 changes: 7 additions & 0 deletions src/xquery-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ eXide.edit.XQueryModeHelper = (function () {
},
contentType: "application/octet-stream",
success: function (data) {
if (data.result !== 'fail' && doc.error) {
data.result = 'fail';
data.error = doc.error;
}
var valid = $this.compileError(data, doc);
if (onComplete) {
onComplete.call(this, valid);
Expand Down Expand Up @@ -206,6 +210,7 @@ eXide.edit.XQueryModeHelper = (function () {
return;
}
$.log("Running xqlint...");
doc.error = false;
var session = doc.getSession();
var value = doc.getText();
var h = new JSONParseTreeHandler(value);
Expand All @@ -214,6 +219,7 @@ eXide.edit.XQueryModeHelper = (function () {
parser.parse_XQuery();
} catch(e) {
$.log("Error while parsing XQuery: %s", parser.getErrorMessage(e));
doc.error = parser.getErrorMessage(e);
if(e instanceof parser.ParseException) {
h.closeParseTree();
}
Expand Down Expand Up @@ -255,6 +261,7 @@ eXide.edit.XQueryModeHelper = (function () {
session.setAnnotations(annotations);
} catch(e) {
$.log("Error while processing ast: %s", e.message);
doc.error = doc.error || e.message;
}
};

Expand Down