001    /*
002     * Copyright 2010-2015 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.kotlin.kdoc.parser;
018    
019    import com.intellij.openapi.util.text.StringUtil;
020    
021    public enum KDocKnownTag {
022        AUTHOR(false, false),
023        THROWS(true, false),
024        EXCEPTION(true, false),
025        PARAM(true, false),
026        RETURN(false, false),
027        SEE(true, false),
028        SINCE(false, false),
029        CONSTRUCTOR(false, true),
030        PROPERTY(true, true),
031        SAMPLE(true, false);
032    
033        private final boolean takesReference;
034        private final boolean startsSection;
035    
036        KDocKnownTag(boolean takesReference, boolean startsSection) {
037            this.takesReference = takesReference;
038            this.startsSection = startsSection;
039        }
040    
041        public boolean isReferenceRequired() {
042            return takesReference;
043        }
044    
045        public boolean isSectionStart() {
046            return startsSection;
047        }
048    
049        public static KDocKnownTag findByTagName(CharSequence tagName) {
050            if (StringUtil.startsWith(tagName, "@")) {
051                tagName = tagName.subSequence(1, tagName.length());
052            }
053            try {
054                return valueOf(tagName.toString().toUpperCase());
055            }
056            catch (IllegalArgumentException ignored) {
057            }
058            return null;
059        }
060    }