private void MenuItemShowPosition_Unchecked(object sender, RoutedEventArgs e) { _xmlGenerator = new SrcMLGenerator(directorySelector.SelectedPath, _namespaceArguments); if (sourceBox.Text.Length > 0) { sourceBox_TextChanged(sender, null); } }
private void CreateArchive(string filesInThisDirectory) { var srcMlArchiveFolder = Path.Combine(_indexPath, "archive"); var srcMLFolder = Path.Combine(".", "SrcML", "CSharp"); Directory.CreateDirectory(srcMlArchiveFolder); var generator = new SrcMLGenerator(TestUtils.SrcMLDirectory); _srcMLArchive = new SrcMLArchive(_indexPath, false, generator); }
public void TestCSharpExpressionWithDefaultKeyword() { var generator = new SrcMLGenerator(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation)); generator.GenerateSrcMLFromFile("external\\TestCSharpExpressionWithDefaultKeyword.cs", "external_xml\\TestCSharpExpressionWithDefaultKeyword.cs.xml"); var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpExpressionWithDefaultKeyword.cs.xml"); var classB = fileUnit.Element(SRC.Class); Assert.IsNotNull(classB); Assert.AreEqual(2, classB.Descendants(SRC.Function).Count()); }
public void TestCSharpExpressionWithDefaultKeyword() { var generator = new SrcMLGenerator(TestConstants.SrcmlPath); generator.GenerateSrcMLFromFile("external\\TestCSharpExpressionWithDefaultKeyword.cs", "external_xml\\TestCSharpExpressionWithDefaultKeyword.cs.xml"); var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpExpressionWithDefaultKeyword.cs.xml"); var classB = fileUnit.Element(SRC.Class); Assert.IsNotNull(classB); Assert.AreEqual(2, classB.Descendants(SRC.Function).Count()); }
/// <summary> /// Creates a new project object /// </summary> /// <param name="scheduler">The task scheduler</param> /// <param name="monitor">The file monitor</param> /// <param name="srcmlGenerator">The generator object for srcML</param> public DataProject(TaskScheduler scheduler, AbstractFileMonitor monitor, SrcMLGenerator srcmlGenerator) : base(scheduler, monitor, new SrcMLGenerator()) { var fileMapPath = Path.Combine(StoragePath, DataArchive.DEFAULT_ARCHIVE_DIRECTORY); Data = new DataArchive(StoragePath, DataArchive.DEFAULT_ARCHIVE_DIRECTORY, true, SourceArchive, new DataGenerator(), new DataFileNameMapping(fileMapPath), scheduler); SetupWorkingSet(); Data.Generator.IsLoggingErrors = true; Data.Generator.ErrorLog = SourceArchive.Generator.ErrorLog; }
public void SetUp() { builder = new UnigramSwumBuilder { Splitter = new CamelIdSplitter() }; var Generator = new SrcMLGenerator(@"..\..\External\SrcML"); var file = Generator.GenerateSrcMLFileFromDirectory(@"..\..\", Path.GetTempFileName(), new List <string>(), Language.Any); functions = from func in file.GetXDocument().Descendants() where _functionTypes.Contains(func.Name) && !func.Ancestors(SRC.Declaration).Any() select func; }
public void TestRoundTrip(string sourceFileName, bool compressOutput) { var sourceFilePath = Path.Combine(TestInputPath, sourceFileName); var srcMLGenerator = new SrcMLGenerator("SrcML"); var dataGenerator = new DataGenerator(); Assert.That(srcMLGenerator.Generate(sourceFilePath, DefaultInputName)); var fileUnit = SrcMLElement.Load(DefaultInputName); var nsd = dataGenerator.Parse(fileUnit) as NamespaceDefinition; XmlSerialization.WriteElement(nsd, DefaultOutputName, compressOutput); var nsdFromFile = XmlSerialization.Load(DefaultOutputName, compressOutput) as NamespaceDefinition; DataAssert.StatementsAreEqual(nsd, nsdFromFile); }
public void TestCppStaticTypeModifier() { var generator = new SrcMLGenerator(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation)); generator.GenerateSrcMLFromFile("external\\TestCppTypeModifiers.cpp", "external_xml\\TestCppStaticModifier.cpp.xml"); var fileUnit = SrcMLElement.Load("external_xml\\TestCppStaticModifier.cpp.xml"); var typeWithStatic = fileUnit.Descendants(SRC.Declaration).LastOrDefault(); Assert.IsNotNull(typeWithStatic); var staticModifier = typeWithStatic.Elements(SRC.Specifier).FirstOrDefault(); Assert.IsNotNull(staticModifier); Assert.AreEqual("static", staticModifier.Value); }
public Src2SrcMLPreviewWindow() { ToggleShowPositionCommand.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Alt)); SelectSrcMLDirectoryCommand.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Alt)); binDirIsValid = true; directorySelector = new System.Windows.Forms.FolderBrowserDialog(); directorySelector.ShowNewFolderButton = false; directorySelector.SelectedPath = SrcMLHelper.GetSrcMLDefaultDirectory(); _language = ABB.SrcML.Language.CPlusPlus; InitializeComponent(); XmlGenerator = new SrcMLGenerator(directorySelector.SelectedPath, _namespaceArguments); }
public void TestCSharpUsingStatement() { var generator = new SrcMLGenerator(TestConstants.SrcmlPath); generator.GenerateSrcMLFromFile("external\\TestCSharpUsingStatement.cs", "external_xml\\TestCSharpUsingStatement.cs.xml"); var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpUsingStatement.cs.xml"); var usingBlock = fileUnit.Elements(SRC.Using).FirstOrDefault(); Assert.IsNotNull(usingBlock); Assert.AreEqual(1, usingBlock.Elements(SRC.Declaration).Count()); Assert.AreEqual(1, usingBlock.Elements(SRC.Block).Count()); }
public void TestCSharpUsingStatement() { var generator = new SrcMLGenerator(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation)); generator.GenerateSrcMLFromFile("external\\TestCSharpUsingStatement.cs", "external_xml\\TestCSharpUsingStatement.cs.xml"); var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpUsingStatement.cs.xml"); var usingBlock = fileUnit.Elements(SRC.Using_Stmt).FirstOrDefault(); Assert.IsNotNull(usingBlock); Assert.AreEqual(1, usingBlock.Elements(SRC.Init).Count()); Assert.AreEqual(1, usingBlock.Elements(SRC.Block).Count()); }
public void TestCppStaticTypeModifier() { var generator = new SrcMLGenerator(TestConstants.SrcmlPath); generator.GenerateSrcMLFromFile("external\\TestCppTypeModifiers.cpp", "external_xml\\TestCppStaticModifier.cpp.xml"); var fileUnit = SrcMLElement.Load("external_xml\\TestCppStaticModifier.cpp.xml"); var typeWithStatic = fileUnit.Descendants(SRC.Type).LastOrDefault(); Assert.IsNotNull(typeWithStatic); var staticModifier = typeWithStatic.Elements(SRC.Specifier).FirstOrDefault(); Assert.IsNotNull(staticModifier); Assert.AreEqual("static", staticModifier.Value); }
public void TestCSharpExpressionWithRemove() { var generator = new SrcMLGenerator(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation)); generator.GenerateSrcMLFromFile("external\\TestCSharpExpressionWithRemove.cs", "external_xml\\TestCSharpExpressionWithRemove.cs.xml"); var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpExpressionWithRemove.cs.xml"); var method = fileUnit.Descendants(SRC.Function).FirstOrDefault(); Assert.IsNotNull(method); var methodBlock = method.Element(SRC.Block); Assert.IsNotNull(methodBlock); Assert.AreEqual(1, methodBlock.Elements(SRC.ExpressionStatement).Count()); }
public void TestCSharpExpressionWithRemove() { var generator = new SrcMLGenerator(TestConstants.SrcmlPath); generator.GenerateSrcMLFromFile("external\\TestCSharpExpressionWithRemove.cs", "external_xml\\TestCSharpExpressionWithRemove.cs.xml"); var fileUnit = SrcMLElement.Load("external_xml\\TestCSharpExpressionWithRemove.cs.xml"); var method = fileUnit.Descendants(SRC.Function).FirstOrDefault(); Assert.IsNotNull(method); var methodBlock = method.Element(SRC.Block); Assert.IsNotNull(methodBlock); Assert.AreEqual(1, methodBlock.Elements(SRC.ExpressionStatement).Count()); }
public void TestRoundTripWithDefaultExtension(string sourceFileName, bool useCompression) { var sourceFilePath = Path.Combine(TestInputPath, sourceFileName); var srcMLGenerator = new SrcMLGenerator("SrcML"); var dataGenerator = new DataGenerator(); Assert.That(srcMLGenerator.Generate(sourceFilePath, DefaultInputName)); var fileUnit = SrcMLElement.Load(DefaultInputName); var nsd = dataGenerator.Parse(fileUnit) as NamespaceDefinition; string outputFileName = Path.ChangeExtension(DefaultOutputName, useCompression ? XmlSerialization.DEFAULT_COMPRESSED_EXTENSION : XmlSerialization.DEFAULT_EXTENSION); XmlSerialization.WriteElement(nsd, outputFileName); var nsdFromFile = XmlSerialization.Load(outputFileName) as NamespaceDefinition; DataAssert.StatementsAreEqual(nsd, nsdFromFile); }
public void TestBadEncoding() { string testCode = @"void Foo()"; var fileName = @"BadPath™.cpp"; var sourceFilePath = Path.Combine(SOURCE_DIRECTORY, fileName); var xmlFilePath = Path.Combine(OUTPUT_DIRECTORY, Path.ChangeExtension(fileName, "xml")); var dataFilePath = Path.ChangeExtension(xmlFilePath, XmlSerialization.DEFAULT_EXTENSION); File.WriteAllText(sourceFilePath, testCode); SrcMLGenerator generator = new SrcMLGenerator("SrcML"); generator.GenerateSrcMLFromFile(sourceFilePath, xmlFilePath, Language.C); var dataGenerator = new DataGenerator(); dataGenerator.Generate(xmlFilePath, dataFilePath); }
private void MenuItemSrcMLSelect_Click(object sender, RoutedEventArgs e) { var currentDirectory = this.directorySelector.SelectedPath; directorySelector.Description = String.Format("Select a directory that contains src2srcml.exe\nThe current directory is {0}", currentDirectory); if (directorySelector.ShowDialog() == Forms.DialogResult.OK) { this._xmlGenerator = new SrcMLGenerator(directorySelector.SelectedPath, _namespaceArguments); binDirIsValid = true; srcmlBox.Foreground = Brushes.Black; UpdateSupportedLanguages(); if (sourceBox.Text.Length > 0) { sourceBox_TextChanged(sender, null); } } }
public void TestSetup() { generator = new SrcMLGenerator(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation)); }
public void FixtureSetUp() { TestUtils.InitializeDefaultExtensionPoints(); generator = new SrcMLGenerator(TestUtils.SrcMLDirectory); }
public static void Src2SrcML([Required(Description = "Source file or directory of source code to convert")] string source, [Optional(null, Description = @"The file to write SrcML to. By default, this is <Current Directory>\<Directory>-<Date>.xml For instance, if you run .\srcml.exe src2srcml c:\source\python, the resulting output file will be located at .\python-YYYMMDDHHMM.xml")] string outputFileName, [Optional("Any", Description = @"Language to use. Only files for this language will be included. The options are * Any (the default: indicates that all recognized languages should be included) * C * C++ * Java * AspectJ")] string language, [Optional("", Description = @"Mapping of file extensions to languages. This is formatted like this: ""/languageMapping:ext1=LANG;ext2=LANG;ext3=LANG"" For example, to map foo.h and foo.cxx to C++, we would use ""/languageMapping:h=C++;cxx=C++"" All of the languages that are valid for the /language option are valid except for ""Any"". ")] string languageMapping, [Optional(null, Description = @"Folder with SrcML binaries. If this is not given, the following directories are checked: 1. %SRCMLBINDIR% 2. c:\Program Files (x86)\SrcML\bin 3. c:\Program Files\SrcML\bin (only checked if c:\Program Files (x86) does not exist) 4. The current directory")] string binaryFolder) { if (null == outputFileName) { var name = source.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries).Last(); outputFileName = String.Format("{0}-{1}.xml", name, DateTime.Now.ToString("yyyyMMddHHmmss")); } SrcMLGenerator generator = null; if (null != binaryFolder) { try { generator = GetGeneratorWithDirectory(binaryFolder); } catch (IOException e) { Console.Error.WriteLine("Invalid binary directory: {0}", e.Message); Environment.Exit(-1); } } else { //try //{ // check all of the usual suspects generator = new SrcMLGenerator(); //} //catch(IOException) //{ // generator = null; //} } Language lang = SrcMLElement.GetLanguageFromString(language); if (lang > Language.Any) { Console.WriteLine("Using {0} language", language); } if (String.Empty != languageMapping) { foreach (var pair in ParseLanguageMap(languageMapping)) { Console.WriteLine("Mapping {0} files to {1} language", pair.Extension, KsuAdapter.GetLanguage(pair.Language)); string ext = pair.Extension.StartsWith(".") ? pair.Extension : "." + pair.Extension; generator.ExtensionMapping.Add(ext, pair.Language); } } SrcMLFile doc; if (Directory.Exists(source)) { doc = generator.GenerateSrcMLFileFromDirectory(source, outputFileName, lang); Console.WriteLine("Created {0}, a srcML archive, from {1} files located at {2}", doc.FileName, doc.FileUnits.Count(), source); } else if (File.Exists(source)) { generator.GenerateSrcMLFromFile(source, outputFileName, lang); Console.WriteLine("Converted {0} to a srcML document at {1}", source, outputFileName); } else { Console.Error.WriteLine("the input folder or directory ({0}) does not exist!", source); Environment.Exit(-2); } }
public void TestSetup() { generator = new SrcMLGenerator(TestConstants.SrcmlPath); }