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
.lang
.properties
;
18 import com
.intellij
.codeInsight
.AnnotationUtil
;
19 import com
.intellij
.lang
.properties
.psi
.impl
.PropertyValueImpl
;
20 import com
.intellij
.patterns
.PsiJavaPatterns
;
21 import static com
.intellij
.patterns
.PsiJavaPatterns
.literalExpression
;
22 import static com
.intellij
.patterns
.PsiJavaPatterns
.psiNameValuePair
;
23 import com
.intellij
.psi
.*;
24 import com
.intellij
.psi
.impl
.source
.resolve
.reference
.impl
.providers
.JavaClassReferenceProvider
;
25 import com
.intellij
.util
.ProcessingContext
;
26 import org
.jetbrains
.annotations
.NotNull
;
31 public class PropertiesReferenceContributor
extends PsiReferenceContributor
{
32 public void registerReferenceProviders(final PsiReferenceRegistrar registrar
) {
33 registrar
.registerReferenceProvider(literalExpression(), new PropertiesReferenceProvider(true));
34 registrar
.registerReferenceProvider(literalExpression().withParent(
35 psiNameValuePair().withName(AnnotationUtil
.PROPERTY_KEY_RESOURCE_BUNDLE_PARAMETER
)),
36 new ResourceBundleReferenceProvider());
38 registrar
.registerReferenceProvider(PsiJavaPatterns
.psiElement(PropertyValueImpl
.class), new PsiReferenceProvider() {
41 public PsiReference
[] getReferencesByElement(@NotNull PsiElement element
, @NotNull ProcessingContext context
) {
42 String text
= element
.getText();
43 String
[] words
= text
.split("\\s");
44 if (words
.length
!= 1) return PsiReference
.EMPTY_ARRAY
;
45 return new JavaClassReferenceProvider(element
.getProject()){
46 public boolean isSoft() {
49 }.getReferencesByString(words
[0], element
, 0);