mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
move *PresentationProvider to java-psi-impl
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.presentation.java;
|
||||
|
||||
import com.intellij.navigation.ColoredItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentationProvider;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiClassOwner;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class ClassPresentationProvider implements ItemPresentationProvider<PsiClass> {
|
||||
@Override
|
||||
public ItemPresentation getPresentation(final PsiClass psiClass) {
|
||||
return new ColoredItemPresentation() {
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return ClassPresentationUtil.getNameForClass(psiClass, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocationString() {
|
||||
PsiFile file = psiClass.getContainingFile();
|
||||
if (file instanceof PsiClassOwner) {
|
||||
PsiClassOwner classOwner = (PsiClassOwner)file;
|
||||
String packageName = classOwner.getPackageName();
|
||||
if (packageName.length() == 0) return null;
|
||||
return "(" + packageName + ")";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextAttributesKey getTextAttributesKey() {
|
||||
if (psiClass.isDeprecated()) {
|
||||
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(boolean open) {
|
||||
return psiClass.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.presentation.java;
|
||||
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentationProvider;
|
||||
import com.intellij.psi.PsiField;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class FieldPresentationProvider implements ItemPresentationProvider<PsiField> {
|
||||
@Override
|
||||
public ItemPresentation getPresentation(PsiField item) {
|
||||
return JavaPresentationUtil.getFieldPresentation(item);
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.presentation.java;
|
||||
|
||||
import com.intellij.navigation.ColoredItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class JavaPresentationUtil {
|
||||
private JavaPresentationUtil() {
|
||||
}
|
||||
|
||||
public static ColoredItemPresentation getMethodPresentation(final PsiMethod psiMethod) {
|
||||
return new ColoredItemPresentation() {
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return PsiFormatUtil.formatMethod(
|
||||
psiMethod,
|
||||
PsiSubstitutor.EMPTY, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS,
|
||||
PsiFormatUtil.SHOW_TYPE
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextAttributesKey getTextAttributesKey() {
|
||||
if (psiMethod.isDeprecated()) {
|
||||
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocationString() {
|
||||
return getJavaSymbolContainerText(psiMethod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(boolean open) {
|
||||
return psiMethod.getIcon(Iconable.ICON_FLAG_VISIBILITY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static ItemPresentation getFieldPresentation(final PsiField psiField) {
|
||||
return new ColoredItemPresentation() {
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return psiField.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextAttributesKey getTextAttributesKey() {
|
||||
if (psiField.isDeprecated()) {
|
||||
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocationString() {
|
||||
return getJavaSymbolContainerText(psiField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(boolean open) {
|
||||
return psiField.getIcon(Iconable.ICON_FLAG_VISIBILITY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getJavaSymbolContainerText(final PsiElement element) {
|
||||
final String result;
|
||||
PsiElement container = PsiTreeUtil.getParentOfType(element, PsiMember.class, PsiFile.class);
|
||||
|
||||
if (container instanceof PsiClass) {
|
||||
String qName = ((PsiClass)container).getQualifiedName();
|
||||
if (qName != null) {
|
||||
result = qName;
|
||||
}
|
||||
else {
|
||||
result = ((PsiClass)container).getName();
|
||||
}
|
||||
}
|
||||
else if (container instanceof PsiJavaFile) {
|
||||
result = ((PsiJavaFile)container).getPackageName();
|
||||
}
|
||||
else {//TODO: local classes
|
||||
result = null;
|
||||
}
|
||||
if (result != null) {
|
||||
return PsiBundle.message("aux.context.display", result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.presentation.java;
|
||||
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentationProvider;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class MethodPresentationProvider implements ItemPresentationProvider<PsiMethod> {
|
||||
@Override
|
||||
public ItemPresentation getPresentation(PsiMethod item) {
|
||||
return JavaPresentationUtil.getMethodPresentation(item);
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.presentation.java;
|
||||
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentationProvider;
|
||||
import com.intellij.psi.PsiPackage;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
|
||||
public class PackagePresentationProvider implements ItemPresentationProvider<PsiPackage> {
|
||||
@Override
|
||||
public ItemPresentation getPresentation(final PsiPackage aPackage) {
|
||||
return new PresentationData(aPackage.getName(), aPackage.getQualifiedName(), PlatformIcons.PACKAGE_OPEN_ICON, PlatformIcons.PACKAGE_ICON, null);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.presentation.java;
|
||||
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentationProvider;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.PsiVariable;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class VariablePresentationProvider<T extends PsiVariable & NavigationItem> implements ItemPresentationProvider<T> {
|
||||
@Override
|
||||
public ItemPresentation getPresentation(final T variable) {
|
||||
return new ItemPresentation() {
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return PsiFormatUtil.formatVariable(variable, PsiFormatUtilBase.SHOW_TYPE, PsiSubstitutor.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocationString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(boolean open) {
|
||||
return variable.getIcon(Iconable.ICON_FLAG_OPEN);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user