This commit is contained in:
Alexey Kudravtsev
2016-02-17 18:20:42 +03:00
parent ea14ecc0c0
commit e549fba03e
6 changed files with 53 additions and 15 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -381,7 +381,7 @@ class IntroduceConstantDialog extends DialogWrapper {
}
else {
UIUtil.setEnabled(myVisibilityPanel, true, true);
// exclude all modifiers not visible from all occurences
// exclude all modifiers not visible from all occurrences
final Set<String> visible = new THashSet<String>();
visible.add(PsiModifier.PRIVATE);
visible.add(PsiModifier.PROTECTED);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -16,20 +16,19 @@
package com.intellij.refactoring.ui;
import com.intellij.psi.PsiModifier;
import static com.intellij.util.VisibilityUtil.toPresentableText;
import com.intellij.util.VisibilityUtil;
/**
* @author Konstantin Bulenkov
*/
public class JavaComboBoxVisibilityPanel extends ComboBoxVisibilityPanel<String> implements PsiModifier {
private static final String[] MODIFIERS = {PRIVATE, PACKAGE_LOCAL, PROTECTED, PUBLIC};
public class JavaComboBoxVisibilityPanel extends ComboBoxVisibilityPanel<String> {
private static final String[] MODIFIERS = {PsiModifier.PRIVATE, PsiModifier.PACKAGE_LOCAL, PsiModifier.PROTECTED, PsiModifier.PUBLIC};
private static final String[] PRESENTABLE_NAMES = {
toPresentableText(PRIVATE),
toPresentableText(PACKAGE_LOCAL),
toPresentableText(PROTECTED),
toPresentableText(PUBLIC)
VisibilityUtil.toPresentableText(PsiModifier.PRIVATE),
VisibilityUtil.toPresentableText(PsiModifier.PACKAGE_LOCAL),
VisibilityUtil.toPresentableText(PsiModifier.PROTECTED),
VisibilityUtil.toPresentableText(PsiModifier.PUBLIC)
};
public JavaComboBoxVisibilityPanel() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -17,6 +17,7 @@ package com.intellij.psi.util;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.util.VisibilityUtil;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -317,10 +318,10 @@ public class PsiFormatUtil extends PsiFormatUtilBase {
? list.hasExplicitModifier(PsiModifier.PACKAGE_LOCAL)
: list.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) {
if (element instanceof PsiClass && element.getParent() instanceof PsiDeclarationStatement) {// local class
appendModifier(buffer, PsiBundle.message("local.class.preposition"));
append(buffer, PsiBundle.message("local.class.preposition"));
}
else {
appendModifier(buffer, PsiBundle.visibilityPresentation(PsiModifier.PACKAGE_LOCAL));
appendModifier(buffer, PsiModifier.PACKAGE_LOCAL);
}
}
@@ -356,7 +357,11 @@ public class PsiFormatUtil extends PsiFormatUtilBase {
}
}
private static void appendModifier(final StringBuilder buffer, final String modifier) {
private static void appendModifier(final StringBuilder buffer, @PsiModifier.ModifierConstant @NotNull String modifier) {
append(buffer, VisibilityUtil.toPresentableText(modifier));
}
private static void append(StringBuilder buffer, String modifier) {
appendSpaceIfNeeded(buffer);
buffer.append(modifier);
}
@@ -100,6 +100,8 @@ public class VisibilityUtil {
return PsiModifier.PACKAGE_LOCAL;
}
@NotNull
@NonNls
public static String getVisibilityString(@PsiModifier.ModifierConstant String visibilityModifier) {
if(PsiModifier.PACKAGE_LOCAL.equals(visibilityModifier)) {
return "";
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2016 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.structuralsearch;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
@@ -686,6 +701,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
return element instanceof PsiIdentifier;
}
@NotNull
@Override
public Collection<String> getReservedWords() {
return Collections.singleton(PsiModifier.PACKAGE_LOCAL);
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2016 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.structuralsearch;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
@@ -271,6 +286,7 @@ public abstract class StructuralSearchProfile {
return false;
}
@NotNull
public Collection<String> getReservedWords() {
return Collections.emptySet();
}