public List <Node> InterpretClass(string clas, string package) { List <Node> nodes = new List <Node>(); //Initialize the base Node ClassNode baseNode = new ClassNode(); baseNode.package = package; //Initialize the ClassStram Reader ClassStreamReader csr = new ClassStreamReader(); csr.Setup(JavaCIEAHolder.getObject(clas).content, null); //Fill a List with all parts of the class List <string> seps = new List <string>(); do { seps.Add(csr.readTillNextSep()); Console.WriteLine(seps[seps.Count - 1]); }while (seps[seps.Count - 1] != null && seps[seps.Count - 1] != ""); //Search for the class name LETS GO FOR A NEW ATTEMPT //baseNode.name = GetNameAfterKeyword(seps, "class"); //baseNode.location = baseNode.package + baseNode.name; //Console.WriteLine(baseNode.name); return(nodes); }
public List <string> RemoveUnwantedInterfaces(List <string> interfaces, List <string> annotations) { List <string> inter = new List <string>(); foreach (string interf in interfaces) { bool match = false; foreach (string anno in annotations) { if (JavaCIEAHolder.getObject(interf).start == JavaCIEAHolder.getObject(anno).start + 1) { match = true; } } if (!match) { inter.Add(interf); } } return(inter); }
///<summary> ///CIEA stands for Class Interface Enum and Annotation ///</summary> public List <string> getCIEAsByKeyword(string keyword, string path, string file) { List <string> cieas = new List <string>(); int offset = 0; while (file.IndexOf(keyword, offset) > -1) { int inter = file.IndexOf(keyword, offset); int start = 0; int end = 0; bool foundStart = false; if (file.Substring(0, inter - 1).LastIndexOf("@") > file.Substring(0, inter - 1).LastIndexOf("}")) { foundStart = true; start = file.Substring(0, inter - 1).LastIndexOf("@"); } foreach (string modi in Java.accessLevelModifiers) { if (file.IndexOf(modi, inter - 30, 30) > -1 && !foundStart) { start = file.IndexOf(modi, inter - 30, 30); foundStart = true; break; } } if (file.IndexOf(Java.initialValue[0], inter - 20, 20) > -1 && !foundStart) { start = file.IndexOf(Java.initialValue[0], inter - 20, 20); } //If there is no accessLevelModifer and no static it will search for final or abstract foreach (string subcl in Java.subclassable) { if (file.IndexOf(subcl, inter - 12, 12) > -1 && !foundStart) { start = file.IndexOf(subcl, inter - 12, 12); foundStart = true; break; } } //If there is no private, public, protected, static, final or abstract the begin of the class is set to the class keyword if (!foundStart) { start = inter; } int openBrackets = 0; int nextBracketOffset = start; do { int nextOpen = file.IndexOf("{", nextBracketOffset); int nextClose = file.IndexOf("}", nextBracketOffset); if (nextOpen == -1) { if (nextClose != -1) { //01 openBrackets--; nextBracketOffset = file.IndexOf("}", nextBracketOffset) + 1; } else { //00 throw new NotClosedBracketsException($"Some of the brackets in file: {path}, weren\'t closed!"); } } else if (nextClose == -1 && nextOpen != -1) { //10 throw new NotClosedBracketsException($"Some of the brackets in file: {path}, weren\'t closed!"); } else if (file.IndexOf("{", nextBracketOffset) < file.IndexOf("}", nextBracketOffset)) { //11 openBrackets++; nextBracketOffset = file.IndexOf("{", nextBracketOffset) + 1; } else { //11 openBrackets--; nextBracketOffset = file.IndexOf("}", nextBracketOffset) + 1; } } while (openBrackets != 0); end = nextBracketOffset; offset = end; //offset = inter + 5; //interfaces.Add(file.Substring(start, end - start)); cieas.Add(JavaCIEAHolder.getJsonObject(new JavaCIEAHolder(file.Substring(start, end - start), start, end))); } return(cieas); }