public static void MakeMethods (string FileName, string Buffer, string Line, int Column, AdaMethods Methods) { string adaFileName = FileName.ToLower(); int nameFirst = 0; int nameLast = Line.Length - 1; int noDotNameFirst = 0; bool haveOne = false; mcc.gnat_tools.xref.xref_file_list_package.node xrefs = null; int useLocation = 0; int newUseLocation = 0; string thisUse; string strUseClause = GetUseClause(Buffer); string possibleDot; rememberMethods = Methods; for (int j = nameLast; j >= nameFirst; j--) { if (Char.IsLetterOrDigit(Line[j]) || Line[j] == '.' || Line[j] == '_') { if (!haveOne) { haveOne = true; nameLast = j; } if (Line[j] == '.') { noDotNameFirst = noDotNameFirst > j + 1 ? noDotNameFirst : j + 1; } } else if (Char.IsControl(Line[j]) || Line[j] == ' ') { if (haveOne) { nameFirst = j + 1; noDotNameFirst = noDotNameFirst > nameFirst ? noDotNameFirst : nameFirst; break; } } else { nameFirst = j + 1; noDotNameFirst = noDotNameFirst > nameFirst ? noDotNameFirst : nameFirst; } } if (!haveOne) { return; } displayProcedureName = Line.Substring(noDotNameFirst, nameLast - noDotNameFirst + 1); procedureName = displayProcedureName.ToLower(); packageName = Line.Substring(nameFirst, noDotNameFirst - 2 - nameFirst + 1).ToLower(); while (newUseLocation != -1) { newUseLocation = strUseClause.IndexOf(';', useLocation); if (newUseLocation != -1) { thisUse = strUseClause.Substring(useLocation, newUseLocation - 1 - useLocation + 1); useLocation = newUseLocation + 1; if ((thisUse.Length == 0) && (packageName.Length == 0)) { goto EndMainLoop; } } else { thisUse = ""; } if ((thisUse.Length != 0) && (packageName.Length != 0)) { possibleDot = "."; } else { possibleDot = ""; } { string filename = Dashify(thisUse + possibleDot + packageName).ToLower(); string fullPath = DefaultLocation.Find_File(filename, "", System.IO.Directory.GetParent(adaFileName).FullName, true); string foundFilename; if (fullPath.Length == 0) { filename = Krunch(filename); fullPath = DefaultLocation.Find_File(filename, "", System.IO.Directory.GetParent(adaFileName).FullName, true); if (fullPath.Length == 0) { goto EndMainLoop; } } foundFilename = filename + ".ads"; byte[] fullPathByte = new byte[fullPath.Length]; char[] tmp = fullPath.ToCharArray(); mgnat.adalib.Acc xrefs_ptr = new mgnat.adalib.Acc(); for (int j = 0; j < tmp.Length; j++) { fullPathByte[j] = (byte)tmp[j]; } mcc.gnat_tools.xref_pkg.read_ali(fullPathByte, 0, fullPath.Length - 1, xrefs_ptr); if (xrefs_ptr.all != null) { xrefs = (mcc.gnat_tools.xref.xref_file_list_package.node)xrefs_ptr.all; lastInserted = ""; byte[] foundFilenameByte = new byte[foundFilename.Length]; for (int j = 0; j < foundFilename.Length; j++) { foundFilenameByte[j] = (byte)foundFilename[j]; } mcc.gnat_tools.xref_pkg.enumerate_public_entities (foundFilenameByte, 1, foundFilename.Length, xrefs, new mcc.gnat_tools.xref.public_callback_type(Lb_Parameter_Insert)); xrefs = null; } } EndMainLoop: xrefs = null; } }
public static void MakeDeclarations (string TheFileName, string Buffer, string Line, int Column, AdaDeclarations Declarations) { int Start = 0; int End = Column; string FileName = TheFileName.ToLower(); for (int j = Column; j >= 0; j--) { if (!Char.IsLetterOrDigit(Line[j]) && Line[j] != '.' && Line[j] != '_') { Start = j + 1; break; } } for (int j = Column; j > Start; j--) { if (Line[j] == '.') { End = j - 1; break; } } // maybe we've got something like 3 . if (Start > End) { return; } string Prefix; string FoundFilename; string FoundDirectory; char[] tmp = new char[End - Start + 1]; for (int j = Start; j <= End; j++) { tmp[j - Start] = (char)Line[j]; } Prefix = new String(tmp).ToLower(); mcc.gnat_tools.xref.xref_file_list_package.node Xrefs = new mcc.gnat_tools.xref.xref_file_list_package.node(); if (IsBasicName(Prefix, Declarations)) { return; } { string tmpFilename = Dashify(Prefix); string FullPath = DefaultLocation.Find_File(tmpFilename, "", System.IO.Directory.GetParent(FileName).FullName, true); if (FullPath.Length == 0) { tmpFilename = Krunch(tmpFilename); FullPath = DefaultLocation.Find_File(tmpFilename, "", System.IO.Directory.GetParent(FileName).FullName, true); } if (FullPath.Length == 0) { return; } FoundFilename = tmpFilename + ".ads"; FoundDirectory = DefaultLocation.Find_File(tmpFilename, "", System.IO.Directory.GetParent(FileName).FullName, false); FoundDirectory = System.IO.Directory.GetParent(FoundDirectory).FullName; mgnat.adalib.Acc Xrefs_Acc = new mgnat.adalib.Acc(); byte[] bFileName = new byte[FullPath.Length]; for (int j = 0; j < FullPath.Length; j++) { bFileName[j] = (byte)FullPath[j]; } Xrefs_Acc.all = null; mcc.gnat_tools.xref_pkg.read_ali(bFileName, 0, bFileName.GetUpperBound(0), Xrefs_Acc); if (Xrefs_Acc.all != null) { bFileName = new byte[FoundFilename.Length]; for (int j = 0; j < FoundFilename.Length; j++) { bFileName[j] = (byte)FoundFilename[j]; } Xrefs = (mcc.gnat_tools.xref.xref_file_list_package.node)Xrefs_Acc.all; lastInserted = ""; Remember_Declarations = Declarations; mcc.gnat_tools.xref_pkg.enumerate_public_entities (bFileName, 0, bFileName.Length - 1, Xrefs, new mcc.gnat_tools.xref.public_callback_type(Lb_Insert)); } } if (FoundDirectory.Length != 0) { string[] results = System.IO.Directory.GetFiles(FoundDirectory, Dashify(Prefix) + "-" + "*.ad*"); for (int j = 0; j < results.Length; j++) { string thisOne = System.IO.Path.GetFileNameWithoutExtension(results[j]); string answer = thisOne.Substring(Prefix.Length, thisOne.Length - Prefix.Length); if (answer.IndexOf('-') == -1) { Declarations.addDeclaration(answer); } } } }