mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master' into develar/is
# Conflicts: # java/java-analysis-impl/src/com/intellij/codeInspection/RedundantSuppressInspectionBase.java # platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
This commit is contained in:
+2
-2
@@ -1,11 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="asm5">
|
||||
<library name="ASM">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/asm-all.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/asm5-src.zip!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/asm-src.zip!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -5,7 +5,7 @@ Index: org/objectweb/asm/ClassReader.java
|
||||
@@ -167,7 +167,7 @@
|
||||
this.b = b;
|
||||
// checks the class version
|
||||
if (readShort(off + 6) > Opcodes.V1_8) {
|
||||
if (readShort(off + 6) > Opcodes.V1_9) {
|
||||
- throw new IllegalArgumentException();
|
||||
+ //[JB: accept any version] throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<property name="src.dir" value="${basedir}/src"/>
|
||||
<property name="out.dir" value="${basedir}/out"/>
|
||||
<property name="src.zip" value="${basedir}/asm5-src.zip"/>
|
||||
<property name="src.zip" value="${basedir}/asm-src.zip"/>
|
||||
<property name="out.jar" value="${basedir}/asm-all.jar"/>
|
||||
|
||||
<target name="check">
|
||||
@@ -41,6 +41,7 @@
|
||||
<target name="patch" depends="unpack">
|
||||
<patch dir="${src.dir}" strip="0" patchfile="1_version_check.patch" failonerror="true"/>
|
||||
<patch dir="${src.dir}" strip="0" patchfile="2_coverage_fix.patch" failonerror="true"/>
|
||||
<delete file="${src.dir}/org/objectweb/asm/optimizer/ModuleInfoBndPlugin.java" quiet="true"/>
|
||||
</target>
|
||||
|
||||
<target name="repackage" depends="patch">
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="Groovy" level="project" />
|
||||
<orderEntry type="library" exported="" name="Ant" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="asm5" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="ASM" level="project" />
|
||||
<orderEntry type="library" exported="" scope="RUNTIME" name="cli-parser" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="JDOM" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Netty" level="project" />
|
||||
|
||||
@@ -171,11 +171,7 @@ libraryLicense(name: "Apache Commons Net", libraryName: "commons-net", version:
|
||||
libraryLicense(name: "Apache Lucene", libraryName: "lucene-core-2.4.1.jar", version: "2.4.1", license: "Apache 2.0", url: "http://lucene.apache.org/java")
|
||||
libraryLicense(name: "Apache Sanselan", libraryName: "Sanselan", version: "0.98", license: "Apache 2.0", url: "https://commons.apache.org/proper/commons-imaging/")
|
||||
libraryLicense(name: "Apache XML Graphics Commons", libraryName: "xmlgraphics-commons-1.3.1.jar", version: "1.3.1", license: "Apache 2.0", url: "http://xmlgraphics.apache.org/commons/", licenseUrl:"http://www.apache.org/licenses/LICENSE-2.0")
|
||||
libraryLicense(name: "asm-4.0-all", libraryName: "asm-4.0-all", version: "4.0", attachedTo: "ByteCodeViewer", license: "BSD", url: "http://asm.objectweb.org/", licenseUrl: "http://asm.objectweb.org/license.html")
|
||||
libraryLicense(name: "ASM Bytecode Manipulation Framework", libraryName: "asm-tools", version: "4.0", license: "BSD", url: "http://asm.objectweb.org/", licenseUrl: "http://asm.objectweb.org/license.html")
|
||||
libraryLicense(name: "ASM Bytecode Manipulation Framework", libraryName: "asm", version: "3.3", license: "BSD", url: "http://asm.objectweb.org/", licenseUrl: "http://asm.objectweb.org/license.html")
|
||||
libraryLicense(name: "ASM Bytecode Manipulation Framework", libraryName: "asm4", version: "4.0", license: "BSD", url: "http://asm.objectweb.org/", licenseUrl: "http://asm.objectweb.org/license.html")
|
||||
libraryLicense(name: "ASM Bytecode Manipulation Framework", libraryName: "asm5", version: "5.0.3 (with patches by JetBrains)", license: "BSD", url: "http://asm.objectweb.org/", licenseUrl: "http://asm.objectweb.org/license.html")
|
||||
libraryLicense(name: "ASM Bytecode Manipulation Framework", libraryName: "ASM", version: "6.0-ALPHA (with patches by JetBrains)", license: "BSD", url: "http://asm.objectweb.org/", licenseUrl: "http://asm.objectweb.org/license.html")
|
||||
libraryLicense(name: "assertJ", version: "3", license: "Apache 2.0", url: "https://github.com/joel-costigliola/assertj-core")
|
||||
libraryLicense(name: "Automaton", libraryName: "automaton.jar", version: "1.11", license: "BSD", url: "http://www.brics.dk/automaton/", licenseUrl: "http://www.opensource.org/licenses/bsd-license.php")
|
||||
libraryLicense(name: "Axis", libraryName: "axis-1.4", version: "1.4", license: "Apache 2.0", url: "http://ws.apache.org/axis/", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0.html")
|
||||
|
||||
@@ -466,14 +466,14 @@ final class ImageEditorUI extends JPanel implements DataProvider, CopyProvider,
|
||||
} else if (CommonDataKeys.VIRTUAL_FILE.is(dataId)) {
|
||||
return editor != null ? editor.getFile() : null;
|
||||
} else if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
|
||||
return editor != null ? new VirtualFile[]{editor.getFile()} : new VirtualFile[]{};
|
||||
return editor != null ? new VirtualFile[]{editor.getFile()} : VirtualFile.EMPTY_ARRAY;
|
||||
} else if (CommonDataKeys.PSI_FILE.is(dataId)) {
|
||||
return getData(CommonDataKeys.PSI_ELEMENT.getName());
|
||||
} else if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
|
||||
VirtualFile file = editor != null ? editor.getFile() : null;
|
||||
return file != null && file.isValid() ? PsiManager.getInstance(editor.getProject()).findFile(file) : null;
|
||||
} else if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
|
||||
return editor != null ? new PsiElement[]{(PsiElement)getData(CommonDataKeys.PSI_ELEMENT.getName())} : new PsiElement[]{} ;
|
||||
return editor != null ? new PsiElement[]{(PsiElement)getData(CommonDataKeys.PSI_ELEMENT.getName())} : PsiElement.EMPTY_ARRAY;
|
||||
} else if (PlatformDataKeys.COPY_PROVIDER.is(dataId) && copyPasteSupport != null) {
|
||||
return this;
|
||||
} else if (PlatformDataKeys.CUT_PROVIDER.is(dataId) && copyPasteSupport != null) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="JDOM" level="project" />
|
||||
<orderEntry type="module" module-name="forms_rt" />
|
||||
<orderEntry type="library" name="asm5" level="project" />
|
||||
<orderEntry type="library" name="ASM" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit3" level="project" />
|
||||
<orderEntry type="library" name="jgoodies-forms" level="project" />
|
||||
<orderEntry type="module" module-name="instrumentation-util" exported="" />
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<orderEntry type="library" name="Trove4j" level="project" />
|
||||
<orderEntry type="module" module-name="java-runtime" />
|
||||
<orderEntry type="module" module-name="instrumentation-util" />
|
||||
<orderEntry type="library" name="asm5" level="project" />
|
||||
<orderEntry type="library" name="ASM" level="project" />
|
||||
<orderEntry type="module" module-name="platform-api" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="jsp-openapi" />
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="asm5" level="project" />
|
||||
<orderEntry type="library" name="ASM" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
@@ -10,7 +10,7 @@
|
||||
<orderEntry type="library" name="Ant" level="project" />
|
||||
<orderEntry type="module" module-name="forms-compiler" />
|
||||
<orderEntry type="module" module-name="forms_rt" />
|
||||
<orderEntry type="library" name="asm5" level="project" />
|
||||
<orderEntry type="library" name="ASM" level="project" />
|
||||
<orderEntry type="module" module-name="instrumentation-util" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
@@ -165,5 +165,4 @@
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
@@ -244,7 +244,7 @@ public class ClassRenderer extends NodeRendererImpl{
|
||||
|
||||
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(node.getProject()).getElementFactory();
|
||||
try {
|
||||
return elementFactory.createExpressionFromText(fieldDescriptor.getField().name(), DebuggerUtils.findClass(
|
||||
return elementFactory.createExpressionFromText("this." + fieldDescriptor.getField().name(), DebuggerUtils.findClass(
|
||||
fieldDescriptor.getObject().referenceType().name(), context.getProject(), context.getDebugProcess().getSearchScope())
|
||||
);
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,6 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
@@ -176,7 +175,7 @@ public abstract class AbstractPatternBasedConfigurationProducer<T extends Module
|
||||
ContainerUtil.addIfNotNull(methods, PsiTreeUtil.getParentOfType(editorFile.findElementAt(caret.getOffset()), PsiMethod.class));
|
||||
}
|
||||
if (!methods.isEmpty()) {
|
||||
return collectTestMembers(methods.toArray(new PsiElement[0]), checkAbstract, checkIsTest, processor, classes);
|
||||
return collectTestMembers(methods.toArray(PsiElement.EMPTY_ARRAY), checkAbstract, checkIsTest, processor, classes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,11 +35,9 @@ import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -55,7 +53,7 @@ import java.util.List;
|
||||
*/
|
||||
public class LibrariesContainerFactory {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory");
|
||||
private static final Library[] EMPTY_LIBRARIES_ARRAY = new Library[0];
|
||||
private static final Library[] EMPTY_LIBRARIES_ARRAY = Library.EMPTY_ARRAY;
|
||||
|
||||
private LibrariesContainerFactory() {
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
<orderEntry type="module" module-name="java-analysis-api" exported="" />
|
||||
<orderEntry type="module" module-name="resources-en" />
|
||||
<orderEntry type="module" module-name="xml-psi-impl" />
|
||||
<orderEntry type="library" exported="" name="asm5" level="project" />
|
||||
<orderEntry type="library" exported="" name="ASM" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
+6
-8
@@ -29,7 +29,6 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiJavaModule;
|
||||
import com.intellij.psi.PsiJavaModuleReference;
|
||||
import com.intellij.psi.search.FilenameIndex;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -37,15 +36,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class ModuleHighlightUtil {
|
||||
private static final String MODULE_FILE_NAME = "module-info.java";
|
||||
import static com.intellij.psi.PsiJavaModule.MODULE_INFO_FILE;
|
||||
|
||||
public class ModuleHighlightUtil {
|
||||
@Nullable
|
||||
static HighlightInfo checkFileName(@NotNull PsiJavaModule element, @NotNull PsiFile file) {
|
||||
if (!MODULE_FILE_NAME.equals(file.getName())) {
|
||||
if (!MODULE_INFO_FILE.equals(file.getName())) {
|
||||
String message = JavaErrorMessages.message("module.file.wrong.name");
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(element)).description(message).create();
|
||||
QuickFixAction.registerQuickFixAction(info, factory().createRenameFileFix(MODULE_FILE_NAME));
|
||||
QuickFixAction.registerQuickFixAction(info, factory().createRenameFileFix(MODULE_INFO_FILE));
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -60,7 +59,7 @@ public class ModuleHighlightUtil {
|
||||
Module module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(vFile);
|
||||
if (module != null) {
|
||||
Collection<VirtualFile> others =
|
||||
FilenameIndex.getVirtualFilesByName(project, MODULE_FILE_NAME, new ModulesScope(Collections.singleton(module), project));
|
||||
FilenameIndex.getVirtualFilesByName(project, MODULE_INFO_FILE, new ModulesScope(Collections.singleton(module), project));
|
||||
if (others.size() > 1) {
|
||||
String message = JavaErrorMessages.message("module.file.duplicate");
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(element)).description(message).create();
|
||||
@@ -93,7 +92,6 @@ public class ModuleHighlightUtil {
|
||||
}
|
||||
|
||||
private static TextRange range(PsiJavaModule module) {
|
||||
PsiJavaModuleReference name = module.getNameElement();
|
||||
return name != null ? new TextRange(module.getTextOffset(), name.getTextRange().getEndOffset()) : module.getTextRange();
|
||||
return new TextRange(module.getTextOffset(), module.getNameElement().getTextRange().getEndOffset());
|
||||
}
|
||||
}
|
||||
+22
-1
@@ -224,7 +224,28 @@ public class RedundantSuppressInspectionBase extends GlobalInspectionTool {
|
||||
descriptors = new ArrayList<CommonProblemDescriptor>();
|
||||
globalContext.getRefManager().iterate(new RefVisitor() {
|
||||
@Override public void visitElement(@NotNull RefEntity refEntity) {
|
||||
CommonProblemDescriptor[] descriptors1 = global.getTool().checkElement(refEntity, scope, manager, globalContext, new ProblemDescriptionsProcessor() {
|
||||
CommonProblemDescriptor[]
|
||||
descriptors1 = global.getTool().checkElement(refEntity, scope, manager, globalContext, new ProblemDescriptionsProcessor() {
|
||||
@Nullable
|
||||
@Override
|
||||
public CommonProblemDescriptor[] getDescriptions(@NotNull RefEntity refEntity) {
|
||||
return CommonProblemDescriptor.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignoreElement(@NotNull RefEntity refEntity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProblemElement(@Nullable RefEntity refEntity, @NotNull CommonProblemDescriptor... commonProblemDescriptors) {
|
||||
int i =0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefEntity getElement(@NotNull CommonProblemDescriptor descriptor) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
if (descriptors1 != null) {
|
||||
ContainerUtil.addAll(descriptors, descriptors1);
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class JCiPUtil {
|
||||
public class JCiPUtil {
|
||||
static boolean isJCiPAnnotation(String ref) {
|
||||
return "Immutable".equals(ref) || "GuardedBy".equals(ref) || "ThreadSafe".equals(ref) || "NotThreadSafe".equals(ref);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,7 +59,7 @@ public class NonFinalFieldInImmutableInspection extends BaseJavaBatchLocalInspec
|
||||
if (!JCiPUtil.isImmutable(containingClass)) {
|
||||
return;
|
||||
}
|
||||
holder.registerProblem(field, "Non-final field #ref in @Immutable class #loc");
|
||||
holder.registerProblem(field.getNameIdentifier(), "Non-final field <code>#ref</code> in @Immutable class #loc");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ public class UnusedDeclarationInspectionBase extends GlobalInspectionTool {
|
||||
List<EntryPoint> deadCodeAddIns = new ArrayList<EntryPoint>(extensions.length);
|
||||
for (EntryPoint entryPoint : extensions) {
|
||||
try {
|
||||
deadCodeAddIns.add(entryPoint);
|
||||
deadCodeAddIns.add(entryPoint.clone());
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
|
||||
+1
-22
@@ -32,26 +32,10 @@ import javax.swing.*;
|
||||
|
||||
|
||||
public class RefPackageImpl extends RefEntityImpl implements RefPackage {
|
||||
private final String myQualifiedName;
|
||||
|
||||
public RefPackageImpl(@NotNull String name, @NotNull RefManager refManager) {
|
||||
super(getPackageSuffix(name), refManager);
|
||||
myQualifiedName = name;
|
||||
super(name, refManager);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getQualifiedName() {
|
||||
return myQualifiedName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getPackageSuffix(@NotNull String fullName) {
|
||||
int dotIndex = fullName.lastIndexOf('.');
|
||||
return (dotIndex >= 0) ? fullName.substring(dotIndex + 1) : fullName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull final RefVisitor visitor) {
|
||||
if (visitor instanceof RefJavaVisitor) {
|
||||
@@ -61,11 +45,6 @@ public class RefPackageImpl extends RefEntityImpl implements RefPackage {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExternalName() {
|
||||
return getQualifiedName();
|
||||
}
|
||||
|
||||
public static RefEntity packageFromFQName(final RefManager manager, final String name) {
|
||||
return manager.getExtension(RefJavaManager.MANAGER).getPackage(name);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<orderEntry type="module" module-name="jps-model-impl" />
|
||||
<orderEntry type="module" module-name="java-analysis-impl" exported="" />
|
||||
<orderEntry type="module" module-name="external-system-api" />
|
||||
<orderEntry type="library" name="asm5" level="project" />
|
||||
<orderEntry type="library" name="ASM" level="project" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
<orderEntry type="library" name="Xerces" level="project" />
|
||||
<orderEntry type="library" name="Velocity" level="project" />
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,7 +80,7 @@ public class FunctionalExpressionCompletionProvider extends CompletionProvider<C
|
||||
final PsiType functionalInterfaceType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(defaultType);
|
||||
final PsiMethod functionalInterfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType);
|
||||
if (functionalInterfaceMethod != null) {
|
||||
PsiParameter[] params = new PsiParameter[0];
|
||||
PsiParameter[] params = PsiParameter.EMPTY_ARRAY;
|
||||
final PsiElement originalPosition = parameters.getPosition();
|
||||
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(functionalInterfaceMethod, PsiUtil.resolveGenericsClassInType(functionalInterfaceType));
|
||||
if (!functionalInterfaceMethod.hasTypeParameters()) {
|
||||
|
||||
@@ -906,7 +906,7 @@ public class JavaDocInfoGenerator {
|
||||
generateAnnotations(buffer, owner, ownerModifierList.getAnnotations(), false, generateLink, splitAnnotations, useShortNames);
|
||||
PsiAnnotation[] externalAnnotations = ExternalAnnotationsManager.getInstance(owner.getProject()).findExternalAnnotations(owner);
|
||||
if (externalAnnotations == null) {
|
||||
externalAnnotations = new PsiAnnotation[]{};
|
||||
externalAnnotations = PsiAnnotation.EMPTY_ARRAY;
|
||||
}
|
||||
PsiAnnotation[] inferredAnnotations = InferredAnnotationsManager.getInstance(owner.getProject()).findInferredAnnotations(owner);
|
||||
externalAnnotations = ArrayUtil.mergeArrays(externalAnnotations, inferredAnnotations, PsiAnnotation.ARRAY_FACTORY);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,6 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usages.*;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StaticIconFieldsAction extends AnAction {
|
||||
@@ -45,7 +44,7 @@ public class StaticIconFieldsAction extends AnAction {
|
||||
final UsageViewPresentation presentation = new UsageViewPresentation();
|
||||
presentation.setTabName("Statics");
|
||||
presentation.setTabText("Statitcs");
|
||||
final UsageView view = UsageViewManager.getInstance(project).showUsages(UsageTarget.EMPTY_ARRAY, new Usage[0], presentation);
|
||||
final UsageView view = UsageViewManager.getInstance(project).showUsages(UsageTarget.EMPTY_ARRAY, Usage.EMPTY_ARRAY, presentation);
|
||||
|
||||
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Searching icons usages") {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -101,7 +101,7 @@ public class ConvertToInstanceMethodProcessor extends BaseRefactoringProcessor {
|
||||
final Project project = myMethod.getProject();
|
||||
|
||||
final PsiReference[] methodReferences =
|
||||
ReferencesSearch.search(myMethod, GlobalSearchScope.projectScope(project), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(myMethod, GlobalSearchScope.projectScope(project), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
List<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
for (final PsiReference ref : methodReferences) {
|
||||
final PsiElement element = ref.getElement();
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -104,7 +104,8 @@ public abstract class ExtractSuperBaseProcessor extends TurnRefsToSuperProcessor
|
||||
|
||||
@NotNull
|
||||
protected UsageInfo[] findUsages() {
|
||||
PsiReference[] refs = ReferencesSearch.search(myClass, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
PsiReference[] refs = ReferencesSearch.search(myClass, GlobalSearchScope.projectScope(myProject), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY);
|
||||
final ArrayList<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
detectTurnToSuperRefs(refs, result);
|
||||
final PsiPackage originalPackage = JavaDirectoryService.getInstance().getPackage(myClass.getContainingFile().getContainingDirectory());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,7 +55,6 @@ import com.intellij.refactoring.rename.RenameJavaVariableProcessor;
|
||||
import com.intellij.refactoring.util.*;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewDescriptor;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
@@ -1108,7 +1107,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
if (isAccessedForWriting) {
|
||||
if (refVar.hasModifierProperty(PsiModifier.FINAL) || shouldBeFinal) return false;
|
||||
PsiReference[] refs =
|
||||
ReferencesSearch.search(refVar, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(refVar, GlobalSearchScope.projectScope(myProject), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
return refs.length == 1; //TODO: control flow
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.FileTypeUtils;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
@@ -40,7 +41,6 @@ import com.intellij.refactoring.util.EnumConstantsUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.psi.util.FileTypeUtils;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -295,7 +295,7 @@ public abstract class LocalToFieldHandler {
|
||||
final boolean rebindNeeded2 = !myVariableName.equals(myFieldName) || myRebindNeeded;
|
||||
final PsiReference[] refs;
|
||||
if (rebindNeeded2) {
|
||||
refs = ReferencesSearch.search(myLocal, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
refs = ReferencesSearch.search(myLocal, GlobalSearchScope.projectScope(myProject), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
}
|
||||
else {
|
||||
refs = null;
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,6 @@ import com.intellij.refactoring.util.CanonicalTypes;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.javadoc.MethodJavaDocHelper;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
@@ -304,7 +303,7 @@ public class MakeMethodStaticProcessor extends MakeMethodOrClassStaticProcessor<
|
||||
|
||||
PsiElement anchor = null;
|
||||
PsiExpressionList argList = null;
|
||||
PsiExpression[] exprs = new PsiExpression[0];
|
||||
PsiExpression[] exprs = PsiExpression.EMPTY_ARRAY;
|
||||
if (parent instanceof PsiMethodCallExpression) {
|
||||
argList = ((PsiMethodCallExpression)parent).getArgumentList();
|
||||
exprs = argList.getExpressions();
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.intention.AddAnnotationFix;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
@@ -552,7 +551,7 @@ public class JavaPullUpHelper implements PullUpHelper<MemberInfo> {
|
||||
}
|
||||
if (doLookup) {
|
||||
final PsiReference[] references =
|
||||
ReferencesSearch.search(field, new LocalSearchScope(statement), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(field, new LocalSearchScope(statement), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
if (commonInitializerCandidate == null && references.length > 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -155,7 +155,7 @@ public class PullUpConflictsUtil {
|
||||
ContainerUtil.addIfNotNull(checkModuleConflictsList, method.getTypeParameterList());
|
||||
}
|
||||
RefactoringConflictsUtil.analyzeModuleConflicts(subclass.getProject(), checkModuleConflictsList,
|
||||
new UsageInfo[0], targetRepresentativeElement, conflicts);
|
||||
UsageInfo.EMPTY_ARRAY, targetRepresentativeElement, conflicts);
|
||||
|
||||
final PsiFile psiFile = PsiTreeUtil.getParentOfType(subclass, PsiClassOwner.class);
|
||||
final boolean toDifferentPackage = !Comparing.strEqual(targetPackage.getQualifiedName(),
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -211,7 +211,7 @@ public class JavaMoveClassesOrPackagesHandler extends MoveHandlerDelegate {
|
||||
return;
|
||||
}
|
||||
final MoveClassesOrPackagesToNewDirectoryDialog dlg =
|
||||
new MoveClassesOrPackagesToNewDirectoryDialog(directories[0], new PsiElement[0], false, callback) {
|
||||
new MoveClassesOrPackagesToNewDirectoryDialog(directories[0], PsiElement.EMPTY_ARRAY, false, callback) {
|
||||
@Override
|
||||
protected BaseRefactoringProcessor createRefactoringProcessor(Project project,
|
||||
final PsiDirectory targetDirectory,
|
||||
|
||||
@@ -31,7 +31,7 @@ public class SearchUtils{
|
||||
|
||||
public static Iterable<PsiReference> findAllReferences(PsiElement element, SearchScope scope){
|
||||
|
||||
return new ArrayIterable<PsiReference>(ReferencesSearch.search(element, scope, true).toArray(new PsiReference[0]));
|
||||
return new ArrayIterable<PsiReference>(ReferencesSearch.search(element, scope, true).toArray(PsiReference.EMPTY_ARRAY));
|
||||
/*
|
||||
try {
|
||||
Class<?> searchClass = Class.forName("com.intellij.psi.search.searches.ReferencesSearch");
|
||||
@@ -59,12 +59,12 @@ public class SearchUtils{
|
||||
}
|
||||
|
||||
public static Iterable<PsiMethod> findOverridingMethods(PsiMethod method){
|
||||
return new ArrayIterable<PsiMethod>(OverridingMethodsSearch.search(method).toArray(new PsiMethod[0]));
|
||||
return new ArrayIterable<PsiMethod>(OverridingMethodsSearch.search(method).toArray(PsiMethod.EMPTY_ARRAY));
|
||||
// return OverridingMethodsSearch.search(method, method.getUseScope(), true).findAll();
|
||||
}
|
||||
|
||||
public static Iterable<PsiClass> findClassInheritors(PsiClass aClass, boolean deep){
|
||||
return new ArrayIterable<PsiClass>(ClassInheritorsSearch.search(aClass, deep).toArray(new PsiClass[0]));
|
||||
return new ArrayIterable<PsiClass>(ClassInheritorsSearch.search(aClass, deep).toArray(PsiClass.EMPTY_ARRAY));
|
||||
// return ClassInheritorsSearch.search(aClass, deep);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ public class ReplaceConstructorWithBuilderViewDescriptor extends UsageViewDescri
|
||||
|
||||
@NotNull
|
||||
public PsiElement[] getElements() {
|
||||
return new PsiElement[0];
|
||||
return PsiElement.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public String getProcessedElementsHeader() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -79,7 +79,8 @@ public class TempWithQueryHandler implements RefactoringActionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
final PsiReference[] refs = ReferencesSearch.search(local, GlobalSearchScope.projectScope(project), false).toArray(new PsiReference[0]);
|
||||
final PsiReference[] refs = ReferencesSearch.search(local, GlobalSearchScope.projectScope(project), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY);
|
||||
|
||||
if (refs.length == 0) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("variable.is.never.used", localName));
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,7 +68,8 @@ public class TurnRefsToSuperProcessor extends TurnRefsToSuperProcessorBase {
|
||||
|
||||
@NotNull
|
||||
protected UsageInfo[] findUsages() {
|
||||
final PsiReference[] refs = ReferencesSearch.search(myClass, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
final PsiReference[] refs = ReferencesSearch.search(myClass, GlobalSearchScope.projectScope(myProject), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY);
|
||||
|
||||
final ArrayList<UsageInfo> result = detectTurnToSuperRefs(refs, new ArrayList<UsageInfo>());
|
||||
|
||||
|
||||
@@ -823,7 +823,8 @@ public class TypeMigrationLabeler {
|
||||
}
|
||||
|
||||
public PsiReference[] markRootUsages(final PsiElement element, final PsiType migrationType) {
|
||||
return markRootUsages(element, migrationType, ReferencesSearch.search(element, myRules.getSearchScope(), false).toArray(new PsiReference[0]));
|
||||
return markRootUsages(element, migrationType, ReferencesSearch.search(element, myRules.getSearchScope(), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY));
|
||||
}
|
||||
|
||||
PsiReference[] markRootUsages(final PsiElement element, final PsiType migrationType, final PsiReference[] refs) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ public class ClassReferenceSearchingScanner extends ClassReferenceScanner {
|
||||
|
||||
public PsiReference[] findReferences() {
|
||||
GlobalSearchScope projectScope = GlobalSearchScope.projectScope(myClass.getProject());
|
||||
return ReferencesSearch.search(myClass, projectScope, false).toArray(new PsiReference[0]);
|
||||
return ReferencesSearch.search(myClass, projectScope, false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ class SliceUtil {
|
||||
// for erased method calls for which we cannot determine target substitutor,
|
||||
// rely on call argument types. I.e. new Pair(1,2) -> Pair<Integer, Integer>
|
||||
if (element instanceof PsiTypeParameterListOwner && PsiUtil.isRawSubstitutor((PsiTypeParameterListOwner)element, substitutor)) {
|
||||
PsiTypeParameter[] typeParameters = substitutor.getSubstitutionMap().keySet().toArray(new PsiTypeParameter[0]);
|
||||
PsiTypeParameter[] typeParameters = substitutor.getSubstitutionMap().keySet().toArray(PsiTypeParameter.EMPTY_ARRAY);
|
||||
|
||||
PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(project).getResolveHelper();
|
||||
substitutor = resolveHelper.inferTypeArguments(typeParameters, actualParameters, expressions, parentSubstitutor, argumentList,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a Java module declaration.
|
||||
@@ -23,6 +23,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @since 2016.3
|
||||
*/
|
||||
public interface PsiJavaModule extends PsiElement {
|
||||
@Nullable PsiJavaModuleReference getNameElement();
|
||||
@Nullable String getModuleName();
|
||||
String MODULE_INFO_CLASS = "module-info";
|
||||
String MODULE_INFO_FILE = MODULE_INFO_CLASS + ".java";
|
||||
|
||||
@NotNull PsiJavaModuleReference getNameElement();
|
||||
@NotNull String getModuleName();
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
<orderEntry type="module" module-name="java-psi-api" exported="" />
|
||||
<orderEntry type="module" module-name="core-impl" exported="" />
|
||||
<orderEntry type="module" module-name="resources-en" />
|
||||
<orderEntry type="library" name="asm5" level="project" />
|
||||
<orderEntry type="library" name="ASM" level="project" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -32,7 +32,7 @@ public class PsiImportListImpl extends JavaStubPsiElement<PsiImportListStub> imp
|
||||
private volatile Map<String,PsiImportStatement> myClassNameToImportMap;
|
||||
private volatile Map<String,PsiImportStatement> myPackageNameToImportMap;
|
||||
private volatile Map<String,PsiImportStatementBase> myNameToSingleImportMap;
|
||||
private static final PsiImportStatementBase[] EMPTY_ARRAY = new PsiImportStatementBase[0];
|
||||
private static final PsiImportStatementBase[] EMPTY_ARRAY = PsiImportStatementBase.EMPTY_ARRAY;
|
||||
private static final ArrayFactory<PsiImportStatementBase> ARRAY_FACTORY = new ArrayFactory<PsiImportStatementBase>() {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -15,29 +15,30 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.JavaElementVisitor;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiJavaModule;
|
||||
import com.intellij.psi.PsiJavaModuleReference;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PsiJavaModuleImpl extends CompositePsiElement implements PsiJavaModule {
|
||||
public PsiJavaModuleImpl() {
|
||||
super(JavaElementType.MODULE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiJavaModuleReference getNameElement() {
|
||||
return PsiTreeUtil.getChildOfType(this, PsiJavaModuleReference.class);
|
||||
return PsiTreeUtil.getRequiredChildOfType(this, PsiJavaModuleReference.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
PsiJavaModuleReference nameElement = getNameElement();
|
||||
return nameElement != null ? nameElement.getReferenceText() : null;
|
||||
return getNameElement().getReferenceText();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -771,7 +771,7 @@ public class InferenceSession {
|
||||
restParamSubstitution = restParamSubstitution.put(typeParameters[i], parameter);
|
||||
}
|
||||
}
|
||||
return initBounds(null, restParamSubstitution, capturedParams.toArray(new PsiTypeParameter[0]));
|
||||
return initBounds(null, restParamSubstitution, capturedParams.toArray(PsiTypeParameter.EMPTY_ARRAY));
|
||||
}
|
||||
return initBounds(null, typeParameters);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<orderEntry type="library" name="Velocity" level="project" />
|
||||
<orderEntry type="module" module-name="java-i18n" exported="" />
|
||||
<orderEntry type="module" module-name="compiler-impl" />
|
||||
<orderEntry type="library" name="asm5" level="project" />
|
||||
<orderEntry type="library" name="ASM" level="project" />
|
||||
<orderEntry type="module" module-name="instrumentation-util" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="IntelliLang-java" scope="RUNTIME" />
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.generation.EqualsHashCodeTemplatesManager;
|
||||
@@ -13,12 +28,12 @@ public class GenerateEquals15Test extends GenerateEqualsTestCase {
|
||||
}
|
||||
|
||||
public void testDifferentTypes() throws Exception {
|
||||
doTest(Function.ID, Function.ID, fields -> new PsiField[0], true
|
||||
doTest(Function.ID, Function.ID, fields -> PsiField.EMPTY_ARRAY, true
|
||||
);
|
||||
}
|
||||
|
||||
public void testDifferentTypesGetters() throws Exception {
|
||||
doTest(Function.ID, Function.ID, fields -> new PsiField[0], true, true);
|
||||
doTest(Function.ID, Function.ID, fields -> PsiField.EMPTY_ARRAY, true, true);
|
||||
}
|
||||
|
||||
public void testDifferentTypesAllNotNull() throws Exception {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.find.findUsages;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
@@ -25,7 +40,7 @@ public class FindParameterTest extends PsiTestCase {
|
||||
final PsiMethod methodFromText = elementFactory.createMethodFromText(text, null);
|
||||
final PsiParameter[] parameters = methodFromText.getParameterList().getParameters();
|
||||
final PsiReference[] references =
|
||||
ReferencesSearch.search(parameters[0], new LocalSearchScope(methodFromText), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(parameters[0], new LocalSearchScope(methodFromText), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
Assert.assertEquals(references.length, 2);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import java.io.File;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ClsBuilderTest extends LightIdeaTestCase {
|
||||
public class ClsStubBuilderTest extends LightIdeaTestCase {
|
||||
public void testUtilList() { doTest("java/util/List.class"); }
|
||||
public void testNullable() { doTest("org/jetbrains/annotations/Nullable.class"); }
|
||||
public void testUtilCollections() { doTest("java/util/Collections.class"); }
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.psi.search;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
@@ -47,12 +46,12 @@ public class FindUsages15Test extends PsiTestCase{
|
||||
PsiMethod[] constructors = enumClass.getConstructors();
|
||||
assertEquals(2, constructors.length);
|
||||
PsiReference[] references0 =
|
||||
ReferencesSearch.search(constructors[0], GlobalSearchScope.moduleScope(myModule), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(constructors[0], GlobalSearchScope.moduleScope(myModule), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
assertEquals(2, references0.length);
|
||||
assertTrue(references0[0].getElement() instanceof PsiEnumConstant);
|
||||
assertTrue(references0[1].getElement() instanceof PsiEnumConstant);
|
||||
PsiReference[] references1 =
|
||||
ReferencesSearch.search(constructors[1], GlobalSearchScope.moduleScope(myModule), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(constructors[1], GlobalSearchScope.moduleScope(myModule), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
assertEquals(1, references1.length);
|
||||
assertTrue(references1[0].getElement() instanceof PsiEnumConstant);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -148,7 +148,7 @@ public class SearchInLibsTest extends PsiTestCase {
|
||||
final PsiClass aClass = myJavaFacade.findClass(classNameToSearch);
|
||||
assertNotNull(aClass);
|
||||
|
||||
PsiReference[] refs = ReferencesSearch.search(aClass, scope, false).toArray(new PsiReference[0]);
|
||||
PsiReference[] refs = ReferencesSearch.search(aClass, scope, false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
|
||||
ArrayList<PsiFile> files = new ArrayList<>();
|
||||
for (PsiReference ref : refs) {
|
||||
|
||||
@@ -45,13 +45,15 @@ import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.PsiTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@PlatformTestCase.WrapInCommand
|
||||
public class UpdateCacheTest extends PsiTestCase {
|
||||
@@ -406,7 +408,8 @@ public class UpdateCacheTest extends PsiTestCase {
|
||||
}
|
||||
|
||||
private void checkUsages(PsiElement element, @NonNls String[] expectedFiles){
|
||||
PsiReference[] refs = ReferencesSearch.search(element, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
PsiReference[] refs = ReferencesSearch.search(element, GlobalSearchScope.projectScope(myProject), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY);
|
||||
|
||||
List<PsiFile> files = new ArrayList<PsiFile>();
|
||||
for (PsiReference ref : refs) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.ElementToArrayConversionRule"/>
|
||||
<conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.ThreadLocalConversionRule"/>
|
||||
<conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.LongAdderConversionRule"/>
|
||||
<conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.VoidConversionRule"/>
|
||||
|
||||
<conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.guava.GuavaOptionalConversionRule"/>
|
||||
<conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.guava.GuavaFluentIterableConversionRule"/>
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.typeMigration.rules;
|
||||
|
||||
import com.intellij.codeInspection.dataFlow.ControlFlowAnalyzer;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.typeMigration.TypeConversionDescriptorBase;
|
||||
import com.intellij.refactoring.typeMigration.TypeEvaluator;
|
||||
import com.intellij.refactoring.typeMigration.TypeMigrationLabeler;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.ig.controlflow.UnnecessaryReturnInspection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public class VoidConversionRule extends TypeConversionRule {
|
||||
@Nullable
|
||||
@Override
|
||||
public TypeConversionDescriptorBase findConversion(PsiType from,
|
||||
PsiType to,
|
||||
PsiMember member,
|
||||
PsiExpression context,
|
||||
TypeMigrationLabeler labeler) {
|
||||
if (PsiType.VOID.equals(to) && context.getParent() instanceof PsiReturnStatement) {
|
||||
final boolean isPure = PsiTreeUtil.processElements(context, new PsiElementProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element) {
|
||||
if (element instanceof PsiPrefixExpression) {
|
||||
return analyzeUnaryExpressionOperand(((PsiPrefixExpression)element).getOperand());
|
||||
}
|
||||
if (element instanceof PsiPostfixExpression) {
|
||||
return analyzeUnaryExpressionOperand(((PsiPostfixExpression)element).getOperand());
|
||||
}
|
||||
if (element instanceof PsiMethodCallExpression) {
|
||||
final PsiMethod method = ((PsiMethodCallExpression)element).resolveMethod();
|
||||
return method != null && ControlFlowAnalyzer.isPure(method);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean analyzeUnaryExpressionOperand(PsiExpression operand) {
|
||||
if (!(operand instanceof PsiReferenceExpression)) return false;
|
||||
final PsiElement resolved = ((PsiReferenceExpression)operand).resolve();
|
||||
return !(resolved instanceof PsiField);
|
||||
}
|
||||
});
|
||||
if (isPure) {
|
||||
return new TypeConversionDescriptorBase() {
|
||||
@Override
|
||||
public PsiExpression replace(PsiExpression expression, @NotNull TypeEvaluator evaluator) throws IncorrectOperationException {
|
||||
final PsiElement parent = expression.getParent();
|
||||
if (parent instanceof PsiReturnStatement) {
|
||||
expression.delete();
|
||||
if (UnnecessaryReturnInspection.isReturnRedundant((PsiReturnStatement)parent, false, null)) {
|
||||
parent.delete();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -826,6 +826,10 @@ public class TypeMigrationTest extends TypeMigrationTestBase {
|
||||
doTestFieldType("fooDontMigrateName", PsiType.BOOLEAN);
|
||||
}
|
||||
|
||||
public void testMethodMigrationToVoidWithUnusedReturns() {
|
||||
doTestMethodType("toVoidMethod", PsiType.VOID);
|
||||
}
|
||||
|
||||
public void testMigrationToSuper() {
|
||||
doTestFieldType("b", myJavaFacade.getElementFactory().createTypeFromText("Test.A<java.lang.String>", null));
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
Types:
|
||||
PsiMethod:toVoidMethod : void
|
||||
PsiMethodCallExpression:toVoidMethod() : void
|
||||
|
||||
Conversions:
|
||||
|
||||
New expression type changes:
|
||||
Fails:
|
||||
"" + String.valueOf(999)->void
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Test {
|
||||
|
||||
public void toVoidMethod() {
|
||||
int j = 0;
|
||||
return "" + String.valueOf(999);
|
||||
}
|
||||
|
||||
public void main(String[] args) {
|
||||
toVoidMethod();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Test {
|
||||
|
||||
public String toVoidMethod() {
|
||||
int j = 0;
|
||||
return "" + String.valueOf(999);
|
||||
}
|
||||
|
||||
public void main(String[] args) {
|
||||
toVoidMethod();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
<orderEntry type="module" module-name="forms_rt" />
|
||||
<orderEntry type="module" module-name="forms-compiler" />
|
||||
<orderEntry type="module" module-name="instrumentation-util" />
|
||||
<orderEntry type="library" exported="" name="asm5" level="project" />
|
||||
<orderEntry type="library" exported="" name="ASM" level="project" />
|
||||
<orderEntry type="library" name="JDOM" level="project" />
|
||||
<orderEntry type="library" name="NanoXML" level="project" />
|
||||
<orderEntry type="library" name="jgoodies-forms" level="project" />
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.jsonSchema.extension.schema;
|
||||
|
||||
import com.intellij.json.psi.JsonObject;
|
||||
import com.intellij.json.psi.JsonProperty;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.jetbrains.jsonSchema.ide.JsonSchemaService;
|
||||
import com.jetbrains.jsonSchema.impl.JsonSchemaObject;
|
||||
import com.jetbrains.jsonSchema.impl.JsonSchemaResourcesRootsProvider;
|
||||
import com.jetbrains.jsonSchema.impl.JsonSchemaWalker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Irina.Chernushina on 7/7/2016.
|
||||
*/
|
||||
public class JsonSchemaDefinitionResolver {
|
||||
@Nullable private String myRef;
|
||||
@Nullable JsonSchemaObject mySchemaObject;
|
||||
|
||||
@NotNull private final PsiElement myElement;
|
||||
@Nullable final String mySchemaId;
|
||||
private boolean myInCurrentFile;
|
||||
|
||||
public JsonSchemaDefinitionResolver(@NotNull PsiElement element, @Nullable String schemaId) {
|
||||
myElement = element;
|
||||
mySchemaId = schemaId;
|
||||
}
|
||||
|
||||
public JsonSchemaDefinitionResolver setSchemaObject(@NotNull final JsonSchemaObject value) {
|
||||
mySchemaObject = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public JsonSchemaDefinitionResolver setRef(@NotNull final String value) {
|
||||
myRef = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement doResolve() {
|
||||
PsiElement result = tryResolveByName();
|
||||
if (result != null) return result;
|
||||
if (mySchemaId == null) {
|
||||
return tryResolveBySchemaObject();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private PsiElement tryResolveBySchemaObject() {
|
||||
if (!(myElement.getParent() instanceof JsonProperty)) return null;
|
||||
final Ref<PsiElement> ref = new Ref<>();
|
||||
|
||||
final String propertyName = ((JsonProperty)myElement.getParent()).getName();
|
||||
|
||||
JsonSchemaService.Impl.getEx(myElement.getProject()).iterateSchemaObjects(
|
||||
myElement.getContainingFile().getVirtualFile(),
|
||||
object -> {
|
||||
final JsonSchemaWalker.CompletionSchemesConsumer consumer = new JsonSchemaWalker.CompletionSchemesConsumer() {
|
||||
@Override
|
||||
public void consume(boolean isName, @NotNull JsonSchemaObject schema) {
|
||||
if (!ref.isNull()) return;
|
||||
|
||||
String definitionAddress = schema.getDefinitionAddress();
|
||||
if (!StringUtil.isEmptyOrSpaces(definitionAddress) && definitionAddress.startsWith("#")) {
|
||||
definitionAddress = definitionAddress.substring(1) + "/properties/" + propertyName;
|
||||
ref.set(resolveByPath(definitionAddress));
|
||||
if (!ref.isNull()) return;
|
||||
}
|
||||
List<JsonSchemaObject> list = new ArrayList<JsonSchemaObject>();
|
||||
if (schema.getAllOf() != null) list.addAll(schema.getAllOf());
|
||||
if (schema.getAnyOf() != null) list.addAll(schema.getAnyOf());
|
||||
if (schema.getOneOf() != null) list.addAll(schema.getOneOf());
|
||||
for (JsonSchemaObject schemaObject : list) {
|
||||
definitionAddress = schemaObject.getDefinitionAddress();
|
||||
if (!StringUtil.isEmptyOrSpaces(definitionAddress) && definitionAddress.startsWith("#")) {
|
||||
definitionAddress = definitionAddress.substring(1) + "/properties/" + propertyName;
|
||||
ref.set(resolveByPath(definitionAddress));
|
||||
if (!ref.isNull()) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
final List<JsonSchemaWalker.Step> position = JsonSchemaWalker.findPosition(((JsonProperty)myElement.getParent()).getNameElement(), true);
|
||||
if (position == null || position.isEmpty()) return true; // to continue iteration
|
||||
JsonSchemaWalker.extractSchemaVariants(consumer, object, true, position);
|
||||
return ref.isNull();
|
||||
});
|
||||
return ref.get();
|
||||
}
|
||||
|
||||
private PsiElement tryResolveByName() {
|
||||
if (myRef == null) initializeName();
|
||||
if (myRef == null) return null;
|
||||
|
||||
return resolveByPath(myRef);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiElement resolveByPath(String referenceName) {
|
||||
final Project project = myElement.getProject();
|
||||
final FileBasedIndex index = FileBasedIndex.getInstance();
|
||||
final Ref<Pair<VirtualFile, Integer>> reference = new Ref<>();
|
||||
GlobalSearchScope filter = mySchemaId != null && myInCurrentFile ? GlobalSearchScope.fileScope(myElement.getContainingFile()) :
|
||||
GlobalSearchScope.allScope(project);
|
||||
filter = JsonSchemaResourcesRootsProvider.enlarge(project, filter);
|
||||
|
||||
index.processValues(JsonSchemaFileIndex.PROPERTIES_INDEX, referenceName, null, new FileBasedIndex.ValueProcessor<Integer>() {
|
||||
@Override
|
||||
public boolean process(VirtualFile file, Integer value) {
|
||||
if (mySchemaId != null) {
|
||||
if (!JsonSchemaService.Impl.getEx(project).checkFileForId(mySchemaId, file)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
reference.set(Pair.create(file, value));
|
||||
return false;
|
||||
}
|
||||
}, filter);
|
||||
|
||||
if (!reference.isNull()) {
|
||||
final Pair<VirtualFile, Integer> pair = reference.get();
|
||||
final PsiFile file = myElement.getManager().findFile(pair.getFirst());
|
||||
if (file != null) {
|
||||
return file.findElementAt(pair.getSecond());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void initializeName() {
|
||||
final List<String> names = new ArrayList<>();
|
||||
final PsiElement parent = myElement.getParent();
|
||||
if (!(parent instanceof JsonProperty)) return;
|
||||
JsonProperty element = (JsonProperty)parent;
|
||||
while (true) {
|
||||
names.add(StringUtil.unquoteString(element.getName()));
|
||||
if (!(element.getParent() instanceof JsonObject)) break;
|
||||
final PsiElement grand = element.getParent().getParent();
|
||||
if (grand instanceof JsonProperty && ((JsonProperty)grand).getValue() != null &&
|
||||
((JsonProperty)grand).getValue().equals(element.getParent())) {
|
||||
element = (JsonProperty) grand;
|
||||
} else break;
|
||||
}
|
||||
final StringBuilder path = new StringBuilder();
|
||||
Collections.reverse(names);
|
||||
for (String name : names) {
|
||||
path.append("/properties/").append(name);
|
||||
}
|
||||
myRef = path.toString();
|
||||
}
|
||||
|
||||
public JsonSchemaDefinitionResolver setInCurrentFile(boolean inCurrentFile) {
|
||||
myInCurrentFile = inCurrentFile;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class JsonSchemaFileIndex extends FileBasedIndexExtension<String, Integer> {
|
||||
public static final ID<String, Integer> PROPERTIES_INDEX = ID.create("json.schema.properties.index");
|
||||
public static final int VERSION = 1;
|
||||
public static final int VERSION = 2;
|
||||
private IntInlineKeyDescriptor myKeyDescriptor = new IntInlineKeyDescriptor();
|
||||
|
||||
@NotNull
|
||||
|
||||
+7
-41
@@ -16,17 +16,12 @@
|
||||
package com.jetbrains.jsonSchema.extension.schema;
|
||||
|
||||
import com.intellij.json.psi.JsonValue;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.ElementManipulators;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.PsiReferenceProvider;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.jetbrains.jsonSchema.ide.JsonSchemaService;
|
||||
import com.jetbrains.jsonSchema.impl.JsonSchemaResourcesRootsProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -57,44 +52,15 @@ public class JsonSchemaRefReferenceProvider extends PsiReferenceProvider {
|
||||
final String text = getCanonicalText();
|
||||
String id = null;
|
||||
String ref = text.substring(1);
|
||||
if (!text.startsWith("#")) {
|
||||
final boolean isGlobal = !text.startsWith("#");
|
||||
if (isGlobal) {
|
||||
final int idx = text.indexOf("#");
|
||||
if (idx <= 0) return null;
|
||||
id = text.substring(0, idx);
|
||||
ref = text.substring(idx + 1);
|
||||
}
|
||||
|
||||
return resolveSchemaProperty(getElement(), id, ref);
|
||||
return new JsonSchemaDefinitionResolver(getElement(), id).setRef(ref).setInCurrentFile(!isGlobal).doResolve();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement resolveSchemaProperty(PsiElement baseElement, @Nullable final String schemaId, String ref) {
|
||||
final Project project = baseElement.getProject();
|
||||
final FileBasedIndex index = FileBasedIndex.getInstance();
|
||||
final Ref<Pair<VirtualFile, Integer>> reference = new Ref<>();
|
||||
final GlobalSearchScope filter = schemaId == null ? GlobalSearchScope.fileScope(baseElement.getContainingFile()) :
|
||||
JsonSchemaResourcesRootsProvider.enlarge(project, GlobalSearchScope.allScope(project));
|
||||
index.processValues(JsonSchemaFileIndex.PROPERTIES_INDEX, ref, null, new FileBasedIndex.ValueProcessor<Integer>() {
|
||||
@Override
|
||||
public boolean process(VirtualFile file, Integer value) {
|
||||
if (schemaId != null) {
|
||||
if (!JsonSchemaService.Impl.getEx(project).checkFileForId(schemaId, file)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
reference.set(Pair.create(file, value));
|
||||
return false;
|
||||
}
|
||||
}, filter);
|
||||
|
||||
if (!reference.isNull()) {
|
||||
final Pair<VirtualFile, Integer> pair = reference.get();
|
||||
final PsiFile file = baseElement.getManager().findFile(pair.getFirst());
|
||||
if (file != null) {
|
||||
return file.findElementAt(pair.getSecond());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.Processor;
|
||||
import com.jetbrains.jsonSchema.impl.JsonSchemaObject;
|
||||
import com.jetbrains.jsonSchema.impl.JsonSchemaServiceEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -41,8 +41,7 @@ public interface JsonSchemaService {
|
||||
@Nullable
|
||||
DocumentationProvider getDocumentationProvider(@Nullable VirtualFile file);
|
||||
|
||||
@Nullable
|
||||
Convertor<String, PsiElement> getToPropertyResolver(@Nullable VirtualFile file);
|
||||
void iterateSchemaObjects(VirtualFile file, @NotNull final Processor<JsonSchemaObject> consumer);
|
||||
|
||||
@Nullable
|
||||
List<Pair<Boolean, String>> getMatchingSchemaDescriptors(@Nullable VirtualFile file);
|
||||
|
||||
@@ -18,8 +18,7 @@ package com.jetbrains.jsonSchema.impl;
|
||||
import com.intellij.codeInsight.completion.CompletionContributor;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.lang.documentation.DocumentationProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -35,6 +34,5 @@ public interface CodeInsightProviders {
|
||||
@NotNull
|
||||
DocumentationProvider getDocumentationProvider();
|
||||
|
||||
@NotNull
|
||||
Convertor<String, PsiElement> getToPropertyResolver();
|
||||
boolean iterateSchemaObjects(@NotNull Processor<JsonSchemaObject> consumer);
|
||||
}
|
||||
|
||||
+2
-9
@@ -16,16 +16,13 @@
|
||||
package com.jetbrains.jsonSchema.impl;
|
||||
|
||||
import com.intellij.json.psi.JsonStringLiteral;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.ElementManipulators;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.PsiReferenceProvider;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.jetbrains.jsonSchema.extension.schema.JsonSchemaBaseReference;
|
||||
import com.jetbrains.jsonSchema.ide.JsonSchemaService;
|
||||
import com.jetbrains.jsonSchema.extension.schema.JsonSchemaDefinitionResolver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -47,11 +44,7 @@ public class JsonPropertyName2SchemaDefinitionReferenceProvider extends PsiRefer
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiElement resolveInner() {
|
||||
final Project project = getElement().getProject();
|
||||
final Convertor<String, PsiElement> resolver =
|
||||
JsonSchemaService.Impl.get(project).getToPropertyResolver(getElement().getContainingFile().getVirtualFile());
|
||||
if (resolver != null) return resolver.convert("/properties/" + StringUtil.unquoteString(getCanonicalText()));
|
||||
return null;
|
||||
return new JsonSchemaDefinitionResolver(getElement(), null).doResolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Map;
|
||||
* @author Irina.Chernushina on 8/28/2015.
|
||||
*/
|
||||
public class JsonSchemaObject {
|
||||
private String myDefinitionAddress;
|
||||
private Map<String, JsonSchemaObject> myDefinitions;
|
||||
private Map<String, JsonSchemaObject> myProperties;
|
||||
private Map<String, JsonSchemaObject> myPatternProperties;
|
||||
@@ -108,6 +109,7 @@ public class JsonSchemaObject {
|
||||
myAnyOf = other.myAnyOf;
|
||||
myOneOf = other.myOneOf;
|
||||
myNot = other.myNot;
|
||||
myDefinitionAddress = other.myDefinitionAddress;
|
||||
}
|
||||
|
||||
public void mergeValues(JsonSchemaObject other) {
|
||||
@@ -480,4 +482,12 @@ public class JsonSchemaObject {
|
||||
public boolean hasSpecifiedType() {
|
||||
return myType != null || (myTypeVariants != null && !myTypeVariants.isEmpty());
|
||||
}
|
||||
|
||||
public String getDefinitionAddress() {
|
||||
return myDefinitionAddress;
|
||||
}
|
||||
|
||||
public void setDefinitionAddress(String definitionAddress) {
|
||||
myDefinitionAddress = definitionAddress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,14 @@ import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.lang.documentation.DocumentationProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.Processor;
|
||||
import com.jetbrains.jsonSchema.extension.SchemaType;
|
||||
import com.jetbrains.jsonSchema.extension.schema.JsonSchemaRefReferenceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class JsonSchemaObjectCodeInsightWrapper implements CodeInsightProviders {
|
||||
@NotNull private final String myName;
|
||||
@NotNull private final SchemaType mySchemaType;
|
||||
@NotNull private final JsonSchemaObject mySchemaObject;
|
||||
|
||||
@NotNull
|
||||
private final CompletionContributor myContributor;
|
||||
@@ -25,7 +22,7 @@ class JsonSchemaObjectCodeInsightWrapper implements CodeInsightProviders {
|
||||
|
||||
@NotNull
|
||||
private final DocumentationProvider myDocumentationProvider;
|
||||
private Convertor<String, PsiElement> my2SchemaResolver;
|
||||
|
||||
|
||||
public JsonSchemaObjectCodeInsightWrapper(@NotNull Project project, @NotNull String name,
|
||||
@NotNull SchemaType type,
|
||||
@@ -33,17 +30,10 @@ class JsonSchemaObjectCodeInsightWrapper implements CodeInsightProviders {
|
||||
@NotNull JsonSchemaObject schemaObject) {
|
||||
myName = name;
|
||||
mySchemaType = type;
|
||||
mySchemaObject = schemaObject;
|
||||
myContributor = new JsonBySchemaObjectCompletionContributor(type, schemaObject);
|
||||
myAnnotator = new JsonBySchemaObjectAnnotator(schemaObject);
|
||||
myDocumentationProvider = new JsonBySchemaDocumentationProvider(schemaObject);
|
||||
my2SchemaResolver = new Convertor<String, PsiElement>() {
|
||||
@Override
|
||||
public PsiElement convert(String key) {
|
||||
final PsiFile psiFile = PsiManager.getInstance(project).findFile(schemaFile);
|
||||
if (psiFile == null) return null;
|
||||
return JsonSchemaRefReferenceProvider.resolveSchemaProperty(psiFile, null, key);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,10 +59,9 @@ class JsonSchemaObjectCodeInsightWrapper implements CodeInsightProviders {
|
||||
return myDocumentationProvider;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Convertor<String, PsiElement> getToPropertyResolver() {
|
||||
return my2SchemaResolver;
|
||||
public boolean iterateSchemaObjects(@NotNull final Processor<JsonSchemaObject> consumer) {
|
||||
return consumer.process(mySchemaObject);
|
||||
}
|
||||
|
||||
public boolean isUserSchema() {
|
||||
|
||||
@@ -147,6 +147,7 @@ public class JsonSchemaReader {
|
||||
}
|
||||
|
||||
final JsonSchemaObject copy = new JsonSchemaObject();
|
||||
copy.setDefinitionAddress(current.getRef());
|
||||
copy.mergeValues(definition);
|
||||
copy.mergeValues(current);
|
||||
current.copyValues(copy);
|
||||
|
||||
@@ -18,14 +18,15 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NullableLazyValue;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.PairConsumer;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.jetbrains.jsonSchema.JsonSchemaFileTypeManager;
|
||||
import com.jetbrains.jsonSchema.JsonSchemaVfsListener;
|
||||
import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider;
|
||||
@@ -53,8 +54,7 @@ public class JsonSchemaServiceImpl implements JsonSchemaServiceEx {
|
||||
public JsonSchemaServiceImpl(@NotNull Project project) {
|
||||
myLock = new Object();
|
||||
myProject = project;
|
||||
myDefinitions = new JsonSchemaExportedDefinitions(
|
||||
consumer -> iterateSchemas(consumer));
|
||||
myDefinitions = new JsonSchemaExportedDefinitions(this::iterateSchemas);
|
||||
ApplicationManager
|
||||
.getApplication().getMessageBus().connect(project).subscribe(VirtualFileManager.VFS_CHANGES, new JsonSchemaVfsListener(project, this));
|
||||
ensureSchemaFiles(project);
|
||||
@@ -113,7 +113,7 @@ public class JsonSchemaServiceImpl implements JsonSchemaServiceEx {
|
||||
public boolean isSchemaFile(@NotNull VirtualFile file, @NotNull final Consumer<String> errorConsumer) {
|
||||
final String text;
|
||||
try {
|
||||
text = VfsUtil.loadText(file);
|
||||
text = VfsUtilCore.loadText(file);
|
||||
}
|
||||
catch (IOException e) {
|
||||
errorConsumer.consume(e.getMessage());
|
||||
@@ -145,11 +145,11 @@ public class JsonSchemaServiceImpl implements JsonSchemaServiceEx {
|
||||
return wrapper != null ? wrapper.getDocumentationProvider() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Convertor<String, PsiElement> getToPropertyResolver(@Nullable VirtualFile file) {
|
||||
CodeInsightProviders wrapper = getWrapper(file);
|
||||
return wrapper != null ? wrapper.getToPropertyResolver() : null;
|
||||
public void iterateSchemaObjects(VirtualFile file, @NotNull Processor<JsonSchemaObject> consumer) {
|
||||
final CodeInsightProviders wrapper = getWrapper(file);
|
||||
if (wrapper == null) return;
|
||||
wrapper.iterateSchemaObjects(consumer);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -286,13 +286,14 @@ public class JsonSchemaServiceImpl implements JsonSchemaServiceEx {
|
||||
|
||||
public CompositeCodeInsightProviderWithWarning(List<JsonSchemaObjectCodeInsightWrapper> wrappers) {
|
||||
final List<JsonSchemaObjectCodeInsightWrapper> userSchemaWrappers =
|
||||
ContainerUtil.filter(wrappers, wrapper -> wrapper.isUserSchema());
|
||||
ContainerUtil.filter(wrappers, JsonSchemaObjectCodeInsightWrapper::isUserSchema);
|
||||
// filter for the case when there are one system schema and one (several) user schemas
|
||||
// then do not use provided system schema: user schema will override it (maybe the user updated the version himself)
|
||||
// if there are 2 or more system schemas - just go the common way: it is unclear what happened and why
|
||||
if (!userSchemaWrappers.isEmpty() && ((userSchemaWrappers.size() + 1) == wrappers.size())) {
|
||||
myWrappers = userSchemaWrappers;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myWrappers = wrappers;
|
||||
}
|
||||
myContributor = new CompletionContributor() {
|
||||
@@ -336,19 +337,12 @@ public class JsonSchemaServiceImpl implements JsonSchemaServiceEx {
|
||||
return myDocumentationProvider;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Convertor<String, PsiElement> getToPropertyResolver() {
|
||||
return new Convertor<String, PsiElement>() {
|
||||
@Override
|
||||
public PsiElement convert(String key) {
|
||||
for (JsonSchemaObjectCodeInsightWrapper wrapper : myWrappers) {
|
||||
PsiElement element = wrapper.getToPropertyResolver().convert(key);
|
||||
if (element != null) return element;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
public boolean iterateSchemaObjects(@NotNull Processor<JsonSchemaObject> consumer) {
|
||||
for (JsonSchemaObjectCodeInsightWrapper wrapper : myWrappers) {
|
||||
if (!wrapper.iterateSchemaObjects(consumer)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.util.List;
|
||||
* This will significantly simplify code, since we will not need to take the list of possible variants of children and grandchildren;
|
||||
* we will be able to iterate variants, not collections of variants
|
||||
*/
|
||||
class JsonSchemaWalker {
|
||||
public class JsonSchemaWalker {
|
||||
public interface CompletionSchemesConsumer {
|
||||
void consume(boolean isName, @NotNull JsonSchemaObject schema);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class JsonSchemaWalker {
|
||||
extractSchemaVariants(consumer, rootSchema, isName, position);
|
||||
}
|
||||
|
||||
private static void extractSchemaVariants(@NotNull CompletionSchemesConsumer consumer,
|
||||
public static void extractSchemaVariants(@NotNull CompletionSchemesConsumer consumer,
|
||||
@NotNull JsonSchemaObject rootSchema, boolean isName, List<Step> position) {
|
||||
final ArrayDeque<Pair<JsonSchemaObject, Integer>> queue = new ArrayDeque<Pair<JsonSchemaObject, Integer>>();
|
||||
queue.add(Pair.create(rootSchema, 0));
|
||||
@@ -189,12 +189,12 @@ class JsonSchemaWalker {
|
||||
return steps;
|
||||
}
|
||||
|
||||
private static class Step {
|
||||
public static class Step {
|
||||
private final StateType myType;
|
||||
@Nullable
|
||||
private final Transition myTransition;
|
||||
|
||||
public Step(StateType type, Transition transition) {
|
||||
public Step(StateType type, @Nullable Transition transition) {
|
||||
myType = type;
|
||||
myTransition = transition;
|
||||
}
|
||||
@@ -282,7 +282,7 @@ class JsonSchemaWalker {
|
||||
@Nullable
|
||||
private final JsonSchemaType myCorrespondingJsonType;
|
||||
|
||||
StateType(JsonSchemaType correspondingJsonType) {
|
||||
StateType(@Nullable JsonSchemaType correspondingJsonType) {
|
||||
myCorrespondingJsonType = correspondingJsonType;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -86,7 +86,7 @@ public class MockFileDocumentManagerImpl extends FileDocumentManager {
|
||||
@Override
|
||||
@NotNull
|
||||
public Document[] getUnsavedDocuments() {
|
||||
return new Document[0];
|
||||
return Document.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,6 +46,7 @@ public abstract class ActionRunner {
|
||||
return result.throwException().getResultObject();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void runInsideReadAction(@NotNull final InterruptibleRunnable runnable) throws Exception {
|
||||
ApplicationManager.getApplication().runReadAction(new ThrowableComputable<Void, Exception>() {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -268,7 +268,7 @@ public class FoldingUpdate {
|
||||
", PSI element range: " + psiElement.getTextRange() + "; " + DebugUtil.diagnosePsiDocumentInconsistency(psiElement, document);
|
||||
LOG.error(message, ApplicationManager.getApplication().isInternal()
|
||||
? new Attachment[]{AttachmentFactory.createAttachment(document), new Attachment("psiTree.txt", DebugUtil.psiToString(file, false, true))}
|
||||
: new Attachment[0]);
|
||||
: Attachment.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
public static class FoldingMap extends MultiMap<PsiElement, FoldingDescriptor>{
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -153,7 +153,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
}
|
||||
|
||||
String text = "";
|
||||
PsiElement[] impls = new PsiElement[0];
|
||||
PsiElement[] impls = PsiElement.EMPTY_ARRAY;
|
||||
if (element != null) {
|
||||
//if (element instanceof PsiPackage) return;
|
||||
|
||||
|
||||
+11
@@ -733,6 +733,17 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
|
||||
private ProblemDescriptionsProcessor getProblemDescriptionProcessor(@NotNull final GlobalInspectionToolWrapper toolWrapper,
|
||||
@NotNull final Map<String, InspectionToolWrapper> wrappersMap) {
|
||||
return new ProblemDescriptionsProcessor() {
|
||||
@Nullable
|
||||
@Override
|
||||
public CommonProblemDescriptor[] getDescriptions(@NotNull RefEntity refEntity) {
|
||||
return CommonProblemDescriptor.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignoreElement(@NotNull RefEntity refEntity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProblemElement(@Nullable RefEntity refEntity, @NotNull CommonProblemDescriptor... commonProblemDescriptors) {
|
||||
for (CommonProblemDescriptor problemDescriptor : commonProblemDescriptors) {
|
||||
|
||||
+1
-1
@@ -415,7 +415,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
|
||||
public void ignoreCurrentElementProblem(RefEntity refEntity, CommonProblemDescriptor descriptor) {
|
||||
CommonProblemDescriptor[] descriptors = getIgnoredElements().get(refEntity);
|
||||
if (descriptors == null) {
|
||||
descriptors = new CommonProblemDescriptor[0];
|
||||
descriptors = CommonProblemDescriptor.EMPTY_ARRAY;
|
||||
}
|
||||
getIgnoredElements().put(refEntity, ArrayUtil.append(descriptors, descriptor));
|
||||
}
|
||||
|
||||
@@ -722,7 +722,6 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
|
||||
final HighlightDisplayKey key = HighlightDisplayKey.find(defaultToolWrapper.getShortName());
|
||||
for (ScopeToolState state : myProvider.getTools(currentTools)) {
|
||||
InspectionToolWrapper toolWrapper = state.getTool();
|
||||
LOG.assertTrue(!ApplicationManager.getApplication().isReadAccessAllowed());
|
||||
ReadAction.run(() -> {
|
||||
if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) {
|
||||
addTool(toolWrapper,
|
||||
|
||||
@@ -29,13 +29,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.MutableTreeNode;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class RefElementNode extends SuppressableInspectionTreeNode {
|
||||
private boolean myHasDescriptorsUnder = false;
|
||||
private CommonProblemDescriptor mySingleDescriptor = null;
|
||||
private volatile boolean myHasDescriptorsUnder;
|
||||
private volatile CommonProblemDescriptor mySingleDescriptor;
|
||||
private final Icon myIcon;
|
||||
public RefElementNode(@Nullable RefEntity userObject, @NotNull InspectionToolPresentation presentation) {
|
||||
super(userObject, presentation);
|
||||
@@ -76,7 +77,6 @@ public class RefElementNode extends SuppressableInspectionTreeNode {
|
||||
|
||||
@Override
|
||||
public void excludeElement(ExcludedInspectionTreeNodesManager excludedManager) {
|
||||
myPresentation.ignoreCurrentElement(getElement());
|
||||
super.excludeElement(excludedManager);
|
||||
}
|
||||
|
||||
@@ -92,10 +92,14 @@ public class RefElementNode extends SuppressableInspectionTreeNode {
|
||||
|
||||
@Override
|
||||
public void add(MutableTreeNode newChild) {
|
||||
checkHasDescriptorUnder(newChild);
|
||||
super.add(newChild);
|
||||
if (newChild instanceof ProblemDescriptionNode) {
|
||||
myHasDescriptorsUnder = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectionTreeNode insertByOrder(InspectionTreeNode child, boolean allowDuplication) {
|
||||
checkHasDescriptorUnder(child);
|
||||
return super.insertByOrder(child, allowDuplication);
|
||||
}
|
||||
|
||||
public void setProblem(@NotNull CommonProblemDescriptor descriptor) {
|
||||
@@ -142,4 +146,17 @@ public class RefElementNode extends SuppressableInspectionTreeNode {
|
||||
}
|
||||
return isLeaf() ? "" : null;
|
||||
}
|
||||
|
||||
private void checkHasDescriptorUnder(MutableTreeNode newChild) {
|
||||
if (myHasDescriptorsUnder) return;
|
||||
if (newChild instanceof ProblemDescriptionNode ||
|
||||
newChild instanceof RefElementNode && ((RefElementNode)newChild).hasDescriptorsUnder()) {
|
||||
myHasDescriptorsUnder = true;
|
||||
TreeNode parent = getParent();
|
||||
while (parent instanceof RefElementNode) {
|
||||
((RefElementNode)parent).myHasDescriptorsUnder = true;
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -93,7 +93,7 @@ public abstract class AbstractNewProjectDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
protected String getHelpId() {
|
||||
return null;
|
||||
return "create_new_project_dialog";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -103,6 +103,6 @@ public abstract class AbstractNewProjectDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> AbstractNewProjectDialog.super.show());
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, super::show);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -243,7 +243,7 @@ public class DefaultLanguageColorsPage implements ColorSettingsPage, DisplayPrio
|
||||
@NotNull
|
||||
@Override
|
||||
public ColorDescriptor[] getColorDescriptors() {
|
||||
return new ColorDescriptor[0];
|
||||
return ColorDescriptor.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,7 +80,7 @@ public class FindDependencyUtil {
|
||||
}
|
||||
}
|
||||
deps.retainAll(searchIn);
|
||||
if (deps.isEmpty()) return new UsageInfo[0];
|
||||
if (deps.isEmpty()) return UsageInfo.EMPTY_ARRAY;
|
||||
|
||||
int totalCount = deps.size();
|
||||
int count = 0;
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,9 +32,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.Consumer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -68,7 +66,7 @@ public class DependenciesUsagesPanel extends UsagesPanel {
|
||||
myCurrentProgress = progress;
|
||||
ProgressManager.getInstance().runProcess(() -> {
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
UsageInfo[] usages = new UsageInfo[0];
|
||||
UsageInfo[] usages = UsageInfo.EMPTY_ARRAY;
|
||||
Set<PsiFile> elementsToSearch = null;
|
||||
|
||||
try {
|
||||
|
||||
+15
-6
@@ -70,6 +70,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
implements ErrorsConfigurable, SearchableConfigurable, Configurable.NoScroll {
|
||||
@@ -78,7 +80,8 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
private static final String HEADER_TITLE = "Profile:";
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(InspectionToolsConfigurable.class);
|
||||
private static final String COPY_SUFFIX = "copy";
|
||||
private static final Pattern COPIED_PROFILE_SUFFIX_PATTERN = Pattern.compile("(.*\\s*copy)\\s*(\\d*)");
|
||||
|
||||
protected final InspectionProfileManager myApplicationProfileManager;
|
||||
protected final ProjectInspectionProfileManager myProjectProfileManager;
|
||||
private final CardLayout myLayout = new CardLayout();
|
||||
@@ -114,15 +117,21 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
LOG.assertTrue(modifyLevel || modifyName);
|
||||
String profileDefaultName = selectedProfile.getName();
|
||||
if (modifyName) {
|
||||
if (!profileDefaultName.endsWith(COPY_SUFFIX)) {
|
||||
profileDefaultName += " " + COPY_SUFFIX;
|
||||
final Matcher matcher = COPIED_PROFILE_SUFFIX_PATTERN.matcher(profileDefaultName);
|
||||
int nextIdx;
|
||||
if (matcher.matches()) {
|
||||
profileDefaultName = matcher.group(1);
|
||||
nextIdx = matcher.group(2).isEmpty() ? 1 : Integer.valueOf(matcher.group(2));
|
||||
}
|
||||
else {
|
||||
profileDefaultName += " copy";
|
||||
nextIdx = 1;
|
||||
}
|
||||
if (hasName(profileDefaultName, modifyLevel != myPanels.get(selectedProfile).isProjectLevel())) {
|
||||
int idx = 0;
|
||||
String currentProfileDefaultName;
|
||||
do {
|
||||
idx++;
|
||||
currentProfileDefaultName = profileDefaultName + " " + String.valueOf(idx);
|
||||
currentProfileDefaultName = profileDefaultName + " " + String.valueOf(nextIdx);
|
||||
nextIdx++;
|
||||
}
|
||||
while (hasName(currentProfileDefaultName, modifyLevel != myPanels.get(selectedProfile).isProjectLevel()));
|
||||
profileDefaultName = currentProfileDefaultName;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class RenamePsiFileProcessor extends RenamePsiElementProcessor {
|
||||
return super.findReferences(element);
|
||||
}
|
||||
|
||||
protected static class PsiFileRenameDialog extends RenameWithOptionalReferencesDialog {
|
||||
public static class PsiFileRenameDialog extends RenameWithOptionalReferencesDialog {
|
||||
public PsiFileRenameDialog(Project project, PsiElement element, PsiElement nameSuggestionContext, Editor editor) {
|
||||
super(project, element, nameSuggestionContext, editor);
|
||||
}
|
||||
|
||||
@@ -2003,6 +2003,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
|
||||
private UnindexedFilesFinder(@Nullable ProgressIndicator indicator) {
|
||||
myProgressIndicator = indicator;
|
||||
if (!myInitialized) waitUntilIndicesAreInitialized();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.editor.actionSystem;
|
||||
|
||||
import com.intellij.diagnostic.ThreadDumper;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.Alarm;
|
||||
|
||||
public class FreezeLogger {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(FreezeLogger.class);
|
||||
private static final Alarm ALARM = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, ApplicationManager.getApplication());
|
||||
private static final int MAX_ALLOWED_TIME = 500;
|
||||
|
||||
public static void runUnderPerformanceMonitor(Runnable action) {
|
||||
ALARM.cancelAllRequests();
|
||||
ALARM.addRequest(FreezeLogger::dumpThreads, MAX_ALLOWED_TIME);
|
||||
|
||||
try {
|
||||
action.run();
|
||||
}
|
||||
finally {
|
||||
ALARM.cancelAllRequests();
|
||||
}
|
||||
}
|
||||
|
||||
private static void dumpThreads() {
|
||||
String dumps = ThreadDumper.dumpThreadsToString();
|
||||
String msg = "Typing freeze report, thread dumps attached. EDT stacktrace:\n"
|
||||
+ ThreadDumper.dumpEdtStackTrace()
|
||||
+ "\n\n\n";
|
||||
|
||||
LOG.error(msg, dumps);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,18 +15,14 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.actionSystem;
|
||||
|
||||
import com.intellij.diagnostic.ThreadDumper;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.UndoConfirmationPolicy;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.Alarm;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -165,34 +161,4 @@ public class TypedAction {
|
||||
"", editor.getDocument(), UndoConfirmationPolicy.DEFAULT, editor.getDocument());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class FreezeLogger {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(FreezeLogger.class);
|
||||
private static final Alarm ALARM = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, Disposer.newDisposable());
|
||||
private static final int MAX_ALLOWED_TIME = 500;
|
||||
|
||||
public static void runUnderPerformanceMonitor(Runnable action) {
|
||||
ALARM.cancelAllRequests();
|
||||
ALARM.addRequest(FreezeLogger::dumpThreads, MAX_ALLOWED_TIME);
|
||||
|
||||
try {
|
||||
action.run();
|
||||
}
|
||||
finally {
|
||||
ALARM.cancelAllRequests();
|
||||
}
|
||||
}
|
||||
|
||||
private static void dumpThreads() {
|
||||
String dumps = ThreadDumper.dumpThreadsToString();
|
||||
String msg = "Typing freeze report, thread dumps attached. EDT stacktrace:\n"
|
||||
+ ThreadDumper.dumpEdtStackTrace()
|
||||
+ "\n\n\n";
|
||||
|
||||
LOG.error(msg, dumps);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.util.ui.RegionPainter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
/**
|
||||
* @author Sergey.Malenkov
|
||||
*/
|
||||
public enum EffectPainter implements RegionPainter<Paint> {
|
||||
WAVE {
|
||||
private final BasicStroke STROKE = new BasicStroke(.7f);
|
||||
|
||||
@Override
|
||||
public void paint(Graphics2D g, int x, int y, int width, int height, Paint paint) {
|
||||
if (paint != null && width > 0 && height > 0) {
|
||||
if (!Registry.is("ide.text.effect.wave.new.scale")) {
|
||||
y += height - 3;
|
||||
height = 3;
|
||||
}
|
||||
g = (Graphics2D)g.create(x, y, width, height);
|
||||
g.clipRect(0, 0, width, height);
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setPaint(paint);
|
||||
|
||||
int length = 2 * height;
|
||||
boolean simple = length < 5;
|
||||
|
||||
double dx = -((x % length + length) % length); // normalize
|
||||
double size = (double)length / 4;
|
||||
|
||||
double upper = 0;
|
||||
double lower = height - 1;
|
||||
double center = lower / 2;
|
||||
|
||||
Path2D path = new Path2D.Double();
|
||||
path.moveTo(dx, lower);
|
||||
while (true) {
|
||||
if (simple) {
|
||||
dx += size + size;
|
||||
path.lineTo(dx, upper);
|
||||
if (dx > width) break;
|
||||
dx += size + size;
|
||||
path.lineTo(dx, lower);
|
||||
if (dx > width) break;
|
||||
}
|
||||
else {
|
||||
dx += size;
|
||||
path.quadTo(dx - size / 2, lower, dx, center);
|
||||
if (dx > width) break;
|
||||
dx += size;
|
||||
path.quadTo(dx - size / 2, upper, dx, upper);
|
||||
if (dx > width) break;
|
||||
dx += size;
|
||||
path.quadTo(dx - size / 2, upper, dx, center);
|
||||
if (dx > width) break;
|
||||
dx += size;
|
||||
path.quadTo(dx - size / 2, lower, dx, lower);
|
||||
if (dx > width) break;
|
||||
}
|
||||
}
|
||||
if (simple) g.setStroke(STROKE);
|
||||
g.draw(path);
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -833,10 +834,15 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co
|
||||
}
|
||||
// 2. Waved effect
|
||||
if (attributes.isWaved()) {
|
||||
if (attributes.getWaveColor() != null) {
|
||||
g.setColor(attributes.getWaveColor());
|
||||
if (Registry.is("ide.text.effect.wave.new")) {
|
||||
EffectPainter.WAVE.paint(g, offset, textBaseline + 1, fragmentWidth, Math.max(2, metrics.getDescent()), attributes.getWaveColor());
|
||||
}
|
||||
else {
|
||||
if (attributes.getWaveColor() != null) {
|
||||
g.setColor(attributes.getWaveColor());
|
||||
}
|
||||
UIUtil.drawWave(g, new Rectangle(offset, textBaseline + 1, fragmentWidth, Math.max(2, metrics.getDescent())));
|
||||
}
|
||||
UIUtil.drawWave(g, new Rectangle(offset, textBaseline + 1, fragmentWidth, Math.max(2, metrics.getDescent())));
|
||||
}
|
||||
// 3. Underline
|
||||
if (attributes.isUnderline()) {
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -79,6 +79,8 @@ public class ExternalizablePropertyContainer extends AbstractProperty.AbstractPr
|
||||
}
|
||||
|
||||
public void readExternal(@NotNull Element element) {
|
||||
myValues.clear();
|
||||
|
||||
Map<String, AbstractProperty> propertyByName = new THashMap<String, AbstractProperty>();
|
||||
for (AbstractProperty abstractProperty : myExternalizers.keySet()) {
|
||||
propertyByName.put(abstractProperty.getName(), abstractProperty);
|
||||
|
||||
@@ -425,7 +425,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
filesData.add(info);
|
||||
if (!firstRecentMarked) {
|
||||
selectionIndex = filesData.size() - 1;
|
||||
if (selectionIndex != 0 || UISettings.getInstance().EDITOR_TAB_PLACEMENT != UISettings.TABS_NONE) {
|
||||
if (selectionIndex != 0 || UISettings.getInstance().EDITOR_TAB_PLACEMENT != UISettings.TABS_NONE || !isPinnedMode()) {
|
||||
firstRecentMarked = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,26 +95,14 @@ public class RepositoryHelper {
|
||||
|
||||
@NotNull
|
||||
public static List<IdeaPluginDescriptor> loadPlugins(@Nullable String repositoryUrl, @Nullable ProgressIndicator indicator) throws IOException {
|
||||
boolean forceHttps = repositoryUrl == null && IdeaApplication.isLoaded() && UpdateSettings.getInstance().canUseSecureConnection();
|
||||
return loadPlugins(repositoryUrl, null, forceHttps, indicator);
|
||||
return loadPlugins(repositoryUrl, null, indicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads list of plugins, compatible with a given build, from a given plugin repository (main repository if null).
|
||||
*/
|
||||
@NotNull
|
||||
public static List<IdeaPluginDescriptor> loadPlugins(@Nullable String repositoryUrl,
|
||||
@Nullable BuildNumber buildnumber,
|
||||
@Nullable ProgressIndicator indicator) throws IOException {
|
||||
boolean forceHttps = repositoryUrl == null && IdeaApplication.isLoaded() && UpdateSettings.getInstance().canUseSecureConnection();
|
||||
return loadPlugins(repositoryUrl, buildnumber, forceHttps, indicator);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<IdeaPluginDescriptor> loadPlugins(@Nullable String repositoryUrl,
|
||||
@Nullable BuildNumber buildnumber,
|
||||
boolean forceHttps,
|
||||
@Nullable ProgressIndicator indicator) throws IOException {
|
||||
return loadPlugins(repositoryUrl, buildnumber, null, forceHttps, indicator);
|
||||
}
|
||||
|
||||
|
||||
@@ -228,8 +228,11 @@ public class DarculaLaf extends BasicLookAndFeel {
|
||||
loadDefaults(defaults);
|
||||
defaults.put("Table.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
|
||||
"ctrl C", "copy",
|
||||
"meta C", "copy",
|
||||
"ctrl V", "paste",
|
||||
"meta V", "paste",
|
||||
"ctrl X", "cut",
|
||||
"meta X", "cut",
|
||||
"COPY", "copy",
|
||||
"PASTE", "paste",
|
||||
"CUT", "cut",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -144,7 +144,7 @@ public class DummyProject extends UserDataHolderBase implements Project {
|
||||
|
||||
@NotNull
|
||||
public ComponentConfig[] getComponentConfigurations() {
|
||||
return new ComponentConfig[0];
|
||||
return ComponentConfig.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -2413,7 +2413,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
int y = visibleLineToY(visibleStartLine) + getAscent() + 1;
|
||||
g.setColor(attributes.getEffectColor());
|
||||
if (attributes.getEffectType() == EffectType.WAVE_UNDERSCORE) {
|
||||
UIUtil.drawWave((Graphics2D)g, new Rectangle(end.x, y, charWidth - 1, getDescent()- 1));
|
||||
if (Registry.is("ide.text.effect.wave.new")) {
|
||||
EffectPainter.WAVE.paint((Graphics2D)g, end.x, y, charWidth - 1, getDescent() - 1, attributes.getEffectColor());
|
||||
}
|
||||
else {
|
||||
UIUtil.drawWave((Graphics2D)g, new Rectangle(end.x, y, charWidth - 1, getDescent() - 1));
|
||||
}
|
||||
}
|
||||
else if (attributes.getEffectType() == EffectType.BOLD_DOTTED_LINE) {
|
||||
final int dottedAt = SystemInfo.isMac ? y - 1 : y;
|
||||
@@ -3562,8 +3567,13 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
g.setColor(savedColor);
|
||||
}
|
||||
else if (effectType == EffectType.WAVE_UNDERSCORE) {
|
||||
g.setColor(effectColor);
|
||||
UIUtil.drawWave((Graphics2D)g, new Rectangle(xStart, y+1, xEnd - xStart, getDescent() - 1));
|
||||
if (Registry.is("ide.text.effect.wave.new")) {
|
||||
EffectPainter.WAVE.paint((Graphics2D)g, xStart, y + 1, xEnd - xStart, getDescent() - 1, effectColor);
|
||||
}
|
||||
else {
|
||||
g.setColor(effectColor);
|
||||
UIUtil.drawWave((Graphics2D)g, new Rectangle(xStart, y + 1, xEnd - xStart, getDescent() - 1));
|
||||
}
|
||||
g.setColor(savedColor);
|
||||
}
|
||||
else if (effectType == EffectType.BOLD_DOTTED_LINE) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.impl.IdeBackgroundUtil;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.EffectPainter;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -439,7 +440,12 @@ class EditorPainter implements TextDrawingCallback {
|
||||
UIUtil.drawLine(g, xStart, y1, xEnd, y1);
|
||||
}
|
||||
else if (effectType == EffectType.WAVE_UNDERSCORE) {
|
||||
UIUtil.drawWave(g, new Rectangle(xStart, y + 1, xEnd - xStart, myView.getDescent() - 1));
|
||||
if (Registry.is("ide.text.effect.wave.new")) {
|
||||
EffectPainter.WAVE.paint(g, xStart, y + 1, xEnd - xStart, myView.getDescent() - 1, effectColor);
|
||||
}
|
||||
else {
|
||||
UIUtil.drawWave(g, new Rectangle(xStart, y + 1, xEnd - xStart, myView.getDescent() - 1));
|
||||
}
|
||||
}
|
||||
else if (effectType == EffectType.BOLD_DOTTED_LINE) {
|
||||
UIUtil.drawBoldDottedLine(g, xStart, xEnd, SystemInfo.isMac ? y : y + 1, myEditor.getBackgroundColor(), g.getColor(), false);
|
||||
|
||||
@@ -266,7 +266,7 @@ abstract class LineLayout {
|
||||
assert startOffset <= endOffset;
|
||||
final BidiRun[] runs;
|
||||
if (startOffset == endOffset) {
|
||||
runs = new BidiRun[0];
|
||||
runs = BidiRun.EMPTY_ARRAY;
|
||||
}
|
||||
else {
|
||||
List<BidiRun> runList = new ArrayList<BidiRun>();
|
||||
@@ -338,7 +338,7 @@ abstract class LineLayout {
|
||||
}
|
||||
|
||||
private BidiRun[] createRuns() {
|
||||
if (myChunk == null) return new BidiRun[0];
|
||||
if (myChunk == null) return BidiRun.EMPTY_ARRAY;
|
||||
BidiRun run = new BidiRun(myChunk.endOffset);
|
||||
run.chunks = new Chunk[] {myChunk};
|
||||
return new BidiRun[] {run};
|
||||
@@ -474,6 +474,7 @@ abstract class LineLayout {
|
||||
}
|
||||
|
||||
private static class BidiRun {
|
||||
public static final BidiRun[] EMPTY_ARRAY = new BidiRun[0];
|
||||
private static final int CHUNK_CHARACTERS = 1024;
|
||||
|
||||
private final byte level;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class KeymapImpl extends ExternalizableSchemeAdapter implements Keymap {
|
||||
*/
|
||||
private Map<MouseShortcut, List<String>> myMouseShortcut2ListOfIds = null;
|
||||
|
||||
private static final Shortcut[] ourEmptyShortcutsArray = new Shortcut[0];
|
||||
private static final Shortcut[] ourEmptyShortcutsArray = Shortcut.EMPTY_ARRAY;
|
||||
private final List<Listener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private KeymapManagerEx myKeymapManager;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SchemeImportUtil {
|
||||
preselectFiles[0] = preselect;
|
||||
}
|
||||
else {
|
||||
preselectFiles = new VirtualFile[0];
|
||||
preselectFiles = VirtualFile.EMPTY_ARRAY;
|
||||
}
|
||||
final VirtualFile[] virtualFiles = fileChooser.choose(null, preselectFiles);
|
||||
//CodeStyleSchemesUIConfiguration.Util.getRecentImportFile());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user