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 SUPPRESS(false, false);
033
034 private final boolean takesReference;
035 private final boolean startsSection;
036
037 KDocKnownTag(boolean takesReference, boolean startsSection) {
038 this.takesReference = takesReference;
039 this.startsSection = startsSection;
040 }
041
042 public boolean isReferenceRequired() {
043 return takesReference;
044 }
045
046 public boolean isSectionStart() {
047 return startsSection;
048 }
049
050 public static KDocKnownTag findByTagName(CharSequence tagName) {
051 if (StringUtil.startsWith(tagName, "@")) {
052 tagName = tagName.subSequence(1, tagName.length());
053 }
054 try {
055 return valueOf(tagName.toString().toUpperCase());
056 }
057 catch (IllegalArgumentException ignored) {
058 }
059 return null;
060 }
061 }