mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -20,7 +20,6 @@ import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -55,11 +54,6 @@ public abstract class ProjectCategory {
|
||||
return createModuleBuilder().getGroupName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getParentId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public FrameworkRole[] getAcceptableFrameworkRoles() {
|
||||
return new FrameworkRole[] {createModuleBuilder().getDefaultAcceptableRole()};
|
||||
}
|
||||
|
||||
@@ -473,14 +473,21 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
|
||||
Disposer.dispose(this);
|
||||
}
|
||||
|
||||
private static MultiMap<String, ProjectTemplate> loadLocalTemplates() {
|
||||
private MultiMap<String, ProjectTemplate> loadLocalTemplates() {
|
||||
ConcurrentMultiMap<String, ProjectTemplate> map = new ConcurrentMultiMap<String, ProjectTemplate>();
|
||||
ProjectTemplateEP[] extensions = ProjectTemplateEP.EP_NAME.getExtensions();
|
||||
for (ProjectTemplateEP ep : extensions) {
|
||||
ClassLoader classLoader = ep.getLoaderForClass();
|
||||
URL url = classLoader.getResource(ep.templatePath);
|
||||
if (url != null) {
|
||||
map.putValue(ep.projectType, new LocalArchivedTemplate(url, classLoader));
|
||||
LocalArchivedTemplate template = new LocalArchivedTemplate(url, classLoader);
|
||||
if (ep.category) {
|
||||
TemplateBasedCategory category = new TemplateBasedCategory(template);
|
||||
myTemplatesMap.putValue(new TemplatesGroup(category), template);
|
||||
}
|
||||
else {
|
||||
map.putValue(ep.projectType, template);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
|
||||
+14
-15
@@ -15,42 +15,41 @@
|
||||
*/
|
||||
package com.intellij.ide.projectWizard;
|
||||
|
||||
import com.intellij.platform.templates.BuilderBasedTemplate;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.platform.templates.ArchivedProjectTemplate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class ProjectCategoryTemplate extends BuilderBasedTemplate {
|
||||
public class TemplateBasedCategory extends ProjectCategory {
|
||||
|
||||
private final ProjectCategory myCategory;
|
||||
private final ArchivedProjectTemplate myTemplate;
|
||||
|
||||
public ProjectCategoryTemplate(ProjectCategory category) {
|
||||
super(category.createModuleBuilder());
|
||||
myCategory = category;
|
||||
public TemplateBasedCategory(ArchivedProjectTemplate template) {
|
||||
myTemplate = template;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myCategory.getDisplayName();
|
||||
public String getDisplayName() {
|
||||
return myTemplate.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return myCategory.getIcon();
|
||||
return myTemplate.getIcon();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return myCategory.getDescription();
|
||||
return myTemplate.getDescription();
|
||||
}
|
||||
|
||||
public ProjectCategory getCategory() {
|
||||
return myCategory;
|
||||
@NotNull
|
||||
@Override
|
||||
public ModuleBuilder createModuleBuilder() {
|
||||
return myTemplate.createModuleBuilder();
|
||||
}
|
||||
}
|
||||
@@ -154,6 +154,11 @@ public class TemplateModuleBuilder extends ModuleBuilder {
|
||||
return myTemplate.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemplateBased() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiRefe
|
||||
String qName = aClass.getQualifiedName();
|
||||
if (qName != null) { //filter local classes
|
||||
if (qName.indexOf('.') == -1) continue; //do not show classes from default package)
|
||||
if (qName.endsWith(name) && ImportFilter.shouldImport(file, qName)) {
|
||||
if (qName.endsWith(name) && (file == null || ImportFilter.shouldImport(file, qName))) {
|
||||
if (isAccessible(aClass, myElement)) {
|
||||
classList.add(aClass);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.intellij.codeInsight;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Eugene.Kudelevsky
|
||||
@@ -11,9 +10,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class ImportFilter {
|
||||
public static final ExtensionPointName<ImportFilter> EP_NAME = new ExtensionPointName<ImportFilter>("com.intellij.importFilter");
|
||||
|
||||
public abstract boolean shouldUseFullyQualifiedName(@Nullable PsiFile targetFile, @NotNull String classQualifiedName);
|
||||
public abstract boolean shouldUseFullyQualifiedName(@NotNull PsiFile targetFile, @NotNull String classQualifiedName);
|
||||
|
||||
public static boolean shouldImport(@Nullable PsiFile targetFile, @NotNull String classQualifiedName) {
|
||||
public static boolean shouldImport(@NotNull PsiFile targetFile, @NotNull String classQualifiedName) {
|
||||
for (ImportFilter filter : EP_NAME.getExtensions()) {
|
||||
if (filter.shouldUseFullyQualifiedName(targetFile, classQualifiedName)) {
|
||||
return false;
|
||||
|
||||
@@ -33,4 +33,6 @@ public class ProjectTemplateEP extends AbstractExtensionPointBean {
|
||||
@Attribute("templatePath")
|
||||
public String templatePath;
|
||||
|
||||
@Attribute("category")
|
||||
public boolean category;
|
||||
}
|
||||
|
||||
+46
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2007 Bas Leijdekkers
|
||||
* Copyright 2005-2014 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,8 @@ import com.siyeh.ig.psiutils.EquivalenceChecker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class RedundantMethodOverrideInspection extends BaseInspection {
|
||||
|
||||
@Override
|
||||
@@ -107,19 +109,11 @@ public class RedundantMethodOverrideInspection extends BaseInspection {
|
||||
if (superBody == null) {
|
||||
return;
|
||||
}
|
||||
final PsiModifierList superModifierList =
|
||||
superMethod.getModifierList();
|
||||
final PsiModifierList modifierList = method.getModifierList();
|
||||
if (!EquivalenceChecker.modifierListsAreEquivalent(
|
||||
modifierList, superModifierList)) {
|
||||
if (!modifierListsAreEquivalent(method.getModifierList(), superMethod.getModifierList())) {
|
||||
return;
|
||||
}
|
||||
final PsiType superReturnType = superMethod.getReturnType();
|
||||
if (superReturnType == null) {
|
||||
return;
|
||||
}
|
||||
final PsiType returnType = method.getReturnType();
|
||||
if (!superReturnType.equals(returnType)) {
|
||||
if (superReturnType == null || !superReturnType.equals(method.getReturnType())) {
|
||||
return;
|
||||
}
|
||||
if (!EquivalenceChecker.codeBlocksAreEquivalent(body, superBody)) {
|
||||
@@ -127,5 +121,46 @@ public class RedundantMethodOverrideInspection extends BaseInspection {
|
||||
}
|
||||
registerMethodError(method);
|
||||
}
|
||||
|
||||
private static boolean modifierListsAreEquivalent(@Nullable PsiModifierList list1, @Nullable PsiModifierList list2) {
|
||||
if (list1 == null) {
|
||||
return list2 == null;
|
||||
}
|
||||
else if (list2 == null) {
|
||||
return false;
|
||||
}
|
||||
final Set<String> annotations1 = new HashSet();
|
||||
for (PsiAnnotation annotation : list1.getAnnotations()) {
|
||||
annotations1.add(annotation.getQualifiedName());
|
||||
}
|
||||
final Set<String> annotations2 = new HashSet();
|
||||
for (PsiAnnotation annotation : list2.getAnnotations()) {
|
||||
annotations2.add(annotation.getQualifiedName());
|
||||
}
|
||||
final Set<String> uniques = disjunction(annotations1, annotations2);
|
||||
uniques.remove(CommonClassNames.JAVA_LANG_OVERRIDE);
|
||||
if (!uniques.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return list1.hasModifierProperty(PsiModifier.STRICTFP) == list2.hasModifierProperty(PsiModifier.STRICTFP) &&
|
||||
list1.hasModifierProperty(PsiModifier.SYNCHRONIZED) == list2.hasModifierProperty(PsiModifier.SYNCHRONIZED) &&
|
||||
list1.hasModifierProperty(PsiModifier.PUBLIC) == list2.hasModifierProperty(PsiModifier.PUBLIC) &&
|
||||
list1.hasModifierProperty(PsiModifier.PROTECTED) == list2.hasModifierProperty(PsiModifier.PROTECTED);
|
||||
}
|
||||
|
||||
private static <T> Set<T> disjunction(Collection<T> set1, Collection<T> set2) {
|
||||
final Set<T> result = new HashSet();
|
||||
for (T t : set1) {
|
||||
if (!set2.contains(t)) {
|
||||
result.add(t);
|
||||
}
|
||||
}
|
||||
for (T t : set2) {
|
||||
if (!set1.contains(t)) {
|
||||
result.add(t);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-67
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2014 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.
|
||||
@@ -27,72 +27,6 @@ public class EquivalenceChecker {
|
||||
|
||||
private EquivalenceChecker() {}
|
||||
|
||||
public static boolean modifierListsAreEquivalent(
|
||||
@Nullable PsiModifierList list1, @Nullable PsiModifierList list2) {
|
||||
if (list1 == null) {
|
||||
return list2 == null;
|
||||
}
|
||||
else if (list2 == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiAnnotation[] annotations = list1.getAnnotations();
|
||||
for (PsiAnnotation annotation : annotations) {
|
||||
final String qualifiedName = annotation.getQualifiedName();
|
||||
if (qualifiedName == null) {
|
||||
return false;
|
||||
}
|
||||
if (list2.findAnnotation(qualifiedName) == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.ABSTRACT) &&
|
||||
!list2.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.FINAL) &&
|
||||
!list2.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.NATIVE) &&
|
||||
!list2.hasModifierProperty(PsiModifier.NATIVE)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) &&
|
||||
!list2.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.PRIVATE) &&
|
||||
!list2.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.PROTECTED) &&
|
||||
!list2.hasModifierProperty(PsiModifier.PROTECTED)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.PUBLIC) &&
|
||||
!list2.hasModifierProperty(PsiModifier.PUBLIC)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
!list2.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.STRICTFP) &&
|
||||
!list2.hasModifierProperty(PsiModifier.STRICTFP)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.SYNCHRONIZED) &&
|
||||
!list2.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
|
||||
return false;
|
||||
}
|
||||
if (list1.hasModifierProperty(PsiModifier.TRANSIENT) &&
|
||||
!list2.hasModifierProperty(PsiModifier.TRANSIENT)) {
|
||||
return false;
|
||||
}
|
||||
return !(list1.hasModifierProperty(PsiModifier.VOLATILE) &&
|
||||
!list2.hasModifierProperty(PsiModifier.VOLATILE));
|
||||
}
|
||||
|
||||
public static boolean statementsAreEquivalent(@Nullable PsiStatement statement1, @Nullable PsiStatement statement2) {
|
||||
if (statement1 == null) {
|
||||
return statement2 == null;
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package redundant_method_override;
|
||||
|
||||
public class RedundantMethodOverride extends S {
|
||||
|
||||
@Override
|
||||
void <warning descr="Method 'foo()' is identical to its super method">foo</warning>() {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
void bar() {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
public void m() {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
class S {
|
||||
|
||||
void foo() {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
synchronized void bar() {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
void m() {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.siyeh.ig.inheritance;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class RedundantMethodOverrideInspectionTest extends LightInspectionTestCase {
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new RedundantMethodOverrideInspection();
|
||||
}
|
||||
|
||||
public void testRedundantMethodOverride() { doTest(); }
|
||||
}
|
||||
@@ -63,6 +63,7 @@
|
||||
key="gradle.name" bundle="i18n.GradleBundle"/>
|
||||
<library.presentationProvider implementation="org.jetbrains.plugins.gradle.config.GradleLibraryPresentationProvider" order="last"/>
|
||||
<java.elementFinder implementation="org.jetbrains.plugins.gradle.config.GradleClassFinder"/>
|
||||
<editorTabTitleProvider implementation="org.jetbrains.plugins.gradle.util.GradleEditorTabTitleProvider"/>
|
||||
<projectOpenProcessor implementation="org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectOpenProcessor"/>
|
||||
<configurationType implementation="org.jetbrains.plugins.gradle.service.execution.GradleExternalTaskConfigurationType"/>
|
||||
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jetbrains.plugins.gradle.util;
|
||||
|
||||
import com.intellij.openapi.fileEditor.impl.EditorTabTitleProvider;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 2/5/14
|
||||
*/
|
||||
public class GradleEditorTabTitleProvider implements EditorTabTitleProvider {
|
||||
public String getEditorTabTitle(Project project, VirtualFile file) {
|
||||
if (GradleConstants.EXTENSION.equals(file.getExtension()) && GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName())) {
|
||||
for (Module module : ModuleManager.getInstance(project).getModules()) {
|
||||
if (module.isDisposed()) return null;
|
||||
|
||||
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
for (VirtualFile virtualFile : moduleRootManager.getContentRoots()) {
|
||||
if (virtualFile == file.getParent()) return module.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@
|
||||
<renamePsiElementProcessor implementation="org.jetbrains.plugins.javaFX.JavaFxRenameAttributeProcessor" order="before xmlAttribute"/>
|
||||
<completion.contributor implementationClass="org.jetbrains.plugins.javaFX.fxml.refs.JavaFxCompletionContributor" language="XML" order="before xmlNonFirst"/>
|
||||
<manifest.parser.provider implementation="org.jetbrains.plugins.javaFX.manifest.JavaFxManifestHeaderParsers"/>
|
||||
<projectTemplate projectType="Java" templatePath="resources/projectTemplates/Java/JavaFX Application.zip"/>
|
||||
<projectTemplate projectType="Java FX" templatePath="resources/projectTemplates/Java/JavaFX Application.zip" category="true"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
|
||||
@@ -180,7 +180,7 @@ public class JBTerminalPanel extends TerminalPanel implements FocusListener, Ter
|
||||
|
||||
@Override
|
||||
public void focusGained(FocusEvent event) {
|
||||
if (GeneralSettings.getInstance().isAutoSaveIfInactive()) {
|
||||
if (GeneralSettings.getInstance().isSaveOnFrameDeactivation()) {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1470,7 +1470,7 @@
|
||||
|
||||
<refactoring.pullUpHelperFactory language="JAVA" implementationClass="com.intellij.refactoring.memberPullUp.JavaPullUpHelperFactory"/>
|
||||
<hierarchy.referenceProcessor implementation="com.intellij.ide.hierarchy.call.JavaCallReferenceProcessor"/>
|
||||
<projectTemplate projectType="Java" templatePath="resources/projectTemplates/Java/Command_Line_App.zip"/>
|
||||
<projectTemplate projectType="JAVA_MODULE" templatePath="resources/projectTemplates/Java/Command_Line_App.zip"/>
|
||||
<generatedSourcesFilter implementation="com.intellij.openapi.roots.JavaGeneratedSourcesFilter"/>
|
||||
<refactoring.elementListenerProvider implementation="com.intellij.codeInspection.ex.AdditionalAnnotationsRefactoringElementListener"/>
|
||||
<projectOpenProcessor implementation="com.intellij.platform.PlatformProjectOpenProcessor"/>
|
||||
|
||||
Reference in New Issue
Block a user