Skip to content

Commit

Permalink
added utility function support in FileStructure (MFile, NodeFS) (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
wit00 committed Mar 6, 2018
1 parent e6818a5 commit 17b5332
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/at/mep/editor/tree/MFile.java
Expand Up @@ -389,9 +389,14 @@ public static class ClassDef {
/** list of properties for class */
private List<Properties> properties = new ArrayList<>(0);

/** lsit of methods for class */
/** list of methods for class */
private List<Method> method = new ArrayList<>(0);

/** list of "Class-Related Functions"
* https://de.mathworks.com/help/matlab/matlab_oop/specifying-methods-and-functions.html
*/
private List<Method.Function> utilityFunctions = new ArrayList<>(0);

private ClassDef() {
}

Expand Down Expand Up @@ -427,6 +432,10 @@ public List<Method> getMethod() {
return method;
}

public List<Method.Function> getUtilityFunctions() {
return utilityFunctions;
}

public List<MTree.Node> getSuperclasses() {
return superclasses;
}
Expand Down Expand Up @@ -510,6 +519,9 @@ public static List<ClassDef> construct(List<MTree.Node> mtnClassDef) {

classDef.attributes = Attributes.construct(node.getLeft().getLeft().getListOfNextNodes());

List<MTree.Node> uf = TreeUtilsV2.findNode(mtnClassDef.get(0).getListOfNextNodes(), MTree.NodeType.FUNCTION);
classDef.utilityFunctions = Method.Function.construct(uf);

List<MTree.Node> pn = TreeUtilsV2.findNode(mtnClassDef.get(0).getRight().getListOfNextNodes(), MTree.NodeType.PROPERTIES);
classDef.properties = Properties.construct(pn);

Expand Down
13 changes: 13 additions & 0 deletions src/at/mep/gui/fileStructure/NodeFS.java
Expand Up @@ -305,10 +305,23 @@ public static NodeFS constructForClassDef(Editor editor, boolean withInherited)

populateProperties(root, classDef.getProperties(), null,"");
populateMethods(root, classDef.getMethod(), null, "");
populateUtilityFunctions(root, classDef.getUtilityFunctions(), null, "");

return root;
}

private static void populateUtilityFunctions(NodeFS root, List<MFile.ClassDef.Method.Function> functionList, File file, String suffix) {
for (MFile.ClassDef.Method.Function function : functionList) {
NodeFS nodeFS = new NodeFS();
nodeFS.node = function.getNode();
nodeFS.nodeText = function.getFunctionString() + suffix;
nodeFS.nodeType = MTree.NodeType.FUNCTION;
nodeFS.file = file;
// TODO: What attributes do utility function have?
root.add(nodeFS);
}
}

private static void populateMethods(NodeFS root, List<MFile.ClassDef.Method> methodList, File file, String suffix) {
for (MFile.ClassDef.Method method : methodList) {
List<MFile.Attributes.Attribute> attributeList = null;
Expand Down

0 comments on commit 17b5332

Please sign in to comment.