From be5e85aedd2b5dca50e52f14c8a977e4db0e14e6 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Wed, 27 Sep 2017 10:56:31 +0300 Subject: [PATCH] type migration: make root search available on scratch files --- .../impl/quickfix/MethodReturnTypeFix.java | 20 +++---------- .../quickfix/VariableTypeFromCallFix.java | 20 +++---------- .../RawTypeCanBeGenericInspection.java | 20 +++---------- .../extractclass/ExtractEnumProcessor.java | 20 +++---------- .../typeMigration/TypeEvaluator.java | 20 +++---------- .../typeMigration/TypeMigrationLabeler.java | 25 ++++------------ .../typeMigration/TypeMigrationRules.java | 30 ++++++++----------- .../typeMigration/ui/TypeMigrationDialog.java | 20 +++---------- .../TypeMigrationVariableTypeFixProvider.java | 5 +++- .../inspections/GuavaInspection.java | 20 +++---------- .../ChangeClassParametersIntention.java | 5 +++- .../refactoring/ChangeTypeSignatureTest.java | 20 +++---------- .../refactoring/TypeMigrationTestBase.java | 20 +++---------- .../JavaFxFieldToPropertyIntention.java | 2 +- 14 files changed, 63 insertions(+), 184 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java index 871f077e312f..f3a0efad220f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2015 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.FileModificationService; @@ -351,7 +339,7 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle new PsiType[]{returnType}, PsiUtil.getLanguageLevel(superClass)); - final TypeMigrationRules rules = new TypeMigrationRules(); + final TypeMigrationRules rules = new TypeMigrationRules(project); final PsiSubstitutor compoundSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, derivedClass, PsiSubstitutor.EMPTY).putAll(psiSubstitutor); rules.setBoundScope(new LocalSearchScope(derivedClass)); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java index cc9e82757a90..d650e3a4f732 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2015 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.codeInsight.daemon.impl.quickfix; @@ -66,7 +54,7 @@ public class VariableTypeFromCallFix implements IntentionAction { @Override public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws IncorrectOperationException { - final TypeMigrationRules rules = new TypeMigrationRules(); + final TypeMigrationRules rules = new TypeMigrationRules(project); rules.setBoundScope(PsiSearchHelper.SERVICE.getInstance(project).getUseScope(myVar)); TypeMigrationProcessor.runHighlightingTypeMigration(project, editor, rules, myVar, myExpressionType); diff --git a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RawTypeCanBeGenericInspection.java b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RawTypeCanBeGenericInspection.java index 3c3b89e59f1e..f472564af03a 100644 --- a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RawTypeCanBeGenericInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RawTypeCanBeGenericInspection.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.codeInspection.miscGenerics; import com.intellij.codeInspection.*; @@ -118,7 +106,7 @@ public class RawTypeCanBeGenericInspection extends BaseJavaBatchLocalInspectionT final PsiVariable variable = (PsiVariable)element; final PsiType type = getSuggestedType(variable); if (type != null) { - final TypeMigrationRules rules = new TypeMigrationRules(); + final TypeMigrationRules rules = new TypeMigrationRules(project); rules.setBoundScope(PsiSearchHelper.SERVICE.getInstance(project).getUseScope(variable)); TypeMigrationProcessor.runHighlightingTypeMigration(project, null, rules, variable, type, false, true); } diff --git a/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractEnumProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractEnumProcessor.java index 8d1b79fb4555..8f2aa57b47ab 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractEnumProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractEnumProcessor.java @@ -1,18 +1,6 @@ -/* - * 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring.extractclass; @@ -141,7 +129,7 @@ public class ExtractEnumProcessor { } } - final TypeMigrationRules rules = new TypeMigrationRules(); + final TypeMigrationRules rules = new TypeMigrationRules(myProject); rules.addConversionDescriptor(new EnumTypeConversionRule(myEnumConstants)); rules.setBoundScope(GlobalSearchScope.projectScope(myProject)); myTypeMigrationProcessor = new TypeMigrationProcessor(myProject, diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java index c7784560f526..dba3956fb6af 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2014 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring.typeMigration; import com.intellij.openapi.diagnostic.Logger; @@ -55,7 +43,7 @@ public class TypeEvaluator { TypeMigrationLabeler labeler, Project project) { myLabeler = labeler; - myRules = labeler == null ? new TypeMigrationRules() : labeler.getRules(); + myRules = labeler == null ? new TypeMigrationRules(project) : labeler.getRules(); myTypeMap = new HashMap<>(); if (types != null) { diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java index ee8c09252e5a..83dcca312f4a 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring.typeMigration; import com.intellij.codeInsight.generation.GenerateMembersUtil; @@ -21,7 +9,6 @@ import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; @@ -1130,12 +1117,12 @@ public class TypeMigrationLabeler { return refs; } - private boolean canBeRoot(@Nullable PsiElement element, @NotNull SearchScope migrationScope) { + private static boolean canBeRoot(@Nullable PsiElement element, @NotNull SearchScope migrationScope) { if (element == null) return false; return element.isValid() && element.isPhysical() && - PsiSearchScopeUtil.isInScope(migrationScope, element) && - ProjectRootManager.getInstance(element.getProject()).getFileIndex().isInSourceContent(element.getContainingFile().getVirtualFile()); + element.isWritable() && + PsiSearchScopeUtil.isInScope(migrationScope, element); } @TestOnly diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationRules.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationRules.java index d156a0f5b4be..862b5baefd2f 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationRules.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationRules.java @@ -1,23 +1,14 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring.typeMigration; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.impl.LibraryScopeCache; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.SearchScope; import com.intellij.psi.util.TypeConversionUtil; import com.intellij.refactoring.typeMigration.rules.DisjunctionTypeConversionRule; @@ -25,6 +16,7 @@ import com.intellij.refactoring.typeMigration.rules.RootTypeConversionRule; import com.intellij.refactoring.typeMigration.rules.TypeConversionRule; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -39,9 +31,11 @@ import java.util.Map; public class TypeMigrationRules { private final List myConversionRules; private final Map myConversionCustomSettings = new HashMap<>(); + private final Project myProject; private SearchScope mySearchScope; - public TypeMigrationRules() { + public TypeMigrationRules(@NotNull Project project) { + myProject = project; final TypeConversionRule[] extensions = Extensions.getExtensions(TypeConversionRule.EP_NAME); myConversionRules = new ArrayList<>(extensions.length + 2); myConversionRules.add(new RootTypeConversionRule()); @@ -93,8 +87,8 @@ public class TypeMigrationRules { return myConversionRules.stream().anyMatch(rule -> rule.shouldConvertNullInitializer(from, to, context)); } - public void setBoundScope(final SearchScope searchScope) { - mySearchScope = searchScope; + public void setBoundScope(@NotNull SearchScope searchScope) { + mySearchScope = searchScope.intersectWith(GlobalSearchScope.notScope(LibraryScopeCache.getInstance(myProject).getLibrariesOnlyScope())); } public SearchScope getSearchScope() { diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java index bea30d1fabbd..33c71a1bc299 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring.typeMigration.ui; import com.intellij.find.FindSettings; @@ -95,7 +83,7 @@ public abstract class TypeMigrationDialog extends RefactoringDialog { } FindSettings.getInstance().setDefaultScopeName(myScopeChooserCombo.getSelectedScopeName()); if (myRules == null) { - myRules = new TypeMigrationRules(); + myRules = new TypeMigrationRules(getProject()); myRules.setBoundScope(myScopeChooserCombo.getSelectedScope()); } invokeRefactoring(new TypeMigrationProcessor(myProject, myRoots, getMigrationTypeFunction(), myRules, true)); diff --git a/java/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java b/java/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java index 7089f63bc112..3be863f7ccc5 100644 --- a/java/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java +++ b/java/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java @@ -1,3 +1,6 @@ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring.typeMigration; import com.intellij.codeInsight.FileModificationService; @@ -69,7 +72,7 @@ public class TypeMigrationVariableTypeFixProvider implements ChangeVariableTypeQ if (!FileModificationService.getInstance().prepareFileForWrite(variable.getContainingFile())) return; try { WriteAction.run(() -> variable.normalizeDeclaration()); - final TypeMigrationRules rules = new TypeMigrationRules(); + final TypeMigrationRules rules = new TypeMigrationRules(project); rules.setBoundScope(GlobalSearchScope.projectScope(project)); TypeMigrationProcessor.runHighlightingTypeMigration(project, editor, rules, variable, targetType, optimizeImports, allowDependentRoots); WriteAction.run(() -> JavaCodeStyleManager.getInstance(project).shortenClassReferences(variable)); diff --git a/java/typeMigration/src/com/intellij/refactoring/typeMigration/inspections/GuavaInspection.java b/java/typeMigration/src/com/intellij/refactoring/typeMigration/inspections/GuavaInspection.java index f44dd37496b2..40f884f037b1 100644 --- a/java/typeMigration/src/com/intellij/refactoring/typeMigration/inspections/GuavaInspection.java +++ b/java/typeMigration/src/com/intellij/refactoring/typeMigration/inspections/GuavaInspection.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2015 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring.typeMigration.inspections; import com.intellij.codeInsight.FileModificationService; @@ -350,7 +338,7 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool { private void performTypeMigration(List elements, List types) { if (!FileModificationService.getInstance().preparePsiElementsForWrite(elements)) return; final Project project = elements.get(0).getProject(); - final TypeMigrationRules rules = new TypeMigrationRules(); + final TypeMigrationRules rules = new TypeMigrationRules(project); rules.setBoundScope(GlobalSearchScopesCore.projectProductionScope(project) .union(GlobalSearchScopesCore.projectTestScope(project))); rules.addConversionRuleSettings(new GuavaConversionSettings(ignoreJavaxNullable)); diff --git a/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java b/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java index ac5bb83cea3a..ff01ad51a842 100644 --- a/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java +++ b/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java @@ -1,3 +1,6 @@ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring.typeMigration.intentions; import com.intellij.codeInsight.daemon.JavaErrorMessages; @@ -115,7 +118,7 @@ public class ChangeClassParametersIntention extends PsiElementBaseIntentionActio classType.getPresentableText())); return; } - final TypeMigrationRules myRules = new TypeMigrationRules(); + final TypeMigrationRules myRules = new TypeMigrationRules(project); final PsiSubstitutor substitutor = result.getSubstitutor().put(typeParameter, targetParam); final PsiType targetClassType = elementFactory.createType(baseClass, substitutor); myRules.setBoundScope(new LocalSearchScope(aClass)); diff --git a/java/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java b/java/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java index fefd04423b84..0dc37958a7dc 100644 --- a/java/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java +++ b/java/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring; @@ -47,7 +35,7 @@ public class ChangeTypeSignatureTest extends LightCodeInsightTestCase { PsiType migrationType = getJavaFacade().getElementFactory().createTypeFromText(migrationTypeText, null); try { - final TypeMigrationRules rules = new TypeMigrationRules(); + final TypeMigrationRules rules = new TypeMigrationRules(getProject()); rules.setBoundScope(GlobalSearchScope.projectScope(getProject())); new TypeMigrationProcessor(getProject(), new PsiElement[]{parameterList}, diff --git a/java/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java b/java/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java index 4a252efc809f..eaa490492457 100644 --- a/java/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java +++ b/java/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2015 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.intellij.refactoring; import com.intellij.openapi.command.WriteCommandAction; @@ -169,7 +157,7 @@ public abstract class TypeMigrationTestBase extends MultiFileTestCase { final PsiElement[] migrationElements = provider.victims(aClass); final PsiType migrationType = provider.migrationType(migrationElements[0]); - final TypeMigrationRules rules = new TypeMigrationRules(); + final TypeMigrationRules rules = new TypeMigrationRules(getProject()); rules.setBoundScope(new LocalSearchScope(aClass.getContainingFile())); final TestTypeMigrationProcessor pr = new TestTypeMigrationProcessor(getProject(), migrationElements, migrationType, rules); diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/codeInsight/JavaFxFieldToPropertyIntention.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/codeInsight/JavaFxFieldToPropertyIntention.java index e92d389de7c9..d823ef56e6f6 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/codeInsight/JavaFxFieldToPropertyIntention.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/codeInsight/JavaFxFieldToPropertyIntention.java @@ -119,7 +119,7 @@ public class JavaFxFieldToPropertyIntention extends PsiElementBaseIntentionActio final PsiType fromType = field.getType(); final PsiType toType = elementFactory.createTypeFromText(myProperty.myObservableType.myText, field); try { - final TypeMigrationRules rules = new TypeMigrationRules(); + final TypeMigrationRules rules = new TypeMigrationRules(myProject); final Set virtualFiles = ContainerUtil.map2SetNotNull(myFiles, PsiFile::getVirtualFile); rules.setBoundScope(GlobalSearchScope.filesScope(myProject, virtualFiles)); final TypeMigrationLabeler labeler = new TypeMigrationLabeler(rules, toType, myProject);