Gets the root folder
The root folder
method getRootFolder()
return this.rootFile;
end
<@doc>
Gets the list of all files/folders in the CodeWriter
The files list
method getAllFiles()
return this.filesList;
end
<@doc>
Gets the list of files/folders under a given folder
The folder to fetch
The files list
method getSubFiles(path)
var folder = this.getFile(arguments[0], arguments[1]);
if (!folder || !folder.isFolder) return null;
return folder.files;
end
<@doc scope="private">
Gets tree root (part of TreeProvider interface)
method getRoot()
return this.rootFile;
end
<@doc scope="private">
Gets tree node (part of TreeProvider interface)
method getNode(id)
return this.getFile(POS(id));
end
<@doc scope="private">
Gets tree child nodes (part of TreeProvider interface)
method getChildNodes(id)
var file = this.getFile(POS(id));
if (!file || !file.isFolder) return [];
SORT(file.files, 'order');
return file.files;
end
///////////////////////////////////////////////////////////////////////
// ERRORS HANDLING
<@doc group="7. Errors Reporting">Gets the number of accumulated errors
readonly property errorsCount = 0;
<@doc>Gets the number of accumulated warnings
readonly property warningsCount = 0;
<@doc>
Reports an error
The error message
The GML object associated with the error
Optional hint about the error
method error(msg, obj, hint)
if (!msg) return;
this.addErrorEntry({type:'E', msg:msg, obj:obj, hint:hint}, obj);
this.errorsCount++;
end
<@doc>
Reports a warning
The warning message
The GML object associated with the warning
Optional hint about the warning
method warning(msg, obj, hint)
if (!msg) return;
this.addErrorEntry({type:'W', msg:msg, obj:obj, hint:hint}, obj);
this.warningsCount++;
end
<@doc scope="private">
Reports a CodeWriter error
The error message
method writerError(msg, obj)
if (!msg) return;
var file=this.currentFile, hint='';
if (file) {
hint = 'near line '+file.linesCount+' in file '+file.path;
}
this.addErrorEntry({type:'E', msg:msg, hint:hint});
this.errorsCount++;
end
<@doc scope="private">
Adds an error object to the errors index
method addErrorEntry(err, obj)
var unit=null;
if (ISA(obj, $ENV.model.unitClassifier)) {
unit = obj;
} else if (ISA(obj, $ENV.model.elementClassifier)) {
unit = obj.unit;
}
if (unit) err.unit = unit;
var grp = unit ? unit.id : '$';
var key = UPPER(unit ? grp+'$' : '$') + UPPER(obj? obj.id+'$' : '$') + err.msg;
if (key in this.allErrors) return;
this.allErrors[key] = err;
if (!(grp in this.unitErrors)) {
var E=[];
if (unit) E.title = unit.name; else E.title = 'General';
this.unitErrors[grp] = E;
}
this.unitErrors[grp].push(err);
end
<@doc>
Gets the collection of all accumulated errors/warnings
The errors collection
method getAllErrors()
return this.allErrors;
end
<@doc>
Gets the collection of all accumulated errors, grouped by unit/warnings
The errors collection
method getErrorsByUnit()
return this.unitErrors;
end
method getErrorsOfUnit(unit)
var allErrors = this.unitErrors;
if(unit && (unit.id in allErrors))
return allErrors[unit.id];
return null;
end
<@doc>
Paints error/warning indicators next to all associated elements in the current diagram
method paintErrorFlags()
// TODO
end
<@doc>
Erases any error/warning indicators in the current diagram
method eraseErrorFlags()
// TODO
end
///////////////////////////////////////////////////////////////////////
// LINKS HANDLING
<@doc group="8. Links Reporting">Gets the number of links
readonly property linksCount = 0;
<@doc>
Reports a link
The link message
The link address
Optional hint about the link
method link(grp,title, appName, link, provider, hint,fullClassName)
if (!appName) return;
this.addLinkEntry({type:'L', grp:grp, title: title, msg:appName, link:link, ruleExtenders:provider, hint:hint, fullClassName:fullClassName});
this.linksCount++;
end
<@doc scope="private">
Adds a link to the links index
method addLinkEntry(obj)
if(!obj)return;
var grp = obj.grp || '$'; context = this;
var key = UPPER(grp ? grp+'$' : '$') + UPPER(obj.msg || '' +'$');
this.allLinks[key] = obj;
var newNode = getFullPath()
newNode.push(obj);
function getFullPath(){
var fullpath = null;
if(obj.title)fullpath = obj.title.split('#');
if (!(grp in context.dcLinks)){
var L=[];
L.title = fullpath ? fullpath[0] : grp;
context.dcLinks[grp] = L;
}
var node = context.dcLinks[grp];
if(fullpath){
for(var k=1 ; k < fullpath.length ; ++k){
var entry = fullpath[k]
if(!node.subgrp)node.subgrp = {};
if(!node.subgrp[entry]){
var L = [];
L.title = entry;
node.subgrp[entry] = L;
}
node = node.subgrp[entry];
}
}
return node;
}
end
<@doc>
Gets the collection of all links
The links collection
method getAllLinks()
return this.allLinks;
end
<@doc>
Gets the collection of all accumulated links, grouped by DC
The links collection
method getLinksByDc()
return this.dcLinks;
end
<@doc>
Reports a link
The info message
Optional hint about the info
method info(msg, hint)
if (!msg) return;
this.addInfoEntry({type:'I', msg:msg, hint:hint});
end
<@doc scope="private">
Adds a info to the infos index
method addInfoEntry(msg)
if(!this.allInfo['I']) this.allInfo['I'] = [];
this.allInfo['I'].push(msg);
end
<@doc>
Gets the collection of all infos
The infos collection
method getAllInfos()
return this.allInfo;
end
///////////////////////////////////////////////////////////////////////
// FORMAT SETTINGS
<@doc group="9. Settings">Gets or sets the newline characters sequence
property newlineChar = '\r\n';
<@doc>Gets or sets the tab size (number of spaces)
property tabSize = 3;
<@doc>Gets or sets the path separator character
property pathChar = '\\';
<@doc scope="private">XML header characters sequence
property xmlHeader = '';
<@doc scope="private">CDATA block start sequence
property cdataChar1 = '';
<@doc scope="private">CDATA block end sequence
property cdataChar2 = '';
<@doc>Indicates whether opening brace of a block is placed inline or on the next line
Sample
compactBlockBraces = true
if (a < 0) {
print("negative");
}
compactBlockBraces = false
if (a < 0)
{
print("negative");
}
property compactBlockBraces = true;
<@doc>Indicates whether a block clause (e.g., Else, Catch, etc.) is placed inline or on the next line
Sample
compactBlockClauses = true and compactBlockBraces = true
if (a < 0) {
print("negative");
} else {
print("positive");
}
compactBlockClauses = false and compactBlockBraces = true
if (a < 0) {
print("negative");
}
else {
print("positive");
}
compactBlockClauses = false and compactBlockBraces = false
if (a < 0)
{
print("negative");
}
else
{
print("positive");
}
property compactBlockClauses = true;
<@doc>Indicates whether one-line blocks are placed inline or enclosed in braces on separate lines
Sample
compactOneLineBlocks = true
if (a < 0) print("negative"); else print("positive");
compactOneLineBlocks = false
if (a < 0) {
print("negative");
} else {
print("positive");
}
property compactOneLineBlocks = false;
<@doc>Indicates whether block contents are indented one level to the right of the block statement
Sample
indentBlockContents = true
function (a, b) {
if (a < b) {
print("a < b");
} else {
print("a > b");
}
}
indentBlockContents = false
function (a, b) {
if (a < b) {
print("a < b");
} else {
print("a > b");
}
}
property indentBlockContents = true;
<@doc>Indicates whether case contents are indented one level to the right of the case labels
Sample
indentCaseContents = true
switch (type) {
case 'A':
print("A");
break;
case 'B':
print("B");
break;
default:
print("X");
break;
}
indentCaseContents = false
switch (type) {
case 'A':
print("A");
break;
case 'B':
print("B");
break;
default:
print("X");
break;
}
property indentCaseContents = true;
<@doc>Indicates whether to insert spacing between adjacent case clauses
Sample
insertCaseSpacing = true
switch (type) {
case 'A':
print("A");
break;
case 'B':
print("B");
break;
default:
print("X");
break;
}
insertCaseSpacing = false
switch (type) {
case 'A':
print("A");
break;
case 'B':
print("B");
break;
default:
print("X");
break;
}
property insertCaseSpacing = true;
<@doc>Indicates whether statement terminators should be automatically added to the end of lines in code blocks
Sample
completeStatements = true
function (a,b) {
var c;
c = a + b;
print(c);
}
completeStatements = false
function (a,b) {
var c
c = a + b
print(c)
}
property completeStatements = true;