Exemplo n.º 1
0
        /// <summary>
        /// This version of GetModifiersFromEnum checks to see if the internal keyword was actually
        /// in the user's code, and if it wasn't it removes it from the list of modifiers returned.
        /// </summary>
        /// <param name="typeDef">The type definition we are getting the list of modifiers for.</param>
        /// <param name="doc">The document that holds the original code.</param>
        /// <returns>A list of the modifiers on the given type declaration, in string form.</returns>
        internal static IEnumerable <string> GetModifiersFromEnumCheckInternal(TypeMemberDeclaration typeDef, Document doc)
        {
            Modifiers modifiers = typeDef.Modifiers;

            if ((modifiers & Modifiers.Assembly) != 0)
            {
                // Search for the internal modifier in the document.
                IToken startToken = doc.Tokens.GetTokenAtOffset(typeDef.StartOffset);
                IToken endToken   = doc.Tokens.GetTokenAtOffset(typeDef.EndOffset);

                TokenStream stream = doc.GetTokenStream(startToken);
                while (startToken != endToken && startToken != null)
                {
                    if (startToken.ID == CSharpTokenID.Internal)
                    {
                        return(GetModifiersFromEnum(modifiers));
                    }
                    startToken = stream.Read();
                }

                // Remove the internal modifier
                modifiers = (modifiers & ~Modifiers.Assembly);
            }
            IEnumerable <string> mods = GetModifiersFromEnum(modifiers);

            return(mods);
        }
Exemplo n.º 2
0
 /**
  * Call back method that must be called as soon as the given <code>
  * TypeMemberDeclaration</code> object has been traversed.
  *
  * @param pTypeMemberDeclaration  The <code>TypeMemberDeclaration</code>
  *                                object that has just been traversed.
  */
 public void actionPerformed(
      
     TypeMemberDeclaration pTypeMemberDeclaration)
 {
     // Nothing to do.
 }
Exemplo n.º 3
0
 /**
  * Call back method that must be called when the given <code>
  * TypeMemberDeclaration</code> will become the next <i>traverse
  * candidate</i>.
  *
  * @param pTypeMemberDeclaration  The <code>TypeMemberDeclaration</code>
  *                                object that will become the next <i>
  *                                traverse candidate</i>.
  */
 public void performAction(
      
     TypeMemberDeclaration pTypeMemberDeclaration)
 {
     // Nothing to do.
 }
        /**
         * Removes a certain type member declaration from <code>this</code>.
         *
         * @param pTypeMemberDeclaration
         *            The type member declaration that should be removed. The
         *            argument passed to this method remains unchanged.
         * @param pRemovingOfSurroundingHiddenTokensEnabled
         *            If <code>true</code> the method also tries to remove
         *            surrounding whitespaces and comments that most likely belongs
         *            to the type member declaration.
         *
         * @
         *             if the type member declaration passed to this method doesn't
         *             belong to <code>this</code>.
         *
         * __TEST__
         */
        public void removeTypeMemberDeclaration(
            TypeMemberDeclaration pTypeMemberDeclaration,
            bool pRemovingOfSurroundingHiddenTokensEnabled)
        {
            AST2TypeMemberDeclaration removedMember = null;
            if (mFieldDeclarations != null)
            {
                int offset = mFieldDeclarations.IndexOf((AST2TypeMemberDeclaration)pTypeMemberDeclaration);
                if (offset != -1)
                {
                    removedMember = mFieldDeclarations[offset];
                    mFieldDeclarations.RemoveAt(offset);
                }
            }
            if (removedMember == null)
            {
                // The stated type member declaration doesn't belong to 'this'.
                throw new JSourceObjectizerException(CommonJSOMMessages
                        .getTypeMemberDeclarationDoesNotExistMessage(
                                pTypeMemberDeclaration.getJSOMType().ToString()
                                        + " ("
                                        + pTypeMemberDeclaration.getLineNumber()
                                        + ':'
                                        + pTypeMemberDeclaration.getCharPositionInLine() + ")",
                                getLineNumber() + ":" + getCharPositionInLine()));
            }
            // If still here a matching type declaration has been found.
            if (pRemovingOfSurroundingHiddenTokensEnabled)
            {
                removeTreeNode(removedMember,
                        ChangeTokenBorder.FARTHEST_NEWLINE_EXCLUDING,
                        ChangeTokenBorder.NEXT_NEWLINE_INCLUDING);

            }
            else
            {
                removeTreeNode(removedMember);
            }
            if (mFieldDeclarations.Count == 0)
            {
                mFieldDeclarations = null;
            }
        }
 /**
  * Removes a certain type member declaration from <code>this</code>.
  * <p>
  * Calling this method equals an <code>
  * removeTypeMemberDeclaration(TypeMemberDeclaration, true)</code>
  * call.
  *
  * @param pTypeMemberDeclaration
  *            The type member declaration that should be removed. The
  *            argument passed to this method remains unchanged.
  *
  * @
  *             if the type member declaration passed to this method doesn't
  *             belong to <code>this</code>.
  *
  * __TEST__
  */
 public void removeTypeMemberDeclaration(TypeMemberDeclaration pTypeMemberDeclaration)
 {
     removeTypeMemberDeclaration(pTypeMemberDeclaration, false);
 }
Exemplo n.º 6
0
        private void Process_Enum_Declaration(TypeMemberDeclaration node)
        {
            if (node == null)
                throw new ArgumentNullException("node");
            Enumeration enu = new Enumeration(controller);
            enu.Modifiers.AddRange(FormatterUtility.GetModifiersFromEnum(node.Modifiers));
            enu.Name = node.Name.Text;

            SetupBaseConstruct(node, enu);
        }
Exemplo n.º 7
0
 private void SetupBaseConstruct(TypeMemberDeclaration node, BaseConstruct inter)
 {
     inter.Index = node.StartOffset;
     inter.TextRange = new TextRange(node.TextRange.StartOffset, node.TextRange.EndOffset);
     SetDocumentation(inter, node.DocumentationProvider.Documentation);
     AddToParentAndStack(inter);
     SetAttributes(inter, node.AttributeSections);
     baseConstructs.Add(node.StartOffset, inter);
     //inter.PreceedingBlankLines = FindPreviousBlankLines(node.StartOffset);
 }
Exemplo n.º 8
0
        private void Process_Structure_Declaration(TypeMemberDeclaration node)
        {
            if (node == null) throw new ArgumentNullException("node");

            Struct str = new Struct(controller);
            str.Name = node.Name.Text;
            str.Modifiers.AddRange(FormatterUtility.GetModifiersFromEnum(node.Modifiers));

            SetupBaseConstruct(node, str);
        }
Exemplo n.º 9
0
        private void Process_Interface_Declaration(TypeMemberDeclaration node)
        {
            if (node == null)
                throw new ArgumentNullException("node");
            Interface inter = new Interface(controller, node.Name.Text);
            inter.Modifiers.AddRange(FormatterUtility.GetModifiersFromEnum(node.Modifiers));

            SetupBaseConstruct(node, inter);
        }