update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / codeInsight / template / macro / EnumMacro.java
blob75c67333c5774b34915bd19d54d79c2de2a14ed3
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.codeInsight.template.macro;
18 import com.intellij.codeInsight.CodeInsightBundle;
19 import com.intellij.codeInsight.lookup.LookupElement;
20 import com.intellij.codeInsight.lookup.LookupElementBuilder;
21 import com.intellij.codeInsight.template.Expression;
22 import com.intellij.codeInsight.template.ExpressionContext;
23 import com.intellij.codeInsight.template.Macro;
24 import com.intellij.codeInsight.template.Result;
25 import org.jetbrains.annotations.NotNull;
27 import java.util.LinkedHashSet;
28 import java.util.Set;
30 public class EnumMacro implements Macro{
31 public String getName() {
32 return "enum";
35 public String getDescription() {
36 return CodeInsightBundle.message("macro.enum");
39 public String getDefaultValue() {
40 return "";
43 public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) {
44 if (params.length == 0) return null;
45 return params[0].calculateResult(context);
48 public Result calculateQuickResult(@NotNull Expression[] params, ExpressionContext context) {
49 if (params.length == 0) return null;
50 return params[0].calculateQuickResult(context);
53 public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
54 if (params.length ==0) return null;
55 Set<LookupElement> set = new LinkedHashSet<LookupElement>();
57 for (Expression param : params) {
58 Result object = param.calculateResult(context);
59 set.add(LookupElementBuilder.create(object.toString()));
61 return set.toArray(new LookupElement[set.size()]);