SetFileParser() public method

public SetFileParser ( FileParser p ) : void
p FileParser
return void
示例#1
0
        // Attempt to insert newComponent after refComponent, or at the end if
        // refComponent is null
        // Returns false if failed (refComponent doesn't exist or newComponent already
        // exists in this file).
        public bool InsertComponentAfter(FileComponent refComponent, FileComponent newComponent)
        {
            int i;

            if (refComponent == null)
            {
                i = fileStructure.Count - 1;
            }
            else
            {
                i = fileStructure.IndexOf(refComponent);
                if (i == -1)
                {
                    return(false);
                }
            }

            if (fileStructure.Contains(newComponent))
            {
                return(false);
            }

            if (newComponent is Label)
            {
                AddLabelToDictionaries(newComponent as Label);
            }

            fileStructure.Insert(i + 1, newComponent);
            newComponent.SetFileParser(this);

            Modified = true;

            return(true);
        }
示例#2
0
        // Insert at the beginning if refComponent is null.
        public bool InsertComponentBefore(FileComponent refComponent, FileComponent newComponent, string comment = "")
        {
            int i;

            if (refComponent == null)
            {
                i = 0;
            }
            else
            {
                i = fileStructure.IndexOf(refComponent);
                if (i == -1)
                {
                    return(false);
                }
            }

            if (newComponent is Label)
            {
                AddLabelToDictionaries(newComponent as Label);
            }

            fileStructure.Insert(i, newComponent);
            fileStructureComments.Insert(i, comment);
            newComponent.SetFileParser(this);

            Modified = true;

            return(true);
        }
示例#3
0
        // Insert at the beginning if refComponent is null.
        public bool InsertComponentBefore(FileComponent refComponent, FileComponent newComponent, string comment="")
        {
            int i;
            if (refComponent == null)
                i = 0;
            else {
                i = fileStructure.IndexOf(refComponent);
                if (i == -1)
                    return false;
            }

            if (newComponent is Label) {
                AddLabelToDictionaries(newComponent as Label);
            }

            fileStructure.Insert(i, newComponent);
            fileStructureComments.Insert(i, comment);
            newComponent.SetFileParser(this);

            Modified = true;

            return true;
        }