]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2007, 2011 IBM Corporation and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * IBM Corporation - initial API and implementation | |
10 | *******************************************************************************/ | |
11 | package org.eclipse.jdt.internal.corext.template.java; | |
12 | ||
13 | import org.eclipse.jface.text.templates.TemplateContext; | |
14 | import org.eclipse.jface.text.templates.TemplateVariableResolver; | |
15 | ||
16 | import org.eclipse.jdt.core.IJavaProject; | |
17 | ||
18 | import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; | |
19 | ||
20 | ||
21 | /** | |
22 | * Variable resolver for variable <code>exception_variable_name</code>. Resolves to | |
23 | * an unused exception name. | |
24 | * | |
25 | * @since 3.4 | |
26 | */ | |
27 | public class ExceptionVariableNameResolver extends TemplateVariableResolver { | |
28 | ||
29 | @Override | |
30 | protected String[] resolveAll(TemplateContext context) { | |
31 | if (context instanceof JavaContext) { | |
32 | JavaContext jc= (JavaContext) context; | |
33 | IJavaProject javaProject= jc.getJavaProject(); | |
34 | String exceptionVariableName= StubUtility.getExceptionVariableName(javaProject); | |
35 | return StubUtility.getLocalNameSuggestions(jc.getJavaProject(), exceptionVariableName, 0, jc.computeExcludes()); | |
36 | } | |
37 | return new String[0]; | |
38 | } | |
39 | ||
40 | } |