mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -66,14 +66,16 @@ public class LossyEncodingInspection extends BaseJavaLocalInspectionTool {
|
||||
if (virtualFile == null) return null;
|
||||
String text = file.getText();
|
||||
Charset charset = LoadTextUtil.extractCharsetFromFileContent(file.getProject(), virtualFile, text);
|
||||
charset = Native2AsciiCharset.nativeToBaseCharset(charset);
|
||||
|
||||
// no sense in checking transparently decoded file: all characters there are already safely encoded
|
||||
if (charset instanceof Native2AsciiCharset) return null;
|
||||
|
||||
int errorCount = 0;
|
||||
int start = -1;
|
||||
List<ProblemDescriptor> descriptors = new SmartList<ProblemDescriptor>();
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
if (isRepresentable(c, charset)) {
|
||||
for (int i = 0; i <= text.length(); i++) {
|
||||
char c = i == text.length() ? 0 : text.charAt(i);
|
||||
if (i == text.length() || isRepresentable(c, charset)) {
|
||||
if (start != -1) {
|
||||
ProblemDescriptor descriptor = manager.createProblemDescriptor(file, new TextRange(start, i), InspectionsBundle.message(
|
||||
"unsupported.character.for.the.charset", charset), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
|
||||
@@ -90,11 +92,6 @@ public class LossyEncodingInspection extends BaseJavaLocalInspectionTool {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (start != -1) {
|
||||
ProblemDescriptor descriptor = manager.createProblemDescriptor(file, new TextRange(start, text.length()), InspectionsBundle.message(
|
||||
"unsupported.character.for.the.charset", charset), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
|
||||
descriptors.add(descriptor);
|
||||
}
|
||||
|
||||
return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ package com.intellij.psi.impl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.UserDataHolderEx;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.filters.OrFilter;
|
||||
@@ -972,6 +969,12 @@ public class PsiClassImplUtil {
|
||||
else {
|
||||
PsiClass class1 = ((PsiClassType)type1).resolve();
|
||||
PsiClass class2 = ((PsiClassType)type2).resolve();
|
||||
|
||||
if (class1 instanceof PsiTypeParameter && class2 instanceof PsiTypeParameter) {
|
||||
return Comparing.equal(class1.getName(), class2.getName()) &&
|
||||
((PsiTypeParameter)class1).getIndex() == ((PsiTypeParameter)class2).getIndex();
|
||||
}
|
||||
|
||||
if (!manager.areElementsEquivalent(class1, class2)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class PsiSuperMethodImplUtil {
|
||||
final PsiSubstitutor superSubstitutor = superTypeResolveResult.getSubstitutor();
|
||||
PsiSubstitutor finalSubstitutor = obtainFinalSubstitutor(superClass, superSubstitutor, substitutor);
|
||||
|
||||
final boolean isInRawContextSuper = isInRawContext || PsiUtil.isRawSubstitutor(superClass, superSubstitutor);
|
||||
final boolean isInRawContextSuper = (isInRawContext || PsiUtil.isRawSubstitutor(superClass, superSubstitutor)) && superClass.getTypeParameters().length != 0;
|
||||
Map<MethodSignature, HierarchicalMethodSignature> superResult = buildMethodHierarchy(superClass, finalSubstitutor, false, visited, isInRawContextSuper);
|
||||
visited.remove(superClass);
|
||||
|
||||
|
||||
+29
-3
@@ -26,6 +26,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
@@ -182,11 +183,16 @@ public class ChangeSignatureProcessor extends BaseRefactoringProcessor {
|
||||
result.add(new UsageInfo(ref.getElement()));
|
||||
}
|
||||
else if (element instanceof PsiMethod && ((PsiMethod)element).isConstructor()) {
|
||||
DefaultConstructorImplicitUsageInfo implicitUsageInfo = new DefaultConstructorImplicitUsageInfo((PsiMethod)element, method);
|
||||
DefaultConstructorImplicitUsageInfo implicitUsageInfo = new DefaultConstructorImplicitUsageInfo((PsiMethod)element,
|
||||
((PsiMethod)element).getContainingClass(), method);
|
||||
result.add(implicitUsageInfo);
|
||||
}
|
||||
else if(element instanceof PsiClass) {
|
||||
result.add(new NoConstructorClassUsageInfo((PsiClass)element));
|
||||
LOG.assertTrue(method.isConstructor());
|
||||
final PsiClass psiClass = (PsiClass)element;
|
||||
if (shouldPropagateToNonPhysicalMethod(method, result, psiClass, myPropagateParametersMethods)) continue;
|
||||
if (shouldPropagateToNonPhysicalMethod(method, result, psiClass, myPropagateExceptionsMethods)) continue;
|
||||
result.add(new NoConstructorClassUsageInfo(psiClass));
|
||||
}
|
||||
else if (ref instanceof PsiCallReference) {
|
||||
result.add(new CallReferenceUsageInfo((PsiCallReference) ref));
|
||||
@@ -223,6 +229,16 @@ public class ChangeSignatureProcessor extends BaseRefactoringProcessor {
|
||||
return overridingMethods;
|
||||
}
|
||||
|
||||
private static boolean shouldPropagateToNonPhysicalMethod(PsiMethod method, ArrayList<UsageInfo> result, PsiClass containingClass, final Set<PsiMethod> propagateMethods) {
|
||||
for (PsiMethod psiMethod : propagateMethods) {
|
||||
if (!psiMethod.isPhysical() && Comparing.strEqual(psiMethod.getName(), containingClass.getName())) {
|
||||
result.add(new DefaultConstructorImplicitUsageInfo(psiMethod, containingClass, method));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void findUsagesInCallers(final ArrayList<UsageInfo> usages) {
|
||||
for (PsiMethod caller : myPropagateParametersMethods) {
|
||||
usages.add(new CallerUsageInfo(caller, true, myPropagateExceptionsMethods.contains(caller)));
|
||||
@@ -512,7 +528,17 @@ public class ChangeSignatureProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
if (usage instanceof DefaultConstructorImplicitUsageInfo) {
|
||||
final DefaultConstructorImplicitUsageInfo defConstructorUsage = (DefaultConstructorImplicitUsageInfo)usage;
|
||||
addSuperCall(defConstructorUsage.getConstructor(), defConstructorUsage.getBaseConstructor(),usages);
|
||||
PsiMethod constructor = defConstructorUsage.getConstructor();
|
||||
if (!constructor.isPhysical()) {
|
||||
final boolean toPropagate = myPropagateParametersMethods.remove(constructor);
|
||||
final PsiClass containingClass = defConstructorUsage.getContainingClass();
|
||||
constructor = (PsiMethod)containingClass.add(constructor);
|
||||
PsiUtil.setModifierProperty(constructor, VisibilityUtil.getVisibilityModifier(containingClass.getModifierList()), true);
|
||||
if (toPropagate) {
|
||||
myPropagateParametersMethods.add(constructor);
|
||||
}
|
||||
}
|
||||
addSuperCall(constructor, defConstructorUsage.getBaseConstructor(),usages);
|
||||
}
|
||||
else if (usage instanceof NoConstructorClassUsageInfo) {
|
||||
addDefaultConstructor(((NoConstructorClassUsageInfo)usage).getPsiClass(),usages);
|
||||
|
||||
+7
-4
@@ -136,7 +136,7 @@ public abstract class CallerChooser extends DialogWrapper {
|
||||
|
||||
final PsiMethod caller = node.getMethod();
|
||||
final PsiMethod callee = parentNode != null ? parentNode.getMethod() : null;
|
||||
if (caller != null && callee != null) {
|
||||
if (caller != null && caller.isPhysical() && callee != null) {
|
||||
HighlightManager highlighter = HighlightManager.getInstance(myProject);
|
||||
EditorColorsManager colorManager = EditorColorsManager.getInstance();
|
||||
TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
|
||||
@@ -162,9 +162,12 @@ public abstract class CallerChooser extends DialogWrapper {
|
||||
if (method == null) return "";
|
||||
final PsiFile file = method.getContainingFile();
|
||||
Document document = PsiDocumentManager.getInstance(myProject).getDocument(file);
|
||||
final int start = document.getLineStartOffset(document.getLineNumber(method.getTextRange().getStartOffset()));
|
||||
final int end = document.getLineEndOffset(document.getLineNumber(method.getTextRange().getEndOffset()));
|
||||
return document.getText().substring(start, end);
|
||||
if (document != null) {
|
||||
final int start = document.getLineStartOffset(document.getLineNumber(method.getTextRange().getStartOffset()));
|
||||
final int end = document.getLineEndOffset(document.getLineNumber(method.getTextRange().getEndOffset()));
|
||||
return document.getText().substring(start, end);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private int getStartOffset (@NotNull final PsiMethod method) {
|
||||
|
||||
+7
-2
@@ -103,6 +103,9 @@ public class MethodNode extends CheckedTreeNode {
|
||||
if (enclosingContext instanceof PsiMethod &&
|
||||
!myMethod.equals(enclosingContext) && !myCalled.contains(myMethod)) { //do not add recursive methods
|
||||
callers.add((PsiMethod) enclosingContext);
|
||||
} else if (element instanceof PsiClass) {
|
||||
final PsiClass aClass = (PsiClass)element;
|
||||
callers.add(JavaPsiFacade.getElementFactory(project).createMethodFromText(aClass.getName() + "(){}", aClass));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,8 +140,10 @@ public class MethodNode extends CheckedTreeNode {
|
||||
SimpleTextAttributes.EXCLUDED_ATTRIBUTES;
|
||||
renderer.append(buffer.toString(), attributes);
|
||||
|
||||
final String packageName = getPackageName(myMethod.getContainingClass());
|
||||
renderer.append(" (" + packageName + ")", new SimpleTextAttributes(SimpleTextAttributes.STYLE_ITALIC, Color.GRAY));
|
||||
if (containingClass != null) {
|
||||
final String packageName = getPackageName(containingClass);
|
||||
renderer.append(" (" + packageName + ")", new SimpleTextAttributes(SimpleTextAttributes.STYLE_ITALIC, Color.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
|
||||
PsiElement ref = ref1.getElement();
|
||||
if (ref instanceof PsiMethod && ((PsiMethod)ref).isConstructor()) {
|
||||
DefaultConstructorImplicitUsageInfo implicitUsageInfo =
|
||||
new DefaultConstructorImplicitUsageInfo((PsiMethod)ref, myMethodToSearchFor);
|
||||
new DefaultConstructorImplicitUsageInfo((PsiMethod)ref, ((PsiMethod)ref).getContainingClass(), myMethodToSearchFor);
|
||||
result.add(implicitUsageInfo);
|
||||
}
|
||||
else if (ref instanceof PsiClass) {
|
||||
|
||||
+7
-1
@@ -23,11 +23,13 @@ import com.intellij.usageView.UsageInfo;
|
||||
*/
|
||||
public class DefaultConstructorImplicitUsageInfo extends UsageInfo {
|
||||
private final PsiMethod myOverridingConstructor;
|
||||
private final PsiClass myContainingClass;
|
||||
private final PsiMethod myBaseConstructor;
|
||||
|
||||
public DefaultConstructorImplicitUsageInfo(PsiMethod overridingConstructor, PsiMethod baseConstructor) {
|
||||
public DefaultConstructorImplicitUsageInfo(PsiMethod overridingConstructor, PsiClass containingClass, PsiMethod baseConstructor) {
|
||||
super(overridingConstructor);
|
||||
myOverridingConstructor = overridingConstructor;
|
||||
myContainingClass = containingClass;
|
||||
myBaseConstructor = baseConstructor;
|
||||
}
|
||||
|
||||
@@ -38,4 +40,8 @@ public class DefaultConstructorImplicitUsageInfo extends UsageInfo {
|
||||
public PsiMethod getBaseConstructor() {
|
||||
return myBaseConstructor;
|
||||
}
|
||||
|
||||
public PsiClass getContainingClass() {
|
||||
return myContainingClass;
|
||||
}
|
||||
}
|
||||
|
||||
-38
@@ -1,38 +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.refactoring.util.usageInfo;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DefaultConstructorUsageCollector implements RefactoringUtil.ImplicitConstructorUsageVisitor {
|
||||
private final ArrayList<UsageInfo> myUsages;
|
||||
|
||||
public void visitConstructor(PsiMethod constructor, PsiMethod baseConstructor) {
|
||||
myUsages.add(new DefaultConstructorImplicitUsageInfo(constructor, baseConstructor));
|
||||
}
|
||||
|
||||
public void visitClassWithoutConstructors(PsiClass aClass) {
|
||||
myUsages.add(new NoConstructorClassUsageInfo(aClass));
|
||||
}
|
||||
|
||||
public DefaultConstructorUsageCollector(ArrayList<UsageInfo> result) {
|
||||
myUsages = result;
|
||||
}
|
||||
}
|
||||
@@ -83,9 +83,8 @@ public class SliceHandler implements CodeInsightActionHandler {
|
||||
dialog.show();
|
||||
if (!dialog.isOK()) return null;
|
||||
|
||||
storedSettingsBean.analysisUIOptions.save(analysisUIOptions);
|
||||
|
||||
AnalysisScope scope = dialog.getScope(analysisUIOptions, analysisScope, myProject, module);
|
||||
storedSettingsBean.analysisUIOptions.save(analysisUIOptions);
|
||||
|
||||
SliceAnalysisParams params = new SliceAnalysisParams();
|
||||
params.scope = scope;
|
||||
|
||||
@@ -28,16 +28,14 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.PairProcessor;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* User: cdr
|
||||
@@ -67,7 +65,14 @@ public class SliceNullnessAnalyzer {
|
||||
public SliceNode fun(SliceNode oldNode) {
|
||||
return oldNode.getDuplicate() == null && node(oldNode, map).nulls.contains(nullExpression) ? oldNode.copy() : null;
|
||||
}
|
||||
},null);
|
||||
},new PairProcessor<SliceNode, List<SliceNode>>() {
|
||||
public boolean process(SliceNode node, List<SliceNode> children) {
|
||||
if (!children.isEmpty()) return true;
|
||||
PsiElement element = node.getValue().getElement();
|
||||
if (element == null) return false;
|
||||
return element.getManager().areElementsEquivalent(element, nullExpression); // leaf can be there only if it's filtering expression
|
||||
}
|
||||
});
|
||||
nullRoot.myCachedChildren.add(new SliceLeafValueRootNode(root.getProject(), nullExpression, nullRoot, Collections.singletonList(newRoot),
|
||||
oldRoot.getValue().params));
|
||||
}
|
||||
@@ -81,7 +86,14 @@ public class SliceNullnessAnalyzer {
|
||||
public SliceNode fun(SliceNode oldNode) {
|
||||
return oldNode.getDuplicate() == null && node(oldNode, map).notNulls.contains(expression) ? oldNode.copy() : null;
|
||||
}
|
||||
},null);
|
||||
},new PairProcessor<SliceNode, List<SliceNode>>() {
|
||||
public boolean process(SliceNode node, List<SliceNode> children) {
|
||||
if (!children.isEmpty()) return true;
|
||||
PsiElement element = node.getValue().getElement();
|
||||
if (element == null) return false;
|
||||
return element.getManager().areElementsEquivalent(element, expression); // leaf can be there only if it's filtering expression
|
||||
}
|
||||
});
|
||||
valueRoot.myCachedChildren.add(new SliceLeafValueRootNode(root.getProject(), expression, valueRoot, Collections.singletonList(newRoot),
|
||||
oldRoot.getValue().params));
|
||||
}
|
||||
@@ -95,7 +107,14 @@ public class SliceNullnessAnalyzer {
|
||||
public SliceNode fun(SliceNode oldNode) {
|
||||
return oldNode.getDuplicate() == null && node(oldNode, map).unknown.contains(expression) ? oldNode.copy() : null;
|
||||
}
|
||||
},null);
|
||||
},new PairProcessor<SliceNode, List<SliceNode>>() {
|
||||
public boolean process(SliceNode node, List<SliceNode> children) {
|
||||
if (!children.isEmpty()) return true;
|
||||
PsiElement element = node.getValue().getElement();
|
||||
if (element == null) return false;
|
||||
return element.getManager().areElementsEquivalent(element, expression); // leaf can be there only if it's filtering expression
|
||||
}
|
||||
});
|
||||
valueRoot.myCachedChildren.add(new SliceLeafValueRootNode(root.getProject(), expression, valueRoot, Collections.singletonList(newRoot),
|
||||
oldRoot.getValue().params));
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class P {
|
||||
public P<caret>() {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
public PP(){
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class P {
|
||||
public P() throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
public PP() throws Exception {
|
||||
super();
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class P {
|
||||
public P<caret>() {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class P {
|
||||
public P() throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
PP() throws Exception {
|
||||
super();
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class P {
|
||||
public P<caret>() {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
public PP(){
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class P {
|
||||
public P(Class clazz) {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
public PP(Class clazz){
|
||||
super(clazz);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
public class P {
|
||||
public P<caret>() {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
public PP(){
|
||||
}
|
||||
}
|
||||
|
||||
class PPP extends P {
|
||||
public PPP(){
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
public class P {
|
||||
public P(Class clazz) {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
public PP(Class clazz){
|
||||
super(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
class PPP extends P {
|
||||
public PPP(Class clazz){
|
||||
super(clazz);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class P {
|
||||
public P<caret>() {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class P {
|
||||
public P(Class clazz) {
|
||||
}
|
||||
}
|
||||
|
||||
class PP extends P {
|
||||
PP(Class clazz) {
|
||||
super(clazz);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.intellij.testFramework.PlatformTestCase;
|
||||
public class ModulePointerTest extends PlatformTestCase {
|
||||
public void testCreateByName() throws Exception {
|
||||
final ModulePointer pointer = getPointerManager().create("m");
|
||||
assertSame(pointer, getPointerManager().create("m"));
|
||||
assertNull(pointer.getModule());
|
||||
assertEquals("m", pointer.getModuleName());
|
||||
|
||||
@@ -39,6 +40,8 @@ public class ModulePointerTest extends PlatformTestCase {
|
||||
public void testCreateByModule() throws Exception {
|
||||
final Module module = addModule("x");
|
||||
final ModulePointer pointer = getPointerManager().create(module);
|
||||
assertSame(pointer, getPointerManager().create(module));
|
||||
assertSame(pointer, getPointerManager().create("x"));
|
||||
assertSame(module, pointer.getModule());
|
||||
assertEquals("x", pointer.getModuleName());
|
||||
|
||||
@@ -48,6 +51,9 @@ public class ModulePointerTest extends PlatformTestCase {
|
||||
|
||||
assertNull(pointer.getModule());
|
||||
assertEquals("x", pointer.getModuleName());
|
||||
|
||||
final Module newModule = addModule("x");
|
||||
assertSame(pointer, getPointerManager().create(newModule));
|
||||
}
|
||||
|
||||
public void testRenameModule() throws Exception {
|
||||
@@ -61,9 +67,12 @@ public class ModulePointerTest extends PlatformTestCase {
|
||||
}
|
||||
|
||||
public void testDisposePointerFromUncommitedModifiableModel() throws Exception {
|
||||
final ModulePointer pointer = getPointerManager().create("xxx");
|
||||
|
||||
final ModifiableModuleModel modifiableModel = getModuleManager().getModifiableModel();
|
||||
final Module module = modifiableModel.newModule(myProject.getBaseDir().getPath() + "/xxx.iml", EmptyModuleType.getInstance());
|
||||
final ModulePointer pointer = getPointerManager().create(module);
|
||||
assertSame(pointer, getPointerManager().create(module));
|
||||
assertSame(pointer, getPointerManager().create("xxx"));
|
||||
|
||||
assertSame(module, pointer.getModule());
|
||||
assertEquals("xxx", pointer.getModuleName());
|
||||
|
||||
+60
-7
@@ -4,12 +4,15 @@ import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.MethodReferencesSearch;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
|
||||
import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
|
||||
import com.intellij.refactoring.changeSignature.ThrownExceptionInfo;
|
||||
import com.intellij.refactoring.util.CanonicalTypes;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
@@ -34,21 +37,71 @@ public class ChangeSignaturePropagationTest extends LightCodeInsightTestCase {
|
||||
exceptionPropagationTest();
|
||||
}
|
||||
|
||||
public void testParamWithNoConstructor() throws Exception {
|
||||
final PsiMethod method = getPrimaryMethod();
|
||||
parameterPropagationTest(method, collectNonPhysicalMethodsToPropagate(method));
|
||||
}
|
||||
|
||||
public void testExceptionWithNoConstructor() throws Exception {
|
||||
final PsiMethod method = getPrimaryMethod();
|
||||
exceptionPropagationTest(method, collectNonPhysicalMethodsToPropagate(method));
|
||||
}
|
||||
|
||||
private static HashSet<PsiMethod> collectNonPhysicalMethodsToPropagate(PsiMethod method) {
|
||||
final HashSet<PsiMethod> methodsToPropagate = new HashSet<PsiMethod>();
|
||||
final PsiReference[] references =
|
||||
MethodReferencesSearch.search(method, GlobalSearchScope.allScope(getProject()), true).toArray(PsiReference.EMPTY_ARRAY);
|
||||
for (PsiReference reference : references) {
|
||||
final PsiElement element = reference.getElement();
|
||||
Assert.assertTrue(element instanceof PsiClass);
|
||||
PsiClass containingClass = (PsiClass)element;
|
||||
methodsToPropagate.add(JavaPsiFacade.getElementFactory(getProject()).createMethodFromText(containingClass.getName() + "(){}", containingClass));
|
||||
}
|
||||
return methodsToPropagate;
|
||||
}
|
||||
|
||||
public void testParamWithImplicitConstructor() throws Exception {
|
||||
final PsiMethod method = getPrimaryMethod();
|
||||
parameterPropagationTest(method, collectDefaultConstructorsToPropagate(method));
|
||||
}
|
||||
|
||||
public void testParamWithImplicitConstructors() throws Exception {
|
||||
final PsiMethod method = getPrimaryMethod();
|
||||
parameterPropagationTest(method, collectDefaultConstructorsToPropagate(method));
|
||||
}
|
||||
|
||||
public void testExceptionWithImplicitConstructor() throws Exception {
|
||||
final PsiMethod method = getPrimaryMethod();
|
||||
exceptionPropagationTest(method, collectDefaultConstructorsToPropagate(method));
|
||||
}
|
||||
|
||||
private static HashSet<PsiMethod> collectDefaultConstructorsToPropagate(PsiMethod method) {
|
||||
final HashSet<PsiMethod> methodsToPropagate = new HashSet<PsiMethod>();
|
||||
for (PsiClass inheritor : ClassInheritorsSearch.search(method.getContainingClass())) {
|
||||
methodsToPropagate.add(inheritor.getConstructors()[0]);
|
||||
}
|
||||
return methodsToPropagate;
|
||||
}
|
||||
|
||||
private void parameterPropagationTest() throws Exception {
|
||||
PsiMethod method = getPrimaryMethod();
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
final PsiMethod method = getPrimaryMethod();
|
||||
parameterPropagationTest(method, new HashSet<PsiMethod>(Arrays.asList(method.getContainingClass().getMethods())));
|
||||
}
|
||||
|
||||
private void parameterPropagationTest(final PsiMethod method, final HashSet<PsiMethod> psiMethods) throws Exception {
|
||||
PsiType newParamType = JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName("java.lang.Class", GlobalSearchScope.allScope(getProject()));
|
||||
final ParameterInfoImpl[] newParameters = new ParameterInfoImpl[]{new ParameterInfoImpl(-1, "clazz", newParamType, "null")};
|
||||
final Set<PsiMethod> methodsToPropagateParameters = new HashSet<PsiMethod>(Arrays.asList(aClass.getMethods()));
|
||||
doTest(newParameters, new ThrownExceptionInfo[0], methodsToPropagateParameters, null, method);
|
||||
doTest(newParameters, new ThrownExceptionInfo[0], psiMethods, null, method);
|
||||
}
|
||||
|
||||
private void exceptionPropagationTest() throws Exception {
|
||||
PsiMethod method = getPrimaryMethod();
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
final PsiMethod method = getPrimaryMethod();
|
||||
exceptionPropagationTest(method, new HashSet<PsiMethod>(Arrays.asList(method.getContainingClass().getMethods())));
|
||||
}
|
||||
|
||||
private void exceptionPropagationTest(final PsiMethod method, final Set<PsiMethod> methodsToPropagateExceptions) throws Exception {
|
||||
PsiClassType newExceptionType = JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName("java.lang.Exception", GlobalSearchScope.allScope(getProject()));
|
||||
final ThrownExceptionInfo[] newExceptions = new ThrownExceptionInfo[]{new ThrownExceptionInfo(-1, newExceptionType)};
|
||||
final Set<PsiMethod> methodsToPropagateExceptions = new HashSet<PsiMethod>(Arrays.asList(aClass.getMethods()));
|
||||
doTest(new ParameterInfoImpl[0], newExceptions, null, methodsToPropagateExceptions, method);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,4 +27,6 @@ import com.intellij.util.IncorrectOperationException;
|
||||
public interface TestFramework {
|
||||
boolean isTestKlass(PsiClass psiClass);
|
||||
PsiMethod findSetUpMethod(PsiClass psiClass) throws IncorrectOperationException;
|
||||
|
||||
boolean isTestMethodOrConfig(PsiMethod psiMethod);
|
||||
}
|
||||
@@ -60,4 +60,13 @@ public class TestUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isTestMethodOrConfig(PsiMethod psiMethod) {
|
||||
for (TestFramework framework : Extensions.getExtensions(TEST_FRAMEWORK)) {
|
||||
if (framework.isTestMethodOrConfig(psiMethod)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,6 @@ public class LineMarkerInfo<T extends PsiElement> {
|
||||
@Nullable private final Function<? super T, String> myTooltipProvider;
|
||||
private final GutterIconRenderer.Alignment myIconAlignment;
|
||||
@Nullable private final GutterIconNavigationHandler<T> myNavigationHandler;
|
||||
public TextAttributesKey textAttributesKey;
|
||||
|
||||
|
||||
public LineMarkerInfo(T element,
|
||||
|
||||
@@ -143,7 +143,6 @@ public class LineMarkersPass extends ProgressableTextEditorHighlightingPass impl
|
||||
return injectedMarker.getLineMarkerTooltip();
|
||||
}
|
||||
}, injectedMarker.getNavigationHandler(), GutterIconRenderer.Alignment.RIGHT);
|
||||
converted.textAttributesKey = injectedMarker.textAttributesKey;
|
||||
result.add(converted);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -399,8 +399,7 @@ public class UpdateHighlightersUtil {
|
||||
}
|
||||
RangeHighlighter marker = toReuse.reuseHighlighterAt(info.startOffset, info.endOffset);
|
||||
if (marker == null) {
|
||||
TextAttributes attributes = info.textAttributesKey == null ? null : colorsScheme.getAttributes(info.textAttributesKey);
|
||||
marker = markupModel.addRangeHighlighter(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX, attributes, HighlighterTargetArea.EXACT_RANGE);
|
||||
marker = markupModel.addRangeHighlighter(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.EXACT_RANGE);
|
||||
}
|
||||
LineMarkerInfo.LineMarkerGutterIconRenderer renderer = (LineMarkerInfo.LineMarkerGutterIconRenderer)info.createGutterRenderer();
|
||||
LineMarkerInfo.LineMarkerGutterIconRenderer oldRenderer = marker.getGutterIconRenderer() instanceof LineMarkerInfo.LineMarkerGutterIconRenderer ? (LineMarkerInfo.LineMarkerGutterIconRenderer)marker.getGutterIconRenderer() : null;
|
||||
|
||||
+9
-4
@@ -65,10 +65,7 @@ public class SimpleTokenSetQuoteHandler implements QuoteHandler {
|
||||
IElementType tokenType = iterator.getTokenType();
|
||||
|
||||
if (myLiteralTokenSet.contains(tokenType)) {
|
||||
if (iterator.getStart() >= iterator.getEnd() - 1 ||
|
||||
chars.charAt(iterator.getEnd() - 1) != '\"' && chars.charAt(iterator.getEnd() - 1) != '\'') {
|
||||
return true;
|
||||
}
|
||||
if (isNonClosedLiteral(iterator, chars)) return true;
|
||||
}
|
||||
iterator.advance();
|
||||
}
|
||||
@@ -80,6 +77,14 @@ public class SimpleTokenSetQuoteHandler implements QuoteHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isNonClosedLiteral(HighlighterIterator iterator, CharSequence chars) {
|
||||
if (iterator.getStart() >= iterator.getEnd() - 1 ||
|
||||
chars.charAt(iterator.getEnd() - 1) != '\"' && chars.charAt(iterator.getEnd() - 1) != '\'') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInsideLiteral(HighlighterIterator iterator) {
|
||||
return myLiteralTokenSet.contains(iterator.getTokenType());
|
||||
}
|
||||
|
||||
@@ -850,7 +850,7 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ
|
||||
}
|
||||
|
||||
private class MyHighlighter extends DocumentAdapter implements EditorHighlighter {
|
||||
private boolean myHasEditor;
|
||||
private HighlighterClient myEditor;
|
||||
|
||||
public HighlighterIterator createIterator(final int startOffset) {
|
||||
final int startIndex = findTokenInfoIndexByOffset(startOffset);
|
||||
@@ -889,6 +889,10 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ
|
||||
return myIndex < 0 || myIndex >= myTokens.size();
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
return myEditor.getDocument();
|
||||
}
|
||||
|
||||
private TokenInfo getTokenInfo() {
|
||||
return myTokens.get(myIndex);
|
||||
}
|
||||
@@ -899,8 +903,8 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ
|
||||
}
|
||||
|
||||
public void setEditor(final HighlighterClient editor) {
|
||||
LOG.assertTrue(!myHasEditor, "Highlighters cannot be reused with different editors");
|
||||
myHasEditor = true;
|
||||
LOG.assertTrue(myEditor == null, "Highlighters cannot be reused with different editors");
|
||||
myEditor = editor;
|
||||
}
|
||||
|
||||
public void setColorScheme(EditorColorsScheme scheme) {
|
||||
|
||||
+4
@@ -498,5 +498,9 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
|
||||
public boolean atEnd() {
|
||||
return myBaseIterator.atEnd();
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
return myBaseIterator.getDocument();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-10
@@ -47,25 +47,26 @@ public class ModulePointerManagerImpl extends ModulePointerManager {
|
||||
|
||||
@Override
|
||||
public void moduleAdded(Project project, Module module) {
|
||||
final ModulePointerImpl pointer = myUnresolved.remove(module.getName());
|
||||
if (pointer != null) {
|
||||
pointer.moduleAdded(module);
|
||||
registerPointer(module, pointer);
|
||||
}
|
||||
moduleAppears(module);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modulesRenamed(Project project, List<Module> modules) {
|
||||
for (Module module : modules) {
|
||||
ModulePointerImpl pointer = myUnresolved.get(module.getName());
|
||||
if (pointer != null) {
|
||||
pointer.moduleAdded(module);
|
||||
}
|
||||
moduleAppears(module);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void moduleAppears(Module module) {
|
||||
ModulePointerImpl pointer = myUnresolved.remove(module.getName());
|
||||
if (pointer != null && pointer.getModule() == null) {
|
||||
pointer.moduleAdded(module);
|
||||
registerPointer(module, pointer);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerPointer(final Module module, final ModulePointerImpl pointer) {
|
||||
myPointers.put(module, pointer);
|
||||
Disposer.register(module, new Disposable() {
|
||||
@@ -88,7 +89,13 @@ public class ModulePointerManagerImpl extends ModulePointerManager {
|
||||
public ModulePointer create(@NotNull Module module) {
|
||||
ModulePointerImpl pointer = myPointers.get(module);
|
||||
if (pointer == null) {
|
||||
pointer = new ModulePointerImpl(module);
|
||||
pointer = myUnresolved.get(module.getName());
|
||||
if (pointer == null) {
|
||||
pointer = new ModulePointerImpl(module);
|
||||
}
|
||||
else {
|
||||
pointer.moduleAdded(module);
|
||||
}
|
||||
registerPointer(module, pointer);
|
||||
}
|
||||
return pointer;
|
||||
|
||||
+8
-11
@@ -22,16 +22,14 @@ import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.*;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.EditorComboWithBrowseButton;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.RecentsManager;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -147,13 +145,12 @@ class CopyFilesOrDirectoriesDialog extends DialogWrapper{
|
||||
if (myShowDirectoryField) {
|
||||
panel.add(new JLabel(RefactoringBundle.message("copy.files.to.directory.label")), new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,8,4,8),0,0));
|
||||
|
||||
final ComponentWithBrowseButton.BrowseFolderActionListener browseActionListener =
|
||||
new ComponentWithBrowseButton.BrowseFolderActionListener<JComboBox>(RefactoringBundle.message("select.target.directory"),
|
||||
RefactoringBundle.message("the.file.will.be.copied.to.this.directory"),
|
||||
null, myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor(),
|
||||
TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
|
||||
myTargetDirectoryField = new EditorComboWithBrowseButton(browseActionListener, "", myProject,
|
||||
myTargetDirectoryField = new EditorComboWithBrowseButton(null, "", myProject,
|
||||
RECENT_KEYS);
|
||||
myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"),
|
||||
RefactoringBundle.message("the.file.will.be.copied.to.this.directory"),
|
||||
myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor(),
|
||||
EditorComboBox.COMPONENT_ACCESSOR);
|
||||
myTargetDirectoryField.setTextFieldPreferredWidth(60);
|
||||
panel.add(myTargetDirectoryField, new GridBagConstraints(1,1,1,1,1,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,0,4,8),0,0));
|
||||
|
||||
|
||||
+7
-8
@@ -24,9 +24,7 @@ import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComponentWithBrowseButton;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.TextComponentAccessor;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -34,6 +32,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.ui.EditorComboBox;
|
||||
import com.intellij.ui.EditorComboWithBrowseButton;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.RecentsManager;
|
||||
@@ -90,12 +89,12 @@ public class MoveFilesOrDirectoriesDialog extends DialogWrapper{
|
||||
panel.add(new JLabel(RefactoringBundle.message("move.files.to.directory.label")),
|
||||
new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,8,4,8),0,0));
|
||||
|
||||
final ComponentWithBrowseButton.BrowseFolderActionListener browseActionListener =
|
||||
new ComponentWithBrowseButton.BrowseFolderActionListener<JComboBox>(RefactoringBundle.message("select.target.directory"),
|
||||
RefactoringBundle.message("the.file.will.be.moved.to.this.directory"), null,
|
||||
myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor(),
|
||||
TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
|
||||
myTargetDirectoryField = new EditorComboWithBrowseButton(browseActionListener, "", myProject, RECENT_KEYS);
|
||||
myTargetDirectoryField = new EditorComboWithBrowseButton(null, "", myProject, RECENT_KEYS);
|
||||
myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"),
|
||||
RefactoringBundle.message("the.file.will.be.moved.to.this.directory"),
|
||||
myProject,
|
||||
FileChooserDescriptorFactory.createSingleFolderDescriptor(),
|
||||
EditorComboBox.COMPONENT_ACCESSOR);
|
||||
myTargetDirectoryField.setTextFieldPreferredWidth(60);
|
||||
panel.add(myTargetDirectoryField, new GridBagConstraints(1,1,1,1,1,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,0,4,8),0,0));
|
||||
|
||||
|
||||
@@ -906,6 +906,8 @@ public class AbstractTreeUi {
|
||||
|
||||
@NotNull
|
||||
UpdaterTreeState setUpdaterState(UpdaterTreeState state) {
|
||||
if (myUpdaterState != null && myUpdaterState.equals(state)) return state;
|
||||
|
||||
final UpdaterTreeState oldState = myUpdaterState;
|
||||
if (oldState == null) {
|
||||
myUpdaterState = state;
|
||||
@@ -1642,9 +1644,7 @@ public class AbstractTreeUi {
|
||||
needToUpdate = true;
|
||||
}
|
||||
|
||||
//noinspection ConstantConditions
|
||||
if (childDescr.get() == null) {
|
||||
LOG.error("childDescr == null, treeStructure = " + getTreeStructure() + ", child = " + child);
|
||||
processingDone.setDone();
|
||||
continue;
|
||||
}
|
||||
|
||||
+2
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.openapi.editor.highlighter;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
@@ -28,4 +29,5 @@ public interface HighlighterIterator {
|
||||
void advance();
|
||||
void retreat();
|
||||
boolean atEnd();
|
||||
Document getDocument();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.StackingPopupDispatcher;
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -940,6 +941,12 @@ public abstract class DialogWrapper {
|
||||
* @throws IllegalStateException if the dialog is invoked not on the event dispatch thread
|
||||
*/
|
||||
public void show() {
|
||||
showAndGetOk();
|
||||
}
|
||||
|
||||
public AsyncResult<Boolean> showAndGetOk() {
|
||||
final AsyncResult<Boolean> result = new AsyncResult<Boolean>();
|
||||
|
||||
ensureEventDispatchThread();
|
||||
registerKeyboardShortcuts();
|
||||
|
||||
@@ -949,7 +956,13 @@ public abstract class DialogWrapper {
|
||||
Disposer.register(uiParent, myDisposable); // ensure everything is disposed on app quit
|
||||
}
|
||||
|
||||
myPeer.show();
|
||||
myPeer.show().doWhenProcessed(new Runnable() {
|
||||
public void run() {
|
||||
result.setDone(isOK());
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.ui;
|
||||
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -138,7 +139,7 @@ public abstract class DialogWrapperPeer {
|
||||
*/
|
||||
public abstract void setLocation(int x, int y);
|
||||
|
||||
public abstract void show();
|
||||
public abstract ActionCallback show();
|
||||
|
||||
public abstract void setContentPane(JComponent content);
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ public class VfsUtil {
|
||||
}
|
||||
|
||||
public static void saveText(@NotNull VirtualFile file, @NotNull String text) throws IOException {
|
||||
file.setBinaryContent(text.getBytes(file.getCharset().name()));
|
||||
Charset charset = file.getCharset();
|
||||
file.setBinaryContent(text.getBytes(charset.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+8
-3
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.editor.ex.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.HighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
@@ -31,7 +32,7 @@ public class EmptyEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
|
||||
private TextAttributes myAttributes;
|
||||
private int myTextLength = 0;
|
||||
private boolean myHasEditor = false;
|
||||
private HighlighterClient myEditor;
|
||||
|
||||
public EmptyEditorHighlighter(TextAttributes attributes) {
|
||||
myAttributes = attributes;
|
||||
@@ -46,8 +47,8 @@ public class EmptyEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
}
|
||||
|
||||
public void setEditor(HighlighterClient editor) {
|
||||
LOG.assertTrue(!myHasEditor, "Highlighters cannot be reused with different editors");
|
||||
myHasEditor = true;
|
||||
LOG.assertTrue(myEditor == null, "Highlighters cannot be reused with different editors");
|
||||
myEditor = editor;
|
||||
}
|
||||
|
||||
public void setColorScheme(EditorColorsScheme scheme) {
|
||||
@@ -92,6 +93,10 @@ public class EmptyEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
return index != 0;
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
return myEditor.getDocument();
|
||||
}
|
||||
|
||||
public IElementType getTokenType(){
|
||||
return IElementType.find(IElementType.FIRST_TOKEN_INDEX);
|
||||
}
|
||||
|
||||
+4
@@ -383,5 +383,9 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
public boolean atEnd() {
|
||||
return mySegmentIndex >= mySegments.getSegmentCount() || mySegmentIndex < 0;
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
return myEditor.getDocument();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.ex.util;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
@@ -61,4 +62,8 @@ public class LimitedRangeHighlighterIterator implements HighlighterIterator {
|
||||
public boolean atEnd() {
|
||||
return myOriginal.atEnd() || myOriginal.getStart() >= myEndOffset || myOriginal.getEnd() <= myStartOffset;
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
return myOriginal.getDocument();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,6 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx
|
||||
|
||||
public void setRangeHighlighterAttributes(final RangeHighlighter highlighter, final TextAttributes textAttributes) {
|
||||
((RangeHighlighterImpl)highlighter).setTextAttributes(textAttributes);
|
||||
fireSegmentHighlighterChanged(highlighter);
|
||||
}
|
||||
|
||||
private MarkupModelListener[] getCachedListeners() {
|
||||
|
||||
@@ -70,6 +70,7 @@ public class RangeHighlighterImpl implements RangeHighlighterEx {
|
||||
|
||||
public void setTextAttributes(final TextAttributes textAttributes) {
|
||||
myTextAttributes = textAttributes;
|
||||
fireChanged();
|
||||
}
|
||||
|
||||
public int getLayer() {
|
||||
@@ -128,6 +129,7 @@ public class RangeHighlighterImpl implements RangeHighlighterEx {
|
||||
|
||||
public void setErrorStripeTooltip(Object tooltipObject) {
|
||||
myErrorStripeTooltip = tooltipObject;
|
||||
fireChanged();
|
||||
}
|
||||
|
||||
public boolean isThinErrorStripeMark() {
|
||||
@@ -136,6 +138,7 @@ public class RangeHighlighterImpl implements RangeHighlighterEx {
|
||||
|
||||
public void setThinErrorStripeMark(boolean value) {
|
||||
myErrorStripeMarkIsThin = value;
|
||||
fireChanged();
|
||||
}
|
||||
|
||||
public Color getLineSeparatorColor() {
|
||||
@@ -158,6 +161,7 @@ public class RangeHighlighterImpl implements RangeHighlighterEx {
|
||||
|
||||
public void setEditorFilter(@NotNull MarkupEditorFilter filter) {
|
||||
myFilter = filter;
|
||||
fireChanged();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -171,6 +175,7 @@ public class RangeHighlighterImpl implements RangeHighlighterEx {
|
||||
|
||||
public void setAfterEndOfLine(boolean afterEndOfLine) {
|
||||
isAfterEndOfLine = afterEndOfLine;
|
||||
fireChanged();
|
||||
}
|
||||
|
||||
private void fireChanged() {
|
||||
|
||||
@@ -348,7 +348,9 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
myDialog.setLocation(x, y);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
public ActionCallback show() {
|
||||
final ActionCallback result = new ActionCallback();
|
||||
|
||||
LOG.assertTrue(EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
|
||||
|
||||
final AnCancelAction anCancelAction = new AnCancelAction();
|
||||
@@ -397,7 +399,15 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
LaterInvocator.leaveModal(myDialog);
|
||||
}
|
||||
}
|
||||
|
||||
myDialog.getFocusManager().doWhenFocusSettlesDown(new Runnable() {
|
||||
public void run() {
|
||||
result.setDone();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//[kirillk] for now it only deals with the TaskWindow under Mac OS X: modal dialogs are shown behind JBPopup
|
||||
@@ -609,7 +619,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
if (!isModal()) {
|
||||
final Ref<IdeFocusManager> focusManager = new Ref<IdeFocusManager>(null);
|
||||
if (myProject != null && myProject.get() != null && !myProject.get().isDisposed()) {
|
||||
focusManager.set(IdeFocusManager.getInstance(myProject.get()));
|
||||
focusManager.set(getFocusManager());
|
||||
focusManager.get().doWhenFocusSettlesDown(new Runnable() {
|
||||
public void run() {
|
||||
disposeFocusTrackbackIfNoChildWindowFocused(focusManager.get());
|
||||
@@ -640,6 +650,14 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
super.show();
|
||||
}
|
||||
|
||||
private IdeFocusManager getFocusManager() {
|
||||
if (myProject != null && myProject.get() != null && !myProject.get().isDisposed()) {
|
||||
return IdeFocusManager.getInstance(myProject.get());
|
||||
} else {
|
||||
return IdeFocusManager.findInstance();
|
||||
}
|
||||
}
|
||||
|
||||
private void disposeFocusTrackbackIfNoChildWindowFocused(@Nullable IdeFocusManager focusManager) {
|
||||
if (myFocusTrackback == null) return;
|
||||
|
||||
@@ -666,8 +684,16 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
@Deprecated
|
||||
public void hide() {
|
||||
super.hide();
|
||||
if (myFocusTrackback != null) {
|
||||
myFocusTrackback.restoreFocus();
|
||||
if (myFocusTrackback != null && !(myFocusTrackback.isSheduledForRestore() || myFocusTrackback.isWillBeSheduledForRestore())) {
|
||||
myFocusTrackback.setWillBeSheduledForRestore();
|
||||
IdeFocusManager mgr = getFocusManager();
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
myFocusTrackback.restoreFocus();
|
||||
myFocusTrackback = null;
|
||||
}
|
||||
};
|
||||
mgr.doWhenFocusSettlesDown(r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,7 +712,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
myComponentListener = null;
|
||||
}
|
||||
|
||||
if (myFocusTrackback != null && !myFocusTrackback.isSheduledForRestore()) {
|
||||
if (myFocusTrackback != null && !(myFocusTrackback.isSheduledForRestore() || myFocusTrackback.isWillBeSheduledForRestore())) {
|
||||
myFocusTrackback.dispose();
|
||||
myFocusTrackback = null;
|
||||
}
|
||||
|
||||
+4
-1
@@ -29,6 +29,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.DialogWrapperDialog;
|
||||
import com.intellij.openapi.ui.DialogWrapperPeer;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
@@ -275,12 +276,14 @@ public class GlassPaneDialogWrapperPeer extends DialogWrapperPeer implements Foc
|
||||
myDialog.setLocation(_x, _y);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
public ActionCallback show() {
|
||||
LOG.assertTrue(EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
|
||||
|
||||
hidePopupsIfNeeded();
|
||||
|
||||
myDialog.setVisible(true);
|
||||
|
||||
return new ActionCallback.Done();
|
||||
}
|
||||
|
||||
public void setContentPane(final JComponent content) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.TextComponentAccessor;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -38,6 +39,15 @@ import java.util.ArrayList;
|
||||
* @author max
|
||||
*/
|
||||
public class EditorComboBox extends JComboBox implements DocumentListener {
|
||||
public static TextComponentAccessor<EditorComboBox> COMPONENT_ACCESSOR = new TextComponentAccessor<EditorComboBox>() {
|
||||
public String getText(EditorComboBox component) {
|
||||
return component.getText();
|
||||
}
|
||||
|
||||
public void setText(EditorComboBox component, String text) {
|
||||
component.setText(text);
|
||||
}
|
||||
};
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ui.EditorTextField");
|
||||
|
||||
private Document myDocument;
|
||||
|
||||
@@ -60,6 +60,7 @@ public class FocusTrackback {
|
||||
private boolean myConsumed;
|
||||
private WeakReference myRequestor;
|
||||
private boolean mySheduledForRestore;
|
||||
private boolean myWillBeSheduledForRestore;
|
||||
|
||||
public FocusTrackback(@NotNull Object requestor, Component parent, boolean mustBeShown) {
|
||||
this(requestor, SwingUtilities.getWindowAncestor(parent), mustBeShown);
|
||||
@@ -375,10 +376,18 @@ public class FocusTrackback {
|
||||
return myRequestor.get();
|
||||
}
|
||||
|
||||
public void setWillBeSheduledForRestore() {
|
||||
myWillBeSheduledForRestore = true;
|
||||
}
|
||||
|
||||
public boolean isSheduledForRestore() {
|
||||
return mySheduledForRestore;
|
||||
}
|
||||
|
||||
public boolean isWillBeSheduledForRestore() {
|
||||
return myWillBeSheduledForRestore;
|
||||
}
|
||||
|
||||
public interface Provider {
|
||||
FocusTrackback getFocusTrackback();
|
||||
}
|
||||
|
||||
@@ -288,6 +288,10 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
int resultWidth = ofContent.width > MAX_SIZE.width ? MAX_SIZE.width : ofContent.width;
|
||||
int resultHeight = ofContent.height > MAX_SIZE.height ? MAX_SIZE.height : ofContent.height;
|
||||
|
||||
if (ofContent.height > MAX_SIZE.height) {
|
||||
resultWidth += new JScrollPane().getVerticalScrollBar().getPreferredSize().getWidth();
|
||||
}
|
||||
|
||||
return new Dimension(resultWidth, resultHeight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware {
|
||||
final HighlightAnnotationsActions highlighting = new HighlightAnnotationsActions(project, file, fileAnnotation, editorGutterComponentEx);
|
||||
final List<AnnotationFieldGutter> gutters = new ArrayList<AnnotationFieldGutter>();
|
||||
final AnnotationSourceSwitcher switcher = fileAnnotation.getAnnotationSourceSwitcher();
|
||||
final MyAnnotationPresentation presentation = new MyAnnotationPresentation(highlighting, switcher, editorGutterComponentEx);
|
||||
final MyAnnotationPresentation presentation = new MyAnnotationPresentation(highlighting, switcher, editorGutterComponentEx, gutters);
|
||||
|
||||
if (switcher != null) {
|
||||
|
||||
@@ -372,19 +372,23 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware {
|
||||
private final HighlightAnnotationsActions myHighlighting;
|
||||
@Nullable
|
||||
private final AnnotationSourceSwitcher mySwitcher;
|
||||
private final List<AnnotationFieldGutter> myGutters;
|
||||
private final List<AnAction> myActions;
|
||||
private MySwitchAnnotationSourceAction mySwitchAction;
|
||||
|
||||
public MyAnnotationPresentation(@NotNull final HighlightAnnotationsActions highlighting, @Nullable final AnnotationSourceSwitcher switcher,
|
||||
final EditorGutterComponentEx gutter) {
|
||||
final EditorGutterComponentEx gutter,
|
||||
List<AnnotationFieldGutter> gutters) {
|
||||
myHighlighting = highlighting;
|
||||
mySwitcher = switcher;
|
||||
myGutters = gutters;
|
||||
|
||||
myActions = new ArrayList<AnAction>(myHighlighting.getList());
|
||||
if (mySwitcher != null) {
|
||||
mySwitchAction = new MySwitchAnnotationSourceAction(mySwitcher, gutter);
|
||||
myActions.add(mySwitchAction);
|
||||
}
|
||||
myActions.add(new ShowHideColorsAction(myGutters, gutter));
|
||||
}
|
||||
|
||||
public EditorFontType getFontType(final int line) {
|
||||
|
||||
@@ -43,6 +43,7 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter {
|
||||
private final AnnotationListener myListener;
|
||||
private final boolean myIsGutterAction;
|
||||
private Map<String, Color> myColorScheme;
|
||||
private boolean myShowBg = true;
|
||||
|
||||
AnnotationFieldGutter(FileAnnotation annotation, Editor editor, LineAnnotationAspect aspect, final TextAnnotationPresentation presentation) {
|
||||
myAnnotation = annotation;
|
||||
@@ -109,8 +110,9 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter {
|
||||
|
||||
@Nullable
|
||||
public Color getBgColor(int line, Editor editor) {
|
||||
if (myColorScheme == null || !myShowBg) return null;
|
||||
final String s = getLineText(line, editor);
|
||||
if (myColorScheme == null || s == null) return null;
|
||||
if (s == null) return null;
|
||||
final Color bg = myColorScheme.get(s);
|
||||
return bg == null ? findBgColor(s) : bg;
|
||||
}
|
||||
@@ -129,5 +131,9 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter {
|
||||
|
||||
public void setAspectValueToBgColorMap(Map<String, Color> colorScheme) {
|
||||
myColorScheme = colorScheme;
|
||||
}
|
||||
}
|
||||
|
||||
public void setShowBg(boolean show) {
|
||||
myShowBg = show;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.openapi.vcs.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.editor.ex.EditorGutterComponentEx;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ShowHideColorsAction extends AnAction {
|
||||
private boolean showColors = Registry.is("vcs.show.colored.annotations");
|
||||
private final List<AnnotationFieldGutter> myGutters;
|
||||
private final EditorGutterComponentEx myGutter;
|
||||
|
||||
public ShowHideColorsAction(List<AnnotationFieldGutter> gutters, EditorGutterComponentEx gutter) {
|
||||
myGutters = gutters;
|
||||
myGutter = gutter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
showColors = !showColors;
|
||||
for (AnnotationFieldGutter gutter : myGutters) {
|
||||
gutter.setShowBg(showColors);
|
||||
}
|
||||
myGutter.revalidateMarkup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setText(showColors ? "Hide Colors" : "Show Colors");
|
||||
}
|
||||
}
|
||||
+19
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,33 +15,37 @@
|
||||
*/
|
||||
package com.siyeh.ig.inheritance;
|
||||
|
||||
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.psiutils.MethodUtils;
|
||||
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
|
||||
import com.siyeh.ig.psiutils.TestUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
public class RefusedBequestInspection extends BaseInspection {
|
||||
|
||||
/** @noinspection PublicField*/
|
||||
public boolean ignoreEmptySuperMethods = false;
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName(){
|
||||
return InspectionGadgetsBundle.message("refused.bequest.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String buildErrorString(Object... infos){
|
||||
return InspectionGadgetsBundle.message(
|
||||
"refused.bequest.problem.descriptor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return new SingleCheckboxOptionsPanel(
|
||||
@@ -50,6 +54,7 @@ public class RefusedBequestInspection extends BaseInspection {
|
||||
"</html>", this, "ignoreEmptySuperMethods");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor(){
|
||||
return new RefusedBequestVisitor();
|
||||
}
|
||||
@@ -57,7 +62,6 @@ public class RefusedBequestInspection extends BaseInspection {
|
||||
private class RefusedBequestVisitor extends BaseInspectionVisitor{
|
||||
|
||||
@Override public void visitMethod(@NotNull PsiMethod method){
|
||||
super.visitMethod(method);
|
||||
final PsiCodeBlock body = method.getBody();
|
||||
if(body == null){
|
||||
return;
|
||||
@@ -72,6 +76,9 @@ public class RefusedBequestInspection extends BaseInspection {
|
||||
}
|
||||
final PsiClass containingClass =
|
||||
leastConcreteSuperMethod.getContainingClass();
|
||||
if (containingClass == null) {
|
||||
return;
|
||||
}
|
||||
final String className = containingClass.getQualifiedName();
|
||||
if("java.lang.Object".equals(className)){
|
||||
return;
|
||||
@@ -83,6 +90,9 @@ public class RefusedBequestInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (TestUtils.isJUnit4BeforeOrAfterMethod(method)) {
|
||||
return;
|
||||
}
|
||||
if(containsSuperCall(body, leastConcreteSuperMethod)){
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +106,8 @@ public class RefusedBequestInspection extends BaseInspection {
|
||||
for(final PsiMethod superMethod : superMethods){
|
||||
final PsiClass containingClass =
|
||||
superMethod.getContainingClass();
|
||||
if(!superMethod.hasModifierProperty(PsiModifier.ABSTRACT) &&
|
||||
if(containingClass != null &&
|
||||
!superMethod.hasModifierProperty(PsiModifier.ABSTRACT) &&
|
||||
!containingClass.isInterface()){
|
||||
leastConcreteSuperMethod = superMethod;
|
||||
return leastConcreteSuperMethod;
|
||||
@@ -105,10 +116,10 @@ public class RefusedBequestInspection extends BaseInspection {
|
||||
return leastConcreteSuperMethod;
|
||||
}
|
||||
|
||||
private boolean containsSuperCall(PsiCodeBlock body,
|
||||
PsiMethod method){
|
||||
private boolean containsSuperCall(@NotNull PsiElement context,
|
||||
@NotNull PsiMethod method){
|
||||
final SuperCallVisitor visitor = new SuperCallVisitor(method);
|
||||
body.accept(visitor);
|
||||
context.accept(visitor);
|
||||
return visitor.hasSuperCall();
|
||||
}
|
||||
}
|
||||
|
||||
+22
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,22 +29,26 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class InstantiatingObjectToGetClassObjectInspection
|
||||
extends BaseInspection {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"instantiating.object.to.get.class.object.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected String buildErrorString(Object... infos) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"instantiating.object.to.get.class.object.problem.descriptor");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
return new InstantiatingObjectToGetClassObjectFix();
|
||||
}
|
||||
@@ -58,6 +62,7 @@ public class InstantiatingObjectToGetClassObjectInspection
|
||||
"instantiating.object.to.get.class.object.replace.quickfix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFix(Project project, ProblemDescriptor descriptor)
|
||||
throws IncorrectOperationException {
|
||||
final PsiMethodCallExpression expression =
|
||||
@@ -70,15 +75,27 @@ public class InstantiatingObjectToGetClassObjectInspection
|
||||
return;
|
||||
}
|
||||
final PsiType type = qualifier.getType();
|
||||
if (type == null || !(type instanceof PsiClassType)) {
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
final PsiClassType classType = (PsiClassType)type;
|
||||
final String text = classType.getClassName();
|
||||
replaceExpression(expression, text + ".class");
|
||||
replaceExpression(expression,
|
||||
getTypeText(type, new StringBuilder()) + ".class");
|
||||
}
|
||||
|
||||
private static StringBuilder getTypeText(PsiType type,
|
||||
StringBuilder text) {
|
||||
if (type instanceof PsiArrayType) {
|
||||
text.append("[]");
|
||||
final PsiArrayType arrayType = (PsiArrayType)type;
|
||||
getTypeText(arrayType.getComponentType(), text);
|
||||
} else {
|
||||
text.insert(0, type.getCanonicalText());
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new InstantiatingObjectToGetClassObjectVisitor();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<reference ref="Compare.LastVersion"/>
|
||||
<reference ref="Compare.Selected"/>
|
||||
<reference ref="Vcs.ShowTabbedFileHistory"/>
|
||||
<!-- <reference id="Vcs.ShowHistoryForBlock"/> -->
|
||||
<reference id="Vcs.ShowHistoryForBlock"/>
|
||||
<!-- <reference id="ChangesView.Browse"/> -->
|
||||
<separator/>
|
||||
|
||||
|
||||
@@ -242,4 +242,9 @@ public class GitRevisionNumber implements VcsRevisionNumber {
|
||||
Date timestamp = GitUtil.parseTimestamp(tokenizer.nextToken());
|
||||
return new GitRevisionNumber(tokenizer.nextToken(), timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myRevisionHash;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,6 +332,11 @@ public class GitVcs extends AbstractVcs {
|
||||
return myHistoryProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VcsHistoryProvider getVcsBlockHistoryProvider() {
|
||||
return myHistoryProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -214,12 +214,12 @@ push.active.pushing=Pushing branches...
|
||||
push.active.rebase.tooltip=Rebase branches in order to make push possible (might reorder commits)
|
||||
push.active.rebase=&Rebase
|
||||
push.active.rebasing=Rebasing ...
|
||||
push.active.status.behind=Unable to push. The current branch is behind tracked branch by {0} commit(s).
|
||||
push.active.status.behind=Unable to push. The current branch is behind tracked branch by {0,choice, 1#1 commit|2#{0,number} commits}.
|
||||
push.active.status.no.branch=The head is not on the branch.
|
||||
push.active.status.no.commits.behind=Nothing to push. The current branch is behind tracked branch by {0} commit(s).
|
||||
push.active.status.no.commits.behind=Nothing to push. The current branch is behind tracked branch by {0,choice, 1#1 commit|2#{0,number} commits}.
|
||||
push.active.status.no.commits=Nothing to push.
|
||||
push.active.status.no.tracked=No tracked branch is configured.
|
||||
push.active.status.push={0} commit(s) will be pushed.
|
||||
push.active.status.push={0,choice, 1#1 commit|2#{0,number} commits} will be pushed.
|
||||
push.active.status.status=Status:
|
||||
push.active.title=Push Active Branches
|
||||
push.active.view=&View
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
|
||||
@@ -153,7 +154,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
myHolder.createWarningAnnotation(referenceExpression.getReferenceNameElement(), message);
|
||||
}
|
||||
if (!resolveResult.isStaticsOK() && resolved instanceof PsiModifierListOwner) {
|
||||
if (!((PsiModifierListOwner)resolved).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (!((PsiModifierListOwner)resolved).hasModifierProperty(GrModifier.STATIC)) {
|
||||
myHolder.createWarningAnnotation(referenceExpression, GroovyBundle.message("cannot.reference.nonstatic", referenceExpression.getReferenceName()));
|
||||
}
|
||||
}
|
||||
@@ -242,15 +243,15 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
PsiModifierList modifiersList = variableDeclaration.getModifierList();
|
||||
checkAccessModifiers(myHolder, modifiersList);
|
||||
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.VOLATILE) && modifiersList.hasExplicitModifier(PsiModifier.FINAL)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.VOLATILE) && modifiersList.hasExplicitModifier(GrModifier.FINAL)) {
|
||||
myHolder.createErrorAnnotation(modifiersList, GroovyBundle.message("illegal.combination.of.modifiers.volatile.and.final"));
|
||||
}
|
||||
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.NATIVE)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.NATIVE)) {
|
||||
myHolder.createErrorAnnotation(modifiersList, GroovyBundle.message("variable.cannot.be.native"));
|
||||
}
|
||||
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.ABSTRACT)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.ABSTRACT)) {
|
||||
myHolder.createErrorAnnotation(modifiersList, GroovyBundle.message("variable.cannot.be.abstract"));
|
||||
}
|
||||
}
|
||||
@@ -348,7 +349,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
final PsiElement element = refElement.resolve();
|
||||
if (element instanceof PsiClass) {
|
||||
PsiClass clazz = (PsiClass)element;
|
||||
if (clazz.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
if (clazz.hasModifierProperty(GrModifier.ABSTRACT)) {
|
||||
if (newExpression.getAnonymousClassDefinition() == null) {
|
||||
String message = clazz.isInterface()
|
||||
? GroovyBundle.message("cannot.instantiate.interface", clazz.getName())
|
||||
@@ -358,7 +359,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
return;
|
||||
}
|
||||
if (newExpression.getQualifier() != null) {
|
||||
if (clazz.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (clazz.hasModifierProperty(GrModifier.STATIC)) {
|
||||
myHolder.createErrorAnnotation(newExpression, GroovyBundle.message("qualified.new.of.static.class"));
|
||||
}
|
||||
} else {
|
||||
@@ -510,8 +511,8 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
for (PsiElement modifier : modifiers) {
|
||||
if (modifier instanceof PsiAnnotation) continue;
|
||||
final String modifierText = modifier.getText();
|
||||
if (PsiModifier.FINAL.equals(modifierText)) continue;
|
||||
if ("def".equals(modifierText)) continue;
|
||||
if (GrModifier.FINAL.equals(modifierText)) continue;
|
||||
if (GrModifier.DEF.equals(modifierText)) continue;
|
||||
myHolder.createErrorAnnotation(modifier, GroovyBundle.message("not.allowed.modifier.in.forin", modifierText));
|
||||
}
|
||||
}
|
||||
@@ -571,7 +572,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
: ((GrSuperReferenceExpression)expression).getQualifier();
|
||||
if (qualifier == null) {
|
||||
final GrMethod method = PsiTreeUtil.getParentOfType(expression, GrMethod.class);
|
||||
if (method != null && method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (method != null && method.hasModifierProperty(GrModifier.STATIC)) {
|
||||
holder.createErrorAnnotation(expression, GroovyBundle.message("cannot.reference.nonstatic", expression.getText()));
|
||||
}
|
||||
}
|
||||
@@ -596,7 +597,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
final PsiClass containingClass = classMember.getContainingClass();
|
||||
if (containingClass == null) return;
|
||||
if (com.intellij.psi.util.PsiUtil.isInnerClass(containingClass)) {
|
||||
if (classMember.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (classMember.hasModifierProperty(GrModifier.STATIC)) {
|
||||
final PsiElement modifier = findModifierStatic(classMember);
|
||||
if (modifier != null) {
|
||||
holder.createErrorAnnotation(modifier, GroovyBundle.message("cannot.have.static.declarations"));
|
||||
@@ -613,7 +614,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
}
|
||||
|
||||
for (PsiElement modifier : list.getModifiers()) {
|
||||
if (PsiModifier.STATIC.equals(modifier.getText())) {
|
||||
if (GrModifier.STATIC.equals(modifier.getText())) {
|
||||
return modifier;
|
||||
}
|
||||
}
|
||||
@@ -639,7 +640,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
}
|
||||
|
||||
private static void checkImplementedMethodsOfClass(AnnotationHolder holder, GrTypeDefinition typeDefinition) {
|
||||
if (typeDefinition.hasModifierProperty(PsiModifier.ABSTRACT)) return;
|
||||
if (typeDefinition.hasModifierProperty(GrModifier.ABSTRACT)) return;
|
||||
if (typeDefinition.isEnum() || typeDefinition.isAnnotationType()) return;
|
||||
if (typeDefinition instanceof GrTypeParameter) return;
|
||||
|
||||
@@ -682,14 +683,14 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
checkAccessModifiers(holder, modifiersList);
|
||||
|
||||
//script methods
|
||||
boolean isMethodAbstract = modifiersList.hasExplicitModifier(PsiModifier.ABSTRACT);
|
||||
final boolean isMethodStatic = modifiersList.hasExplicitModifier(PsiModifier.STATIC);
|
||||
boolean isMethodAbstract = modifiersList.hasExplicitModifier(GrModifier.ABSTRACT);
|
||||
final boolean isMethodStatic = modifiersList.hasExplicitModifier(GrModifier.STATIC);
|
||||
if (method.getParent() instanceof GroovyFileBase) {
|
||||
if (isMethodAbstract) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("script.cannot.have.modifier.abstract"));
|
||||
}
|
||||
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.NATIVE)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.NATIVE)) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("script.cannot.have.modifier.native"));
|
||||
}
|
||||
}
|
||||
@@ -703,7 +704,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("interface.must.have.no.static.method"));
|
||||
}
|
||||
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.PRIVATE)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.PRIVATE)) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("interface.must.have.no.private.method"));
|
||||
}
|
||||
|
||||
@@ -734,7 +735,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
PsiModifierList typeDefModifiersList = containingTypeDef.getModifierList();
|
||||
LOG.assertTrue(typeDefModifiersList != null, "modifiers list must be not null");
|
||||
|
||||
if (!typeDefModifiersList.hasExplicitModifier(PsiModifier.ABSTRACT)) {
|
||||
if (!typeDefModifiersList.hasExplicitModifier(GrModifier.ABSTRACT)) {
|
||||
if (isMethodAbstract) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("not.abstract.class.cannot.have.abstract.method"));
|
||||
}
|
||||
@@ -768,35 +769,35 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
if (psiClass != null) {
|
||||
PsiModifierList modifierList = psiClass.getModifierList();
|
||||
if (modifierList != null) {
|
||||
if (modifierList.hasExplicitModifier(PsiModifier.FINAL)) {
|
||||
if (modifierList.hasExplicitModifier(GrModifier.FINAL)) {
|
||||
holder.createErrorAnnotation(typeDefinition.getNameIdentifierGroovy(), GroovyBundle.message("final.class.cannot.be.extended"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.ABSTRACT) && modifiersList.hasExplicitModifier(PsiModifier.FINAL)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.ABSTRACT) && modifiersList.hasExplicitModifier(GrModifier.FINAL)) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("illegal.combination.of.modifiers.abstract.and.final"));
|
||||
}
|
||||
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.TRANSIENT)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.TRANSIENT)) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("modifier.transient.not.allowed.here"));
|
||||
}
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.VOLATILE)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.VOLATILE)) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("modifier.volatile.not.allowed.here"));
|
||||
}
|
||||
|
||||
/**** interface ****/
|
||||
if (typeDefinition.isInterface()) {
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.FINAL)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.FINAL)) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("intarface.cannot.have.modifier.final"));
|
||||
}
|
||||
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.VOLATILE)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.VOLATILE)) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("modifier.volatile.not.allowed.here"));
|
||||
}
|
||||
|
||||
if (modifiersList.hasExplicitModifier(PsiModifier.TRANSIENT)) {
|
||||
if (modifiersList.hasExplicitModifier(GrModifier.TRANSIENT)) {
|
||||
holder.createErrorAnnotation(modifiersList, GroovyBundle.message("modifier.transient.not.allowed.here"));
|
||||
}
|
||||
}
|
||||
@@ -805,9 +806,9 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
}
|
||||
|
||||
private static void checkAccessModifiers(AnnotationHolder holder, @NotNull PsiModifierList modifierList) {
|
||||
boolean hasPrivate = modifierList.hasExplicitModifier(PsiModifier.PRIVATE);
|
||||
boolean hasPublic = modifierList.hasExplicitModifier(PsiModifier.PUBLIC);
|
||||
boolean hasProtected = modifierList.hasExplicitModifier(PsiModifier.PROTECTED);
|
||||
boolean hasPrivate = modifierList.hasExplicitModifier(GrModifier.PRIVATE);
|
||||
boolean hasPublic = modifierList.hasExplicitModifier(GrModifier.PUBLIC);
|
||||
boolean hasProtected = modifierList.hasExplicitModifier(GrModifier.PROTECTED);
|
||||
|
||||
if (hasPrivate && hasPublic || hasPrivate && hasProtected || hasPublic && hasProtected) {
|
||||
holder.createErrorAnnotation(modifierList, GroovyBundle.message("illegal.combination.of.modifiers"));
|
||||
@@ -1003,7 +1004,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
}
|
||||
|
||||
private static void highlightMemberResolved(AnnotationHolder holder, GrReferenceExpression refExpr, PsiMember member) {
|
||||
boolean isStatic = member.hasModifierProperty(PsiModifier.STATIC);
|
||||
boolean isStatic = member.hasModifierProperty(GrModifier.STATIC);
|
||||
Annotation annotation = holder.createInfoAnnotation(refExpr.getReferenceNameElement(), null);
|
||||
|
||||
if (member instanceof PsiField ) {
|
||||
@@ -1197,7 +1198,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
if (member instanceof GrField) {
|
||||
GrField field = (GrField)member;
|
||||
PsiElement identifier = field.getNameIdentifierGroovy();
|
||||
final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
|
||||
final boolean isStatic = field.hasModifierProperty(GrModifier.STATIC);
|
||||
holder.createInfoAnnotation(identifier, null).setTextAttributes(isStatic ? DefaultHighlighter.STATIC_FIELD : DefaultHighlighter.INSTANCE_FIELD);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
@@ -52,7 +53,7 @@ public class EachToForIntention extends Intention {
|
||||
String var;
|
||||
if (parameters.length == 1) {
|
||||
var = parameters[0].getText();
|
||||
var = StringUtil.replace(var, "def", "");
|
||||
var = StringUtil.replace(var, GrModifier.DEF, "");
|
||||
}
|
||||
else {
|
||||
var = "it";
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
|
||||
@@ -45,7 +46,7 @@ public class ConvertMethodToClosureIntention extends Intention {
|
||||
StringBuilder builder = new StringBuilder(method.getTextLength());
|
||||
String modifiers = method.getModifierList().getText();
|
||||
if (modifiers.trim().length() == 0) {
|
||||
modifiers = "def";
|
||||
modifiers = GrModifier.DEF;
|
||||
}
|
||||
builder.append(modifiers).append(' ');
|
||||
builder.append(method.getName()).append("={");
|
||||
|
||||
+6
-3
@@ -26,7 +26,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.patterns.PlatformPatterns;
|
||||
import static com.intellij.patterns.PlatformPatterns.psiElement;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -41,6 +40,7 @@ import org.jetbrains.plugins.groovy.lang.completion.handlers.AfterNewClassInsert
|
||||
import org.jetbrains.plugins.groovy.lang.completion.handlers.ArrayInsertHandler;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
|
||||
@@ -49,11 +49,13 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.skipWhitespaces;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.patterns.PlatformPatterns.psiElement;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.skipWhitespaces;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
@@ -66,7 +68,8 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
private static final ElementPattern<PsiElement> AFTER_DOT = psiElement().afterLeaf(".").withParent(GrReferenceExpression.class);
|
||||
|
||||
private static final String[] MODIFIERS =
|
||||
new String[]{"private", "public", "protected", "transient", "abstract", "native", "volatile", "strictfp", "def", "final", "synchronized", "static"};
|
||||
new String[]{GrModifier.PRIVATE, GrModifier.PUBLIC, GrModifier.PROTECTED, GrModifier.TRANSIENT, GrModifier.ABSTRACT, GrModifier.NATIVE,
|
||||
GrModifier.VOLATILE, GrModifier.STRICTFP, GrModifier.DEF, GrModifier.FINAL, GrModifier.SYNCHRONIZED, GrModifier.STATIC};
|
||||
private static final ElementPattern<PsiElement> TYPE_IN_VARIABLE_DECLARATION_AFTER_MODIFIER = PlatformPatterns
|
||||
.or(psiElement(PsiElement.class).withParent(GrVariable.class).afterLeaf(MODIFIERS),
|
||||
psiElement(PsiElement.class).withParent(GrParameter.class));
|
||||
|
||||
+3
-2
@@ -38,6 +38,7 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.impl.GrDocCommentUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -212,7 +213,7 @@ public class GroovyDocumentationProvider implements CodeDocumentationProvider {
|
||||
buffer.append(type.getCanonicalText());
|
||||
}
|
||||
else {
|
||||
buffer.append("def");
|
||||
buffer.append(GrModifier.DEF);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +345,7 @@ public class GroovyDocumentationProvider implements CodeDocumentationProvider {
|
||||
builder.append(LINE_SEPARATOR);
|
||||
}
|
||||
|
||||
if ((method.getReturnType() != null || method.getModifierList().hasModifierProperty("def")) &&
|
||||
if ((method.getReturnType() != null || method.getModifierList().hasModifierProperty(GrModifier.DEF)) &&
|
||||
method.getReturnType() != PsiType.VOID) {
|
||||
builder.append(CodeDocumentationUtil.createDocCommentLine(RETURN_TAG, project, commenter));
|
||||
builder.append(LINE_SEPARATOR);
|
||||
|
||||
+5
-2
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.editor.template.expressions;
|
||||
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
|
||||
import com.intellij.codeInsight.template.Expression;
|
||||
import com.intellij.codeInsight.template.ExpressionContext;
|
||||
import com.intellij.codeInsight.template.PsiTypeResult;
|
||||
@@ -23,6 +25,7 @@ import com.intellij.codeInsight.template.Result;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.SubtypeConstraint;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.SupertypeConstraint;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.TypeConstraint;
|
||||
@@ -58,7 +61,7 @@ public class ChooseTypeExpression extends Expression {
|
||||
}
|
||||
}
|
||||
|
||||
result.add(LookupElementBuilder.create("def").setBold());
|
||||
result.add(LookupElementBuilder.create(GrModifier.DEF).setBold());
|
||||
|
||||
return result.toArray(new LookupElement[result.size()]);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.parser.GroovyDocElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrStubElementType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAnnotationMethod;
|
||||
@@ -210,7 +211,7 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
GroovyElementType VARIABLE = new GroovyElementType("assigned variable");
|
||||
|
||||
//modifiers
|
||||
GroovyElementType MODIFIERS = new GroovyElementType("modifiers"); //node
|
||||
GrStubElementType<GrModifierListStub, GrModifierList> MODIFIERS = new GrModifierListElementType("modifier list");
|
||||
|
||||
GroovyElementType BALANCED_BRACKETS = new GroovyElementType("balanced brackets"); //node
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers;
|
||||
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public interface GrModifier extends PsiModifier {
|
||||
@NonNls String DEF = "def";
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public interface GrModifierFlags {
|
||||
int PUBLIC_MASK = 0x0001;
|
||||
int PRIVATE_MASK = 0x0002;
|
||||
int PROTECTED_MASK = 0x0004;
|
||||
int STATIC_MASK = 0x0008;
|
||||
int FINAL_MASK = 0x0010;
|
||||
int SYNCHRONIZED_MASK = 0x0020;
|
||||
int VOLATILE_MASK = 0x0040;
|
||||
int TRANSIENT_MASK = 0x0080;
|
||||
int NATIVE_MASK = 0x0100;
|
||||
int INTERFACE_MASK = 0x0200;
|
||||
int ABSTRACT_MASK = 0x0400;
|
||||
int STRICTFP_MASK = 0x0800;
|
||||
int PACKAGE_LOCAL_MASK = 0x1000;
|
||||
int DEPRECATED_MASK = 0x2000;
|
||||
int ENUM_MASK = 0x4000;
|
||||
int ANNOTATION_TYPE_MASK = 0x8000;
|
||||
int ANNOTATION_DEPRECATED_MASK = 0x10000;
|
||||
int DEF_MASK = 0x20000;
|
||||
}
|
||||
+5
-4
@@ -16,18 +16,19 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiModifierList;
|
||||
import com.intellij.psi.StubBasedPsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
|
||||
import com.intellij.psi.PsiModifierList;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrModifierListStub;
|
||||
|
||||
/**
|
||||
* @autor: Dmitry.Krasilschikov
|
||||
* @date: 18.03.2007
|
||||
*/
|
||||
public interface GrModifierList extends GroovyPsiElement, PsiModifierList {
|
||||
public interface GrModifierList extends GroovyPsiElement, PsiModifierList, StubBasedPsiElement<GrModifierListStub> {
|
||||
@NotNull
|
||||
PsiElement[] getModifiers();
|
||||
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ import java.util.Set;
|
||||
* @author ven
|
||||
*/
|
||||
public interface GrField extends GrVariable, GrMember, PsiField, GrTopLevelDefintion, StubBasedPsiElement<GrFieldStub>, GrDocCommentOwner {
|
||||
public static final GrField[] EMPTY_ARRAY = new GrField[0];
|
||||
GrField[] EMPTY_ARRAY = new GrField[0];
|
||||
|
||||
boolean isProperty();
|
||||
|
||||
@@ -41,5 +41,5 @@ public interface GrField extends GrVariable, GrMember, PsiField, GrTopLevelDefin
|
||||
GrAccessorMethod[] getGetters();
|
||||
|
||||
@NotNull
|
||||
public Set<String>[] getNamedParametersArray();
|
||||
Set<String>[] getNamedParametersArray();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.psi.scope.BaseScopeProcessor;
|
||||
import com.intellij.psi.scope.NameHint;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -51,6 +52,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.GrTopStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrFileStub;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint;
|
||||
|
||||
@@ -82,6 +84,10 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
|
||||
@NotNull
|
||||
public String getPackageName() {
|
||||
final StubElement stub = getStub();
|
||||
if (stub instanceof GrFileStub) {
|
||||
return ((GrFileStub)stub).getPackageName().toString();
|
||||
}
|
||||
GrPackageDefinition packageDef = findChildByClass(GrPackageDefinition.class);
|
||||
if (packageDef != null) {
|
||||
return packageDef.getPackageName();
|
||||
@@ -371,6 +377,10 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
}
|
||||
|
||||
public boolean isScript() {
|
||||
final StubElement stub = getStub();
|
||||
if (stub instanceof GrFileStub) {
|
||||
return ((GrFileStub)stub).isScript();
|
||||
}
|
||||
GrTopStatement[] top = findChildrenByClass(GrTopStatement.class);
|
||||
for (GrTopStatement st : top) {
|
||||
if (!(st instanceof GrTypeDefinition || st instanceof GrImportStatement || st instanceof GrPackageDefinition)) return true;
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.intellij.psi.util.MethodSignatureUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrNamedElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
@@ -56,6 +55,8 @@ import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -143,10 +144,11 @@ public class PsiImplUtil {
|
||||
} else if (parent instanceof GrMethodCallExpression) {
|
||||
funExpr = ((GrMethodCallExpression) parent).getInvokedExpression();
|
||||
}
|
||||
|
||||
if (funExpr instanceof GrReferenceExpression) {
|
||||
qualifier = ((GrReferenceExpression) funExpr).getQualifierExpression();
|
||||
if (qualifier != null) break;
|
||||
} else break;
|
||||
}
|
||||
|
||||
closure = PsiTreeUtil.getParentOfType(closure, GrClosableBlock.class);
|
||||
}
|
||||
|
||||
+65
-27
@@ -19,7 +19,9 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.modifiers;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.TreeUtil;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -29,12 +31,15 @@ import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierFlags;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyBaseElementImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrModifierListStub;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -44,11 +49,37 @@ import java.util.List;
|
||||
* @autor: Dmitry.Krasilschikov
|
||||
* @date: 18.03.2007
|
||||
*/
|
||||
public class GrModifierListImpl extends GroovyPsiElementImpl implements GrModifierList {
|
||||
public class GrModifierListImpl extends GroovyBaseElementImpl<GrModifierListStub> implements GrModifierList {
|
||||
public static final TObjectIntHashMap<String> NAME_TO_MODIFIER_FLAG_MAP = new TObjectIntHashMap<String>();
|
||||
|
||||
static {
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.PUBLIC, GrModifierFlags.PUBLIC_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.PROTECTED, GrModifierFlags.PROTECTED_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.PRIVATE, GrModifierFlags.PRIVATE_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.PACKAGE_LOCAL, GrModifierFlags.PACKAGE_LOCAL_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.STATIC, GrModifierFlags.STATIC_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.ABSTRACT, GrModifierFlags.ABSTRACT_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.FINAL, GrModifierFlags.FINAL_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.NATIVE, GrModifierFlags.NATIVE_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.SYNCHRONIZED, GrModifierFlags.SYNCHRONIZED_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.STRICTFP, GrModifierFlags.STRICTFP_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.TRANSIENT, GrModifierFlags.TRANSIENT_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.VOLATILE, GrModifierFlags.VOLATILE_MASK);
|
||||
NAME_TO_MODIFIER_FLAG_MAP.put(GrModifier.DEF, GrModifierFlags.DEF_MASK);
|
||||
}
|
||||
|
||||
public GrModifierListImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public GrModifierListImpl(GrModifierListStub stub) {
|
||||
this(stub, GroovyElementTypes.MODIFIERS);
|
||||
}
|
||||
|
||||
public GrModifierListImpl(GrModifierListStub stub, IStubElementType nodeType) {
|
||||
super(stub, nodeType);
|
||||
}
|
||||
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitModifierList(this);
|
||||
}
|
||||
@@ -78,23 +109,29 @@ public class GrModifierListImpl extends GroovyPsiElementImpl implements GrModifi
|
||||
}
|
||||
|
||||
public boolean hasModifierProperty(@NotNull @NonNls String modifier) {
|
||||
final GrModifierListStub stub = getStub();
|
||||
if (stub != null) {
|
||||
final int flag = NAME_TO_MODIFIER_FLAG_MAP.get(modifier);
|
||||
return (stub.getModifiersFlags() & flag) != 0;
|
||||
}
|
||||
|
||||
final PsiElement parent = getParent();
|
||||
if (parent instanceof GrVariableDeclaration &&
|
||||
parent.getParent() instanceof GrTypeDefinitionBody &&
|
||||
!hasExplicitVisibilityModifiers()) { //properties are backed by private fields
|
||||
PsiElement pParent = parent.getParent().getParent();
|
||||
if (!(pParent instanceof PsiClass) || !((PsiClass)pParent).isInterface()) {
|
||||
if (modifier.equals(PsiModifier.PUBLIC)) return true;
|
||||
if (modifier.equals(PsiModifier.PROTECTED)) return false;
|
||||
if (modifier.equals(PsiModifier.PRIVATE)) return false;
|
||||
if (modifier.equals(GrModifier.PUBLIC)) return true;
|
||||
if (modifier.equals(GrModifier.PROTECTED)) return false;
|
||||
if (modifier.equals(GrModifier.PRIVATE)) return false;
|
||||
}
|
||||
else {
|
||||
if (modifier.equals(PsiModifier.STATIC)) return true;
|
||||
if (modifier.equals(PsiModifier.FINAL)) return true;
|
||||
if (modifier.equals(GrModifier.STATIC)) return true;
|
||||
if (modifier.equals(GrModifier.FINAL)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (modifier.equals(PsiModifier.PUBLIC)) {
|
||||
if (modifier.equals(GrModifier.PUBLIC)) {
|
||||
//groovy type definitions and methods are public by default
|
||||
return findChildByType(GroovyElementTypes.kPRIVATE) == null && findChildByType(GroovyElementTypes.kPROTECTED) == null;
|
||||
}
|
||||
@@ -104,11 +141,11 @@ public class GrModifierListImpl extends GroovyPsiElementImpl implements GrModifi
|
||||
}
|
||||
|
||||
if (!(parent instanceof GrVariableDeclaration)) {
|
||||
if (modifier.equals(PsiModifier.ABSTRACT)) {
|
||||
if (modifier.equals(GrModifier.ABSTRACT)) {
|
||||
return (parent instanceof GrTypeDefinition && ((GrTypeDefinition)parent).isInterface()) ||
|
||||
findChildByType(GroovyElementTypes.kABSTRACT) != null;
|
||||
}
|
||||
if (modifier.equals(PsiModifier.NATIVE)) return findChildByType(GroovyElementTypes.kNATIVE) != null;
|
||||
if (modifier.equals(GrModifier.NATIVE)) return findChildByType(GroovyElementTypes.kNATIVE) != null;
|
||||
}
|
||||
|
||||
if (!(parent instanceof GrTypeDefinition)) {
|
||||
@@ -129,8 +166,8 @@ public class GrModifierListImpl extends GroovyPsiElementImpl implements GrModifi
|
||||
assert psiClassAnnotation instanceof GrAnnotation;
|
||||
|
||||
if (GroovyImmutableAnnotationInspection.IMMUTABLE.equals(psiClassAnnotation.getQualifiedName())) {
|
||||
if (modifier.equals(PsiModifier.FINAL)) return true;
|
||||
if (modifier.equals(PsiModifier.PRIVATE)) return true;
|
||||
if (modifier.equals(GrModifier.FINAL)) return true;
|
||||
if (modifier.equals(GrModifier.PRIVATE)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,33 +178,33 @@ public class GrModifierListImpl extends GroovyPsiElementImpl implements GrModifi
|
||||
}
|
||||
|
||||
public boolean hasExplicitModifier(@NotNull @NonNls String name) {
|
||||
|
||||
if (name.equals(PsiModifier.PUBLIC)) return findChildByType(GroovyElementTypes.kPUBLIC) != null;
|
||||
if (name.equals(PsiModifier.ABSTRACT)) return findChildByType(GroovyElementTypes.kABSTRACT) != null;
|
||||
if (name.equals(PsiModifier.NATIVE)) return findChildByType(GroovyElementTypes.kNATIVE) != null;
|
||||
if (name.equals(GrModifier.PUBLIC)) return findChildByType(GroovyElementTypes.kPUBLIC) != null;
|
||||
if (name.equals(GrModifier.ABSTRACT)) return findChildByType(GroovyElementTypes.kABSTRACT) != null;
|
||||
if (name.equals(GrModifier.NATIVE)) return findChildByType(GroovyElementTypes.kNATIVE) != null;
|
||||
return hasOtherModifiers(name);
|
||||
}
|
||||
|
||||
private boolean hasOtherModifiers(String name) {
|
||||
if (name.equals(PsiModifier.PRIVATE)) return findChildByType(GroovyElementTypes.kPRIVATE) != null;
|
||||
if (name.equals(PsiModifier.PROTECTED)) return findChildByType(GroovyElementTypes.kPROTECTED) != null;
|
||||
if (name.equals(PsiModifier.SYNCHRONIZED)) return findChildByType(GroovyElementTypes.kSYNCHRONIZED) != null;
|
||||
if (name.equals(PsiModifier.STRICTFP)) return findChildByType(GroovyElementTypes.kSTRICTFP) != null;
|
||||
if (name.equals(PsiModifier.STATIC)) return findChildByType(GroovyElementTypes.kSTATIC) != null;
|
||||
if (name.equals(PsiModifier.FINAL)) return findChildByType(GroovyElementTypes.kFINAL) != null;
|
||||
if (name.equals(PsiModifier.TRANSIENT)) return findChildByType(GroovyElementTypes.kTRANSIENT) != null;
|
||||
return name.equals(PsiModifier.VOLATILE) && findChildByType(GroovyElementTypes.kVOLATILE) != null;
|
||||
if (name.equals(GrModifier.PRIVATE)) return findChildByType(GroovyElementTypes.kPRIVATE) != null;
|
||||
if (name.equals(GrModifier.PROTECTED)) return findChildByType(GroovyElementTypes.kPROTECTED) != null;
|
||||
if (name.equals(GrModifier.SYNCHRONIZED)) return findChildByType(GroovyElementTypes.kSYNCHRONIZED) != null;
|
||||
if (name.equals(GrModifier.STRICTFP)) return findChildByType(GroovyElementTypes.kSTRICTFP) != null;
|
||||
if (name.equals(GrModifier.STATIC)) return findChildByType(GroovyElementTypes.kSTATIC) != null;
|
||||
if (name.equals(GrModifier.FINAL)) return findChildByType(GroovyElementTypes.kFINAL) != null;
|
||||
if (name.equals(GrModifier.TRANSIENT)) return findChildByType(GroovyElementTypes.kTRANSIENT) != null;
|
||||
return name.equals(GrModifier.VOLATILE) && findChildByType(GroovyElementTypes.kVOLATILE) != null;
|
||||
}
|
||||
|
||||
public void setModifierProperty(@NotNull @NonNls String name, boolean doSet) throws IncorrectOperationException {
|
||||
if (PsiModifier.PACKAGE_LOCAL.equals(name)) {
|
||||
if (GrModifier.PACKAGE_LOCAL.equals(name)) {
|
||||
return;
|
||||
}
|
||||
if (doSet) {
|
||||
final ASTNode modifierNode = GroovyPsiElementFactory.getInstance(getProject()).createModifierFromText(name).getNode();
|
||||
if (!"def".equals(name)) {
|
||||
assert modifierNode != null;
|
||||
if (!GrModifier.DEF.equals(name)) {
|
||||
final PsiElement[] modifiers = getModifiers();
|
||||
if (modifiers.length == 1 && modifiers[0].getText().equals("def")) {
|
||||
if (modifiers.length == 1 && modifiers[0].getText().equals(GrModifier.DEF)) {
|
||||
getNode().replaceChild(findChildByType(GroovyTokenTypes.kDEF).getNode(), modifierNode);
|
||||
return;
|
||||
}
|
||||
@@ -191,6 +228,7 @@ public class GrModifierListImpl extends GroovyPsiElementImpl implements GrModifi
|
||||
public GrAnnotation[] getAnnotations() {
|
||||
return findChildrenByClass(GrAnnotation.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiAnnotation[] getApplicableAnnotations() {
|
||||
return getAnnotations();
|
||||
|
||||
+23
-3
@@ -89,7 +89,11 @@ public class GrFieldImpl extends GrVariableBaseImpl<GrFieldStub> implements GrFi
|
||||
}
|
||||
|
||||
public boolean isDeprecated() {
|
||||
return false;
|
||||
final GrFieldStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.isDeprecated();
|
||||
}
|
||||
return PsiImplUtil.isDeprecatedByDocTag(this) || PsiImplUtil.isDeprecatedByAnnotation(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,8 +141,10 @@ public class GrFieldImpl extends GrVariableBaseImpl<GrFieldStub> implements GrFi
|
||||
}
|
||||
|
||||
public boolean isProperty() {
|
||||
// final String name = getName();
|
||||
// if (!GroovyPropertyUtils.canBePropertyName(name)) return false;
|
||||
final GrFieldStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.isProperty();
|
||||
}
|
||||
final PsiClass clazz = getContainingClass();
|
||||
if (clazz == null) return false;
|
||||
if (clazz.isInterface()) return false;
|
||||
@@ -237,6 +243,16 @@ public class GrFieldImpl extends GrVariableBaseImpl<GrFieldStub> implements GrFi
|
||||
return PsiImplUtil.getMemberUseScope(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
final GrFieldStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getName();
|
||||
}
|
||||
return super.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPresentation getPresentation() {
|
||||
return new ItemPresentation() {
|
||||
@@ -285,6 +301,10 @@ public class GrFieldImpl extends GrVariableBaseImpl<GrFieldStub> implements GrFi
|
||||
|
||||
@NotNull
|
||||
public Set<String>[] getNamedParametersArray() {
|
||||
final GrFieldStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getNamedParameters();
|
||||
}
|
||||
final GrExpression initializerGroovy = getInitializerGroovy();
|
||||
|
||||
List<Set<String>> namedParameters = new LinkedList<Set<String>>();
|
||||
|
||||
+2
-1
@@ -34,6 +34,7 @@ import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrTupleDeclaration;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
@@ -190,7 +191,7 @@ public abstract class GrVariableBaseImpl<T extends StubElement> extends GroovyBa
|
||||
if (typeElement == null) return;
|
||||
final ASTNode typeElementNode = typeElement.getNode();
|
||||
final ASTNode parent = typeElementNode.getTreeParent();
|
||||
parent.addLeaf(GroovyTokenTypes.kDEF, "def", typeElementNode);
|
||||
parent.addLeaf(GroovyTokenTypes.kDEF, GrModifier.DEF, typeElementNode);
|
||||
parent.removeChild(typeElementNode);
|
||||
} else {
|
||||
type = TypesUtil.unboxPrimitiveTypeWrapper(type);
|
||||
|
||||
+20
-16
@@ -17,9 +17,9 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.path;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiArrayType;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,9 +27,9 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrExpressionImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
@@ -64,13 +64,26 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp
|
||||
PsiType thisType = selected.getType();
|
||||
|
||||
if (thisType != null) {
|
||||
if (thisType instanceof PsiArrayType) {
|
||||
PsiType componentType = ((PsiArrayType)thisType).getComponentType();
|
||||
return TypesUtil.boxPrimitiveType(componentType, getManager(), getResolveScope());
|
||||
}
|
||||
|
||||
GrArgumentList argList = getArgumentList();
|
||||
if (argList != null) {
|
||||
GrExpression[] arguments = argList.getExpressionArguments();
|
||||
PsiType[] argTypes = new PsiType[arguments.length];
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
PsiType argType = arguments[i].getType();
|
||||
if (argType == null) argType = TypesUtil.getJavaLangObject(argList);
|
||||
argTypes[i] = argType;
|
||||
}
|
||||
|
||||
final PsiType overloadedOperatorType = TypesUtil.getOverloadedOperatorType(thisType, "getAt", this, argTypes);
|
||||
if (overloadedOperatorType!=null) {
|
||||
return overloadedOperatorType;
|
||||
}
|
||||
|
||||
if (thisType instanceof PsiArrayType) {
|
||||
PsiType componentType = ((PsiArrayType)thisType).getComponentType();
|
||||
return TypesUtil.boxPrimitiveType(componentType, getManager(), getResolveScope());
|
||||
}
|
||||
|
||||
if (thisType instanceof GrTupleType) {
|
||||
PsiType[] types = ((GrTupleType)thisType).getParameters();
|
||||
return types.length == 1 ? types[0] : null;
|
||||
@@ -84,15 +97,6 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp
|
||||
if (InheritanceUtil.isInheritor(thisType, CommonClassNames.JAVA_UTIL_MAP)) {
|
||||
return PsiUtil.substituteTypeParameter(thisType, CommonClassNames.JAVA_UTIL_MAP, 1, true);
|
||||
}
|
||||
GrExpression[] arguments = argList.getExpressionArguments();
|
||||
PsiType[] argTypes = new PsiType[arguments.length];
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
PsiType argType = arguments[i].getType();
|
||||
if (argType == null) argType = TypesUtil.getJavaLangObject(argList);
|
||||
argTypes[i] = argType;
|
||||
}
|
||||
|
||||
return TypesUtil.getOverloadedOperatorType(thisType, "getAt", this, argTypes);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
+18
-14
@@ -100,6 +100,11 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl<GrTypeD
|
||||
|
||||
@Nullable
|
||||
public String getQualifiedName() {
|
||||
final GrTypeDefinitionStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getQualifiedName();
|
||||
}
|
||||
|
||||
final PsiClass containingClass = getContainingClass();
|
||||
if (containingClass != null) {
|
||||
return containingClass.getQualifiedName() + "." + getName();
|
||||
@@ -169,7 +174,11 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl<GrTypeD
|
||||
return (GrImplementsClause)findChildByType(GroovyElementTypes.IMPLEMENTS_CLAUSE);
|
||||
}
|
||||
|
||||
public String[] getSuperClassNames() {
|
||||
public String[] getSuperClassNames() {
|
||||
final GrTypeDefinitionStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getSuperClassNames();
|
||||
}
|
||||
return ArrayUtil.mergeArrays(getExtendsNames(), getImplementsNames(), String.class);
|
||||
}
|
||||
|
||||
@@ -231,8 +240,11 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl<GrTypeD
|
||||
return GrClassImplUtil.processDeclarations(this, processor, state, lastParent, place);
|
||||
}
|
||||
|
||||
// @NotNull
|
||||
public String getName() {
|
||||
final GrTypeDefinitionStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getName();
|
||||
}
|
||||
return PsiImplUtil.getName(this);
|
||||
}
|
||||
|
||||
@@ -241,7 +253,6 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl<GrTypeD
|
||||
return GrClassImplUtil.isClassEquivalentTo(this, another);
|
||||
}
|
||||
|
||||
//Fake java class implementation
|
||||
public boolean isInterface() {
|
||||
return false;
|
||||
}
|
||||
@@ -275,7 +286,7 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl<GrTypeD
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiClass getSuperClass() {
|
||||
public PsiClass getSuperClass() {
|
||||
return GrClassImplUtil.getSuperClass(this);
|
||||
}
|
||||
|
||||
@@ -289,7 +300,7 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl<GrTypeD
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiClassType[] getSuperTypes() {
|
||||
public PsiClassType[] getSuperTypes() {
|
||||
return GrClassImplUtil.getSuperTypes(this);
|
||||
}
|
||||
|
||||
@@ -532,7 +543,7 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl<GrTypeD
|
||||
}
|
||||
|
||||
public boolean isDeprecated() {
|
||||
return false;
|
||||
return com.intellij.psi.impl.PsiImplUtil.isDeprecatedByDocTag(this) || com.intellij.psi.impl.PsiImplUtil.isDeprecatedByAnnotation(this);
|
||||
}
|
||||
|
||||
public boolean hasTypeParameters() {
|
||||
@@ -716,14 +727,7 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl<GrTypeD
|
||||
GrTypeDefinitionBody body = getBody();
|
||||
if (body == null) throw new IncorrectOperationException("Type definition without a body");
|
||||
ASTNode anchorNode;
|
||||
if (anchorBefore != null) {
|
||||
anchorNode = anchorBefore.getNode();
|
||||
}
|
||||
else {
|
||||
PsiElement child = body.getLastChild();
|
||||
assert child != null;
|
||||
anchorNode = child.getNode();
|
||||
}
|
||||
anchorNode = anchorBefore.getNode();
|
||||
ASTNode bodyNode = body.getNode();
|
||||
bodyNode.addChild(decl.getNode(), anchorNode);
|
||||
bodyNode.addLeaf(GroovyTokenTypes.mWS, " ", decl.getNode()); //add whitespaces before and after to hack over incorrect auto reformat
|
||||
|
||||
+10
-6
@@ -19,7 +19,6 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.StubBasedPsiElement;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAnnotationMethod;
|
||||
@@ -50,13 +49,18 @@ public class GrAnnotationMethodImpl extends GrMethodBaseImpl<GrAnnotationMethodS
|
||||
return "Default annotation member";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Set<String> getNamedParameters(int paramNumber) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<String>[] getNamedParametersArray() {
|
||||
return new HashSet[0];
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
final GrAnnotationMethodStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getName();
|
||||
}
|
||||
return super.getName();
|
||||
}
|
||||
}
|
||||
|
||||
+21
@@ -23,6 +23,8 @@ import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Dmitry.Krasilschikov
|
||||
* @date 26.03.2007
|
||||
@@ -41,4 +43,23 @@ public class GrMethodImpl extends GrMethodBaseImpl<GrMethodStub> implements GrMe
|
||||
return "Method";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String>[] getNamedParametersArray() {
|
||||
final GrMethodStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getNamedParameters();
|
||||
}
|
||||
return super.getNamedParametersArray();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
final GrMethodStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getName();
|
||||
}
|
||||
return super.getName();
|
||||
}
|
||||
}
|
||||
@@ -36,4 +36,9 @@ public interface GrFieldStub extends NamedStub<GrField> {
|
||||
@NotNull
|
||||
Set<String>[] getNamedParameters();
|
||||
|
||||
boolean isProperty();
|
||||
|
||||
boolean isDeprecated();
|
||||
|
||||
byte getFlags();
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.plugins.groovy.lang.psi.stubs;
|
||||
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public interface GrModifierListStub extends StubElement<GrModifierList>{
|
||||
int getModifiersFlags();
|
||||
}
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class GrEnumConstantElementType extends GrStubElementType<GrFieldStub, Gr
|
||||
}
|
||||
}, new String[0]);
|
||||
}
|
||||
return new GrFieldStubImpl(parentStub, StringRef.fromString(psi.getName()), true, annNames, new Set[0], GroovyElementTypes.ENUM_CONSTANT);
|
||||
return new GrFieldStubImpl(parentStub, StringRef.fromString(psi.getName()), annNames, new Set[0], GroovyElementTypes.ENUM_CONSTANT, GrFieldStubImpl.buildFlags(psi));
|
||||
}
|
||||
|
||||
public void serialize(GrFieldStub stub, StubOutputStream dataStream) throws IOException {
|
||||
|
||||
+10
-8
@@ -25,8 +25,6 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.ENUM_CONSTANT;
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.FIELD;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrStubElementType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
|
||||
@@ -41,6 +39,9 @@ import org.jetbrains.plugins.groovy.lang.psi.stubs.index.GrFieldNameIndex;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.ENUM_CONSTANT;
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.FIELD;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
@@ -78,10 +79,10 @@ public class GrFieldElementType extends GrStubElementType<GrFieldStub, GrField>
|
||||
|
||||
Set<String>[] namedParametersArray = new Set[0];
|
||||
if (psi instanceof GrFieldImpl){
|
||||
namedParametersArray = ((GrFieldImpl)psi).getNamedParametersArray();
|
||||
namedParametersArray = psi.getNamedParametersArray();
|
||||
}
|
||||
|
||||
return new GrFieldStubImpl(parentStub, StringRef.fromString(psi.getName()), false, annNames, namedParametersArray, FIELD);
|
||||
return new GrFieldStubImpl(parentStub, StringRef.fromString(psi.getName()), annNames, namedParametersArray, FIELD, GrFieldStubImpl.buildFlags(psi));
|
||||
}
|
||||
|
||||
public void serialize(GrFieldStub stub, StubOutputStream dataStream) throws IOException {
|
||||
@@ -117,7 +118,7 @@ public class GrFieldElementType extends GrStubElementType<GrFieldStub, GrField>
|
||||
dataStream.writeUTF(namepParameter);
|
||||
}
|
||||
}
|
||||
dataStream.writeBoolean(stub.isEnumConstant());
|
||||
dataStream.writeByte(stub.getFlags());
|
||||
}
|
||||
|
||||
static GrFieldStub deserializeFieldStub(StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
@@ -144,9 +145,10 @@ public class GrFieldElementType extends GrStubElementType<GrFieldStub, GrField>
|
||||
namedParametersSets.add(curSet);
|
||||
}
|
||||
|
||||
boolean isEnumConstant = dataStream.readBoolean();
|
||||
return new GrFieldStubImpl(parentStub, ref, isEnumConstant, annNames, namedParametersSets.toArray(new HashSet[0]),
|
||||
isEnumConstant ? ENUM_CONSTANT : FIELD);
|
||||
byte flags = dataStream.readByte();
|
||||
|
||||
return new GrFieldStubImpl(parentStub, ref, annNames, namedParametersSets.toArray(new HashSet[namedParametersSets.size()]),
|
||||
GrFieldStubImpl.isEnumConstant(flags) ? ENUM_CONSTANT : FIELD, flags);
|
||||
}
|
||||
|
||||
static void indexFieldStub(GrFieldStub stub, IndexSink sink) {
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.plugins.groovy.lang.psi.stubs.elements;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrStubElementType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.modifiers.GrModifierListImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrModifierListStub;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.impl.GrModifierListStubImpl;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class GrModifierListElementType extends GrStubElementType<GrModifierListStub, GrModifierList> {
|
||||
public GrModifierListElementType(String debugName) {
|
||||
super(debugName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement createElement(ASTNode node) {
|
||||
return new GrModifierListImpl(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrModifierList createPsi(GrModifierListStub stub) {
|
||||
return new GrModifierListImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrModifierListStub createStub(GrModifierList psi, StubElement parentStub) {
|
||||
return new GrModifierListStubImpl(parentStub, GroovyElementTypes.MODIFIERS, GrModifierListStubImpl.buildFlags(psi));
|
||||
}
|
||||
|
||||
public void serialize(GrModifierListStub stub, StubOutputStream dataStream) throws IOException {
|
||||
dataStream.writeVarInt(stub.getModifiersFlags());
|
||||
}
|
||||
|
||||
public GrModifierListStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
return new GrModifierListStubImpl(parentStub, GroovyElementTypes.MODIFIERS, dataStream.readVarInt());
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class GrStubFileElementType extends IStubFileElementType<GrFileStub> {
|
||||
|
||||
@Override
|
||||
public int getStubVersion() {
|
||||
return super.getStubVersion() + 4;
|
||||
return super.getStubVersion() + 5;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
|
||||
+45
-4
@@ -22,6 +22,7 @@ import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrFieldStub;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -30,23 +31,31 @@ import java.util.Set;
|
||||
* @author ilyas
|
||||
*/
|
||||
public class GrFieldStubImpl extends StubBase<GrField> implements GrFieldStub {
|
||||
public static final byte IS_PROPERTY = 0x01;
|
||||
public static final byte IS_ENUM_CONSTANT = 0x02;
|
||||
public static final byte IS_DEPRECATED = 0x04;
|
||||
|
||||
private final boolean isEnumConstant;
|
||||
private final byte myFlags;
|
||||
private final StringRef myName;
|
||||
private final String[] myAnnotations;
|
||||
@Nullable
|
||||
private final Set<String>[] myNamedParameters;
|
||||
|
||||
public GrFieldStubImpl(StubElement parent, StringRef name, boolean isEnumConstant, final String[] annotations, @NotNull Set<String>[] namedParameters, final IStubElementType elemType) {
|
||||
public GrFieldStubImpl(StubElement parent,
|
||||
StringRef name,
|
||||
final String[] annotations,
|
||||
@NotNull Set<String>[] namedParameters,
|
||||
final IStubElementType elemType,
|
||||
byte flags) {
|
||||
super(parent, elemType);
|
||||
myName = name;
|
||||
this.isEnumConstant = isEnumConstant;
|
||||
myAnnotations = annotations;
|
||||
myNamedParameters = namedParameters;
|
||||
myFlags = flags;
|
||||
}
|
||||
|
||||
public boolean isEnumConstant() {
|
||||
return isEnumConstant;
|
||||
return (myFlags & IS_ENUM_CONSTANT) != 0;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -61,4 +70,36 @@ public class GrFieldStubImpl extends StubBase<GrField> implements GrFieldStub {
|
||||
public Set<String>[] getNamedParameters() {
|
||||
return myNamedParameters;
|
||||
}
|
||||
|
||||
public boolean isProperty() {
|
||||
return (myFlags & IS_PROPERTY) != 0;
|
||||
}
|
||||
|
||||
public boolean isDeprecated() {
|
||||
return (myFlags & IS_DEPRECATED) != 0;
|
||||
}
|
||||
|
||||
public byte getFlags() {
|
||||
return myFlags;
|
||||
}
|
||||
|
||||
public static byte buildFlags(GrField field) {
|
||||
byte f = 0;
|
||||
if (field instanceof GrEnumConstant) {
|
||||
f |= IS_ENUM_CONSTANT;
|
||||
}
|
||||
|
||||
if (field.isProperty()) {
|
||||
f |= IS_PROPERTY;
|
||||
}
|
||||
|
||||
if (field.isDeprecated()) {
|
||||
f|= IS_DEPRECATED;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
public static boolean isEnumConstant(byte flags) {
|
||||
return (flags & IS_ENUM_CONSTANT) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.plugins.groovy.lang.psi.stubs.impl;
|
||||
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.impl.cache.ModifierFlags;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.psi.stubs.StubBase;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrModifierListStub;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class GrModifierListStubImpl extends StubBase<GrModifierList> implements GrModifierListStub {
|
||||
private final int myFlags;
|
||||
|
||||
public GrModifierListStubImpl(StubElement parent, IStubElementType elementType, int flags) {
|
||||
super(parent, elementType);
|
||||
this.myFlags = flags;
|
||||
}
|
||||
|
||||
public int getModifiersFlags() {
|
||||
return myFlags;
|
||||
}
|
||||
|
||||
public static int buildFlags(GrModifierList modifierList) {
|
||||
int flags = 0;
|
||||
if (modifierList.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
flags |= ModifierFlags.ABSTRACT_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
flags |= ModifierFlags.FINAL_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.NATIVE)) {
|
||||
flags |= ModifierFlags.NATIVE_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
flags |= ModifierFlags.STATIC_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
|
||||
flags |= ModifierFlags.SYNCHRONIZED_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.TRANSIENT)) {
|
||||
flags |= ModifierFlags.TRANSIENT_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.VOLATILE)) {
|
||||
flags |= ModifierFlags.VOLATILE_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
flags |= ModifierFlags.PRIVATE_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.PROTECTED)) {
|
||||
flags |= ModifierFlags.PROTECTED_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
|
||||
flags |= ModifierFlags.PUBLIC_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) {
|
||||
flags |= ModifierFlags.PACKAGE_LOCAL_MASK;
|
||||
}
|
||||
if (modifierList.hasModifierProperty(PsiModifier.STRICTFP)) {
|
||||
flags |= ModifierFlags.STRICTFP_MASK;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.lang.resolve.noncode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
@@ -54,11 +55,11 @@ public class BindableAnnotationProcessor implements NonCodeMembersProcessor {
|
||||
for (GrAnnotation annotation : annotations) {
|
||||
if (BINDABLE.equals(annotation.getQualifiedName())) {
|
||||
GrMethod addPropertyChangeListenerMethod = GroovyPsiElementFactory.getInstance(annotation.getProject())
|
||||
.createMethodFromText("def", "addPropertyChangeListener", PsiType.VOID.getCanonicalText(),
|
||||
.createMethodFromText(GrModifier.DEF, "addPropertyChangeListener", PsiType.VOID.getCanonicalText(),
|
||||
new String[]{"PropertyChangeListener"});
|
||||
|
||||
GrMethod removePropertyChangeListenerMethod = GroovyPsiElementFactory.getInstance(annotation.getProject())
|
||||
.createMethodFromText("def", "removePropertyChangeListener", PsiType.VOID.getCanonicalText(),
|
||||
.createMethodFromText(GrModifier.DEF, "removePropertyChangeListener", PsiType.VOID.getCanonicalText(),
|
||||
new String[]{"PropertyChangeListener"});
|
||||
|
||||
GroovyResolveResultImpl addPropertyResult = new GroovyResolveResultImpl(addPropertyChangeListenerMethod, true);
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
@@ -56,7 +57,7 @@ public class VetoableAnnotationProcessor implements NonCodeMembersProcessor {
|
||||
if (VETOABLE.equals(annotation.getQualifiedName())) {
|
||||
Project project = annotation.getProject();
|
||||
GrVariableDeclaration vetoableChangeVar = GroovyPsiElementFactory.getInstance(project)
|
||||
.createVariableDeclaration(new String[]{"def"}, null, PsiType.getJavaLangObject(PsiManager.getInstance(project), GlobalSearchScope.allScope(
|
||||
.createVariableDeclaration(new String[]{GrModifier.DEF}, null, PsiType.getJavaLangObject(PsiManager.getInstance(project), GlobalSearchScope.allScope(
|
||||
project)), "vetoableChange");
|
||||
|
||||
GroovyResolveResultImpl vetoableChangeResult = new GroovyResolveResultImpl(vetoableChangeVar.getVariables()[0], true);
|
||||
|
||||
+2
-1
@@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrBlockStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
@@ -607,7 +608,7 @@ public class GroovyInlineMethodUtil {
|
||||
type = "";
|
||||
}
|
||||
if (modifiers.length() == 0 && type.length() == 0) {
|
||||
modifiers = "def";
|
||||
modifiers = GrModifier.DEF;
|
||||
}
|
||||
|
||||
return modifiers + " " + type + " " + varName + " = " + expression.getText();
|
||||
|
||||
@@ -201,4 +201,8 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
public void testStringAndGStringUpperBound() throws Exception {doTest();}
|
||||
|
||||
public void testWithMethod() throws Exception {doTest();}
|
||||
|
||||
public void testArrayLikeAccess() throws Exception {doTest();}
|
||||
}
|
||||
@@ -254,22 +254,95 @@ class ConfigObject extends LinkedHashMap implements Writable {
|
||||
}
|
||||
-----
|
||||
[Groovy script]
|
||||
[Modifiers]
|
||||
[Class definition : ConfigObject]
|
||||
[Modifiers]
|
||||
[Extends clause]
|
||||
[Implements clause]
|
||||
[Modifiers]
|
||||
[Field : KEYWORDS]
|
||||
[Modifiers]
|
||||
[Field : TAB_CHARACTER]
|
||||
[Modifiers]
|
||||
[Field : configFile]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : writeTo]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : getProperty]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : flatten]
|
||||
[Modifiers]
|
||||
[Method : flatten]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : merge]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : toProperties]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : toProperties]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : merge]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : writeConfig]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : writeValue]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : writeNode]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : convertValuesToString]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : populate]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
+72
-1
@@ -273,21 +273,92 @@ class ConfigBinding extends Binding {
|
||||
}
|
||||
-----
|
||||
[Groovy script]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Class definition : ConfigSlurper]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Field : ENV_METHOD]
|
||||
[Modifiers]
|
||||
[Field : ENV_SETTINGS]
|
||||
[Modifiers]
|
||||
[Field : classLoader]
|
||||
[Modifiers]
|
||||
[Field : environment]
|
||||
[Modifiers]
|
||||
[Field : envMode]
|
||||
[Modifiers]
|
||||
[Field : bindingVars]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : setBinding]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : parse]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : parse]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : parse]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : parse]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : parse]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : parse]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Class definition : ConfigBinding]
|
||||
[Modifiers]
|
||||
[Extends clause]
|
||||
[Modifiers]
|
||||
[Field : callable]
|
||||
[Method : setVariable]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Method : setVariable]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
+3
-1
@@ -4,4 +4,6 @@ interface I {}
|
||||
-----
|
||||
[Groovy script]
|
||||
[Class definition : A]
|
||||
[Interface definition : I]
|
||||
[Modifiers]
|
||||
[Interface definition : I]
|
||||
[Modifiers]
|
||||
+4
-1
@@ -5,5 +5,8 @@ class Boo{}
|
||||
-----
|
||||
[Groovy script]
|
||||
[Class definition : Stub]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Field : foo]
|
||||
[Class definition : Boo]
|
||||
[Class definition : Boo]
|
||||
[Modifiers]
|
||||
@@ -5,5 +5,9 @@ class Stub {
|
||||
-----
|
||||
[Groovy script]
|
||||
[Class definition : Stub]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
[Field : myInt]
|
||||
[Method : foo]
|
||||
[Modifiers]
|
||||
[Modifiers]
|
||||
@@ -0,0 +1,19 @@
|
||||
def foo = [1, 2, 5]
|
||||
def bar = [00, 11, 22, 33, 44, 55, 66, 77, 88]
|
||||
|
||||
// highlights right side as 'Can not assign Integer to Collection'
|
||||
Collection<Integer> baz = bar[foo]
|
||||
assert baz == [11, 22, 55]
|
||||
|
||||
// highlights right side as 'Can not assign Integer to Collection'
|
||||
Collection<Integer> qux = bar[[1, 2, 5]]
|
||||
assert qux == [11, 22, 55]
|
||||
|
||||
// accepted as correct
|
||||
Collection<Integer> quux = [bar[1], bar[5], bar[2]]
|
||||
assert quux == [11, 22, 55]
|
||||
|
||||
// highlights right side as 'Can not assign Integer to Collection'
|
||||
|
||||
Collection<Integer> quuux = bar[2..5]
|
||||
assert quuux == [22, 33, 44, 55]
|
||||
@@ -0,0 +1,9 @@
|
||||
final def calendar = Calendar.getInstance()
|
||||
|
||||
calendar.with {
|
||||
clear()
|
||||
set YEAR, 2009
|
||||
set MONTH, 7
|
||||
set DAY_OF_MONTH, 30
|
||||
println "Time is ${time}"
|
||||
}
|
||||
@@ -66,4 +66,8 @@ public class JUnitTestFramework implements TestFramework {
|
||||
}
|
||||
return inClass;
|
||||
}
|
||||
|
||||
public boolean isTestMethodOrConfig(PsiMethod psiMethod) {
|
||||
return JUnitUtil.isTestMethodOrConfig(psiMethod);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class TestCaseInfo extends ClassBasedInfo {
|
||||
MethodSignatureUtil.createMethodSignature(strippedMethodName, PsiType.EMPTY_ARRAY, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY), true);
|
||||
if (method != null)
|
||||
return new MethodLocation(project, method, classLocation);
|
||||
return classLocation;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean shouldRun() {
|
||||
|
||||
@@ -60,6 +60,9 @@ public class JUnit3OutputObjectRegistry extends OutputObjectRegistry {
|
||||
}
|
||||
addTestClass(packet, fullName);
|
||||
}
|
||||
else if (test instanceof TestRunnerUtil.SuiteMethodWrapper) {
|
||||
addTestClass(packet, ((TestRunnerUtil.SuiteMethodWrapper)test).getClassName());
|
||||
}
|
||||
else {
|
||||
addUnknownTest(packet, test);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user