Beispiel #1
0
        public void IndexEndTest()
        {
            CCodeFragment  Content = new CCodeFragment(CreateCollection());
            CSyntacticUnit target  = new CSyntacticUnit(Content);

            Assert.AreEqual(43, target.IndexEnd);
        }
Beispiel #2
0
        public void SizeTest()
        {
            CCodeFragment  Content = new CCodeFragment(CreateCollection());
            CSyntacticUnit target  = new CSyntacticUnit(Content);

            Assert.AreEqual(3, target.Size());
        }
Beispiel #3
0
 public void CSourceFileConstructorTest3()
 {
     string        FullPathAndFileName = string.Empty;
     Encoding      file_encoding       = Encoding.GetEncoding(866);
     CCodeFragment _Content            = new CCodeFragment();
     CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);
 }
Beispiel #4
0
        public void LineStartTest()
        {
            CCodeFragment  Content = new CCodeFragment(CreateCollection());
            CSyntacticUnit target  = new CSyntacticUnit(Content);

            Assert.AreEqual(12, target.LineStart);
        }
Beispiel #5
0
        public CSyntacticUnit FromMethodBlock(MethodBlock mb)
        {
            BuildCCodeUnitsCollection(mb);
            CCodeFragment  fragment = new CCodeFragment(code_units_collection);
            CSyntacticUnit unit     = new CSyntacticUnit(fragment);

            return(unit);
        }
Beispiel #6
0
        public void CSourceFileConstructorTest2()
        {
            string        FullPathAndFileName = "somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment();
            CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);

            Assert.IsNotNull(target);
        }
Beispiel #7
0
        public void NameTest()
        {
            string        FullPathAndFileName = "sdfsdf\\sdfsdf\\sdfsdf\\somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment();
            CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);

            Assert.AreEqual("somefile.ext", target.Name);
        }
Beispiel #8
0
        public void SizeTest()
        {
            string        FullPathAndFileName = "somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment(CreateCollection());
            CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);

            Assert.AreEqual(3, target.Size());
        }
Beispiel #9
0
        public void SourceFileIDTest()
        {
            CSourceFileID _FileID             = new CSourceFileID();
            string        FullPathAndFileName = "somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment();
            CSourceFile   target = new CSourceFile(_FileID, FullPathAndFileName, file_encoding, _Content);

            Assert.AreEqual(_FileID.SourceFileID, target.SourceFileID);
        }
Beispiel #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="_FirstFragment"></param>
 /// <param name="_SecondFragment"></param>
 /// <param name="_Similarity"></param>
 public CRelatedCloneFragments(CCodeFragment _FirstFragment, CCodeFragment _SecondFragment, CSimilarity _Similarity)
 {
     if (_FirstFragment == null || _SecondFragment == null || _Similarity == null)
     {
         throw new ArgumentNullException();
     }
     m_FirstFragment  = _FirstFragment;
     m_SecondFragment = _SecondFragment;
     m_Similarity     = _Similarity;
 }
Beispiel #11
0
        public void FileEncodingTest()
        {
            string        FullPathAndFileName = "somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment();
            CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);

            Encoding expected = Encoding.GetEncoding(866);

            Assert.IsTrue(target.FileEncoding.Equals(expected));
        }
Beispiel #12
0
        public void EqualsTest1()
        {
            CCodeFragment target = new CCodeFragment(CreateCollection());
            CCodeFragment other  = new CCodeFragment(CreateCollection());

            Assert.IsFalse(Object.ReferenceEquals(target, other));
            Assert.IsTrue(target.Equals(other));

            other.Content.Add(new CExtendedCodeUnit(new CCodeUnit(new CElementPosition(12, 23), ")"), 1, 1));
            Assert.IsFalse(target.Equals(other));
        }
Beispiel #13
0
        public void IndexEndTest1()
        {
            CCodeFragment target = new CCodeFragment(CreateCollection());

            int expected = 43;

            Assert.AreEqual(expected, target.IndexEnd);

            ++expected;
            target.IndexEnd = expected;
            Assert.AreEqual(expected, target.IndexEnd);
        }
Beispiel #14
0
        public void LineEndTest1()
        {
            CCodeFragment target = new CCodeFragment(CreateCollection());

            long expected = 14;

            Assert.AreEqual(expected, target.LineEnd);

            ++expected;
            target.LineEnd = expected;
            Assert.AreEqual(expected, target.LineEnd);
        }
Beispiel #15
0
        public void IndexStartTest1()
        {
            CCodeFragment target = new CCodeFragment(CreateCollection());

            int expected = 23;

            Assert.AreEqual(expected, target.IndexStart);

            --expected;
            target.IndexStart = expected;
            Assert.AreEqual(expected, target.IndexStart);
        }
Beispiel #16
0
        public void LineStartTest1()
        {
            CCodeFragment target = new CCodeFragment(CreateCollection());

            long expected = 12;

            Assert.AreEqual(expected, target.LineStart);

            --expected;
            target.LineStart = expected;
            Assert.AreEqual(expected, target.LineStart);
        }
Beispiel #17
0
        public void FilePathTest()
        {
            string        FullPath      = "dfgdfgdfg\\dfgdfg\\dfgdfg\\";
            Encoding      file_encoding = Encoding.GetEncoding(866);
            CCodeFragment _Content      = new CCodeFragment();
            CSourceFile   target        = new CSourceFile(FullPath + "somefile.ext", file_encoding, _Content);

            Assert.AreEqual(FullPath, target.FilePath);

            FullPath        = "dfsdfsdfsd\\fgdfgdfg\\tyryrt";
            target.FilePath = FullPath;
            Assert.AreEqual(FullPath, target.FilePath);
        }
Beispiel #18
0
        public void ContentTest()
        {
            CCodeUnitsCollection _Content = new CCodeUnitsCollection();
            CCodeFragment        target   = new CCodeFragment(_Content);

            Assert.AreEqual(target.Content.Size(), 0);

            _Content = new CCodeUnitsCollection();
            _Content.Add(new CExtendedCodeUnit(new CCodeUnit(new CElementPosition(12, 23), ")"), 1, 1));
            _Content.Add(new CExtendedCodeUnit(new CCodeUnit(new CElementPosition(12, 33), ")"), 1, 1));
            target.Content = _Content;
            Assert.AreEqual(target.Content.Size(), 2);
        }
Beispiel #19
0
        public void IsBelongOneLineTest1()
        {
            CCodeFragment target = new CCodeFragment(CreateCollection());

            Assert.IsFalse(target.IsBelongOneLine());

            CCodeUnitsCollection _Content = new CCodeUnitsCollection();

            _Content.Add(new CExtendedCodeUnit(new CCodeUnit(new CElementPosition(12, 23), ")"), 1, 1));
            _Content.Add(new CExtendedCodeUnit(new CCodeUnit(new CElementPosition(12, 33), ")"), 1, 1));

            target = new CCodeFragment(_Content);
            Assert.IsTrue(target.IsBelongOneLine());
        }
Beispiel #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_FileID"></param>
        /// <param name="FullPathAndFileName"></param>
        /// <param name="file_encoding"></param>
        /// <param name="_Content"></param>
        public CSourceFile(CSourceFileID _FileID, string FullPathAndFileName, Encoding file_encoding, CCodeFragment _Content)
        {
            m_SourceFileID = _FileID;
            m_FileEncoding = file_encoding;
            m_Content      = _Content;

            if (!String.IsNullOrEmpty(FullPathAndFileName))
            {
                SetPathAndFileNameFromString(FullPathAndFileName);
            }
            else
            {
                throw new ArgumentNullException("FullPathAndFileName");
            }
        }
Beispiel #21
0
        private void PrepareLoadFilesOptions()
        {
            ICloneExtension     Ext              = ChooseLangComboBox.SelectedItem as ICloneExtension;
            CICloneEncodingInfo EncodeInfo       = CodeEncodingComboBox.SelectedItem as CICloneEncodingInfo;
            CLoadFilesOptions   LoadFilesOptions = new CLoadFilesOptions(CodeLocationTextBox.Text, ChoosenFilesExtensionsTextBox.Text, EncodeInfo.GetEncodingInfo().GetEncoding(), new CCodePreProcessingOptions(Ext.GetCommentSymbols()));

            LoadFilesOptions.SetSkippingFolders(Properties.Settings.Default.CSWSkippingFolders);
            LoadFilesOptions.SetIsUseParallelExtensions(Properties.Settings.Default.CSWIsUseParallelExtensions);

            m_CloneSearchExecutor.SetLoadFilesOptions(LoadFilesOptions);
            if (AutomaticKminCalculationCheckBox.Checked)
            {
                CCodeSizeDetector Counter = new CCodeSizeDetector(Ext.LanguageID(), new CLoadFilesOptions(CodeLocationTextBox.Text, ChoosenFilesExtensionsTextBox.Text));
                //Counter.LoadFilesProgress += new EventHandler(ReportProgress);
                CSyntacticInfo info = Counter.Calculate();
                CCodeFragment.SetKmin(info.Kmin);
            }
            else
            {
                CCodeFragment.SetKmin((long)KminValue.Value);
            }
            m_CloneSearchExecutor.Extension = Ext;
        }
Beispiel #22
0
        public override CCodeFragment get_type_interface_init_declaration()
        {
            var frag = new CCodeFragment();

            foreach (DataType base_type in class_reference.get_base_types())
            {
                if (!(base_type.data_type is Interface))
                {
                    continue;
                }

                var iface = (Interface)base_type.data_type;

                var iface_info_name = "%s_info".printf(CCodeBaseModule.get_ccode_lower_case_name(iface, null));

                var ctypedecl = new CCodeDeclaration("const GInterfaceInfo");
                ctypedecl.modifiers = CCodeModifiers.STATIC;
                ctypedecl.add_declarator(new CCodeVariableDeclarator(iface_info_name, new CCodeConstant("{ (GInterfaceInitFunc) %s_%s_interface_init, (GInterfaceFinalizeFunc) NULL, NULL}".printf(CCodeBaseModule.get_ccode_lower_case_name(class_reference), CCodeBaseModule.get_ccode_lower_case_name(iface)))));
                frag.append(ctypedecl);
            }

            return(frag);
        }
Beispiel #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="_Content"></param>
 public CSyntacticUnit(CCodeFragment _Content)
 {
     m_Content = _Content;
 }
Beispiel #24
0
 public void IsBelongOneLineTest2()
 {
     CCodeUnitsCollection _Content = new CCodeUnitsCollection();
     CCodeFragment        target   = new CCodeFragment(_Content);
     bool actual = target.IsBelongOneLine();
 }
Beispiel #25
0
 public void IndexEndTest2()
 {
     CCodeUnitsCollection _Content = new CCodeUnitsCollection();
     CCodeFragment        target   = new CCodeFragment(_Content);
     int actual = target.IndexEnd;
 }
Beispiel #26
0
        public void CCodeFragmentConstructorTest()
        {
            CCodeFragment target = new CCodeFragment(CreateCollection());

            Assert.IsNotNull(target);
        }
Beispiel #27
0
 public void LineStartTest2()
 {
     CCodeUnitsCollection _Content = new CCodeUnitsCollection();
     CCodeFragment        target   = new CCodeFragment(_Content);
     long actual = target.LineStart;
 }
Beispiel #28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="FullPathAndFileName">Полный путь к файлу, включая имя файла</param>
 /// <param name="file_encoding">Кодировка файла</param>
 /// <param name="_Content"></param>
 public CSourceFile(string FullPathAndFileName, Encoding file_encoding, CCodeFragment _Content)
     : this(new CSourceFileID(), FullPathAndFileName, file_encoding, _Content)
 {
 }