diff --git a/.idea/libraries/Netty.xml b/.idea/libraries/Netty.xml
index bc6600b3242d..c79ce3e2cbe0 100644
--- a/.idea/libraries/Netty.xml
+++ b/.idea/libraries/Netty.xml
@@ -1,11 +1,11 @@
-
+
-
+
\ No newline at end of file
diff --git a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpIntentionAction.java b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpIntentionAction.java
index e9586776531d..6c052461c5b8 100644
--- a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpIntentionAction.java
+++ b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpIntentionAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public class CheckRegExpIntentionAction extends QuickEditAction implements Icona
final Project project = file.getProject();
final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
if (document != null) {
- return new CheckRegExpForm(new Pair>(file, ref)).getRootPanel();
+ return new CheckRegExpForm(Pair.create(file, ref)).getRootPanel();
}
return null;
}
diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant
index 435720ffcab7..225113a63393 100644
--- a/build/scripts/libLicenses.gant
+++ b/build/scripts/libLicenses.gant
@@ -251,7 +251,7 @@ libraryLicense(name: "XML-RPC", libraryName: "XmlRPC", version: "2.0", license:
libraryLicense(name: "XStream", version: "1.4.3", license: "BSD", url: "http://xstream.codehaus.org/", licenseUrl: "http://xstream.codehaus.org/license.html")
libraryLicense(name: "YourKit Java Profiler", libraryName: "yjp-controller-api-redist.jar", version: "8.0.x", license: "link (commercial license)", url: "http://yourkit.com/", licenseUrl: "http://www.yourkit.com/purchase/license.html")
libraryLicense(name: "protobuf", version: "2.5.0", license: "New BSD", url: "http://code.google.com/p/protobuf/", licenseUrl: "http://code.google.com/p/protobuf/source/browse/trunk/COPYING.txt?r=367")
-libraryLicense(name: "Netty", libraryName: "Netty", version: "5.0.0.Alpha1", license: "Apache 2.0", url: "http://netty.io", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0")
+libraryLicense(name: "Netty", libraryName: "Netty", version: "4.1.0.Alpha2", license: "Apache 2.0", url: "http://netty.io", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0")
libraryLicense(name: "Kryo", libraryName: "Kryo", version: "2.22", license: "New BSD License", url: "https://github.com/EsotericSoftware/kryo", licenseUrl: "https://github.com/EsotericSoftware/kryo/blob/master/license.txt")
libraryLicense(name: "Snappy-Java", libraryName: "Snappy-Java", version: "0.3", license: "Apache 2.0", url: "https://github.com/dain/snappy", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0")
libraryLicense(name: "Cucumber-Java", libraryName: "cucumber-java", version: "1.0.14", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html")
diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java
index 46a090da8a92..64356bf491b2 100644
--- a/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java
+++ b/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java
@@ -397,12 +397,17 @@ public class CompilerManagerImpl extends CompilerManager {
@NotNull
public CompileScope createModuleCompileScope(@NotNull final Module module, final boolean includeDependentModules) {
- return new ModuleCompileScope(module, includeDependentModules);
+ return createModulesCompileScope(new Module[] {module}, includeDependentModules);
}
@NotNull
public CompileScope createModulesCompileScope(@NotNull final Module[] modules, final boolean includeDependentModules) {
- return new ModuleCompileScope(myProject, modules, includeDependentModules);
+ return createModulesCompileScope(modules, includeDependentModules, false);
+ }
+
+ @NotNull
+ public CompileScope createModulesCompileScope(@NotNull Module[] modules, boolean includeDependentModules, boolean includeRuntimeDependencies) {
+ return new ModuleCompileScope(myProject, modules, includeDependentModules, includeRuntimeDependencies);
}
@NotNull
diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/PropertyFileGeneratorImpl.java b/java/compiler/impl/src/com/intellij/compiler/ant/PropertyFileGeneratorImpl.java
index f7ee1bcbfb14..b6c74bf3dd6e 100644
--- a/java/compiler/impl/src/com/intellij/compiler/ant/PropertyFileGeneratorImpl.java
+++ b/java/compiler/impl/src/com/intellij/compiler/ant/PropertyFileGeneratorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -85,7 +85,7 @@ public class PropertyFileGeneratorImpl extends PropertyFileGenerator {
}
public void addProperty(String name, String value) {
- myProperties.add(new Pair(name, value));
+ myProperties.add(Pair.create(name, value));
}
@Override
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java
index f58d9efd9482..51343b9e5d7e 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,17 +17,20 @@ package com.intellij.compiler.classFilesIndex.chainsSearch;
import com.intellij.compiler.classFilesIndex.chainsSearch.context.ChainCompletionContext;
import com.intellij.compiler.classFilesIndex.chainsSearch.context.TargetType;
+import com.intellij.compiler.classFilesIndex.impl.MethodIncompleteSignature;
import com.intellij.compiler.classFilesIndex.impl.MethodsUsageIndexReader;
import com.intellij.compiler.classFilesIndex.impl.UsageIndexValue;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Pair;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiManager;
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.PsiModifier;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import com.intellij.compiler.classFilesIndex.impl.MethodIncompleteSignature;
import java.util.*;
@@ -93,7 +96,7 @@ public final class ChainsSearcher {
final WeightAware methodIncompleteSignatureWeightAware) {
final MethodIncompleteSignature underlying = methodIncompleteSignatureWeightAware.getUnderlying();
return new WeightAware>(
- new Pair(
+ Pair.create(
underlying,
new MethodsChain(context.resolveNotDeprecated(underlying),
methodIncompleteSignatureWeightAware.getWeight(),
@@ -173,7 +176,7 @@ public final class ChainsSearcher {
final MethodsChain methodsChain =
currentVertexUnderlying.second.addEdge(resolved, sign.getUnderlying().getOwner(), sign.getWeight());
q.add(new WeightAware>(
- new Pair(sign.getUnderlying(), methodsChain), sign.getWeight()));
+ Pair.create(sign.getUnderlying(), methodsChain), sign.getWeight()));
continue;
}
}
@@ -184,7 +187,7 @@ public final class ChainsSearcher {
if (parametersMatchResult.noUnmatchedAndHasMatched() && parametersMatchResult.hasTarget()) {
updated = true;
q.addFirst(new WeightAware>(
- new Pair(sign.getUnderlying(), methodsChain), sign.getWeight()));
+ Pair.create(sign.getUnderlying(), methodsChain), sign.getWeight()));
}
isBreak = true;
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java
index f4c372a86d62..764bf1dbc042 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -348,7 +348,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
myGeneratedTestRoots.add(root);
}
if (compiler instanceof SourceGeneratingCompiler) {
- myOutputRootToSourceGeneratorMap.put(root, new Pair((SourceGeneratingCompiler)compiler, module));
+ myOutputRootToSourceGeneratorMap.put(root, Pair.create((SourceGeneratingCompiler)compiler, module));
}
}
finally {
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
index 38fe261235b0..39b052f5c82a 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
@@ -182,8 +182,8 @@ public class CompileDriver {
for (IntermediateOutputCompiler compiler : generatingCompilers) {
final VirtualFile productionOutput = lookupVFile(lfs, CompilerPaths.getGenerationOutputPath(compiler, module, false));
final VirtualFile testOutput = lookupVFile(lfs, CompilerPaths.getGenerationOutputPath(compiler, module, true));
- final Pair pair = new Pair(compiler, module);
- final Pair outputs = new Pair(productionOutput, testOutput);
+ final Pair pair = Pair.create(compiler, module);
+ final Pair outputs = Pair.create(productionOutput, testOutput);
myGenerationCompilerModuleToOutputDirMap.put(pair, outputs);
}
if (config.getAnnotationProcessingConfiguration(module).isEnabled()) {
@@ -1882,7 +1882,7 @@ public class CompileDriver {
private VirtualFile getGenerationOutputDir(final IntermediateOutputCompiler compiler, final Module module, final boolean forTestSources) {
final Pair outputs =
- myGenerationCompilerModuleToOutputDirMap.get(new Pair(compiler, module));
+ myGenerationCompilerModuleToOutputDirMap.get(Pair.create(compiler, module));
return forTestSources? outputs.getSecond() : outputs.getFirst();
}
@@ -2730,7 +2730,7 @@ public class CompileDriver {
list = new ArrayList>();
myData.put(file, list);
}
- list.add(new Pair(cache, item));
+ list.add(Pair.create(cache, item));
}
public void doUpdate() throws IOException {
@@ -2896,7 +2896,7 @@ public class CompileDriver {
final Set depFiles = new HashSet(deps.getSecond());
depFiles.removeAll(myProcessedFiles);
myProcessedFiles.addAll(deps.getSecond());
- return new Pair>(currentDeps.toArray(), depFiles);
+ return Pair.create(currentDeps.toArray(), depFiles);
}
}
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/ModuleCompileScope.java b/java/compiler/impl/src/com/intellij/compiler/impl/ModuleCompileScope.java
index b2485e8d8ea8..63bb747e9462 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/ModuleCompileScope.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/ModuleCompileScope.java
@@ -25,10 +25,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.FileIndex;
-import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.roots.ProjectFileIndex;
-import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.roots.*;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -36,10 +33,7 @@ import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.util.CommonProcessors;
import org.jetbrains.annotations.NotNull;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
public class ModuleCompileScope extends FileIndexCompileScope {
private final Project myProject;
@@ -47,18 +41,18 @@ public class ModuleCompileScope extends FileIndexCompileScope {
private final Module[] myModules;
public ModuleCompileScope(final Module module, boolean includeDependentModules) {
- myProject = module.getProject();
- myScopeModules = new HashSet();
- if (includeDependentModules) {
- buildScopeModulesSet(module);
- }
- else {
- myScopeModules.add(module);
- }
- myModules = ModuleManager.getInstance(myProject).getModules();
+ this(module.getProject(), Collections.singleton(module), includeDependentModules, false);
}
public ModuleCompileScope(Project project, final Module[] modules, boolean includeDependentModules) {
+ this(project, modules, includeDependentModules, false);
+ }
+
+ public ModuleCompileScope(Project project, final Module[] modules, boolean includeDependentModules, boolean includeRuntimeDependencies) {
+ this(project, Arrays.asList(modules), includeDependentModules, includeRuntimeDependencies);
+ }
+
+ private ModuleCompileScope(Project project, final Collection modules, boolean includeDependentModules, boolean includeRuntimeDeps) {
myProject = project;
myScopeModules = new HashSet();
for (Module module : modules) {
@@ -66,7 +60,11 @@ public class ModuleCompileScope extends FileIndexCompileScope {
continue; // prevent NPE
}
if (includeDependentModules) {
- buildScopeModulesSet(module);
+ OrderEnumerator enumerator = ModuleRootManager.getInstance(module).orderEntries().recursively();
+ if (!includeRuntimeDeps) {
+ enumerator = enumerator.compileOnly();
+ }
+ enumerator.forEachModule(new CommonProcessors.CollectProcessor(myScopeModules));
}
else {
myScopeModules.add(module);
@@ -75,10 +73,6 @@ public class ModuleCompileScope extends FileIndexCompileScope {
myModules = ModuleManager.getInstance(myProject).getModules();
}
- private void buildScopeModulesSet(Module module) {
- ModuleRootManager.getInstance(module).orderEntries().recursively().compileOnly().forEachModule(new CommonProcessors.CollectProcessor(myScopeModules));
- }
-
@NotNull
public Module[] getAffectedModules() {
return myScopeModules.toArray(new Module[myScopeModules.size()]);
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java
index a4c2fbeeed05..cfc34412e727 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -768,7 +768,7 @@ public class BackendCompilerWrapper {
LOG.info(message);
myCompileContext.addMessage(CompilerMessageCategory.WARNING, message, sourceFile.getUrl(), -1, -1);
// do not move: looks like source file has been invalidated, need recompilation
- return new Pair(tempOutputDir, pathToClass);
+ return Pair.create(tempOutputDir, pathToClass);
}
final String realOutputDir;
if (myCompileContext.isInTestSourceContent(sourceFile)) {
@@ -782,7 +782,7 @@ public class BackendCompilerWrapper {
if (FileUtil.pathsEqual(tempOutputDir, realOutputDir)) { // no need to move
filesToRefresh.add(new File(pathToClass));
- return new Pair(realOutputDir, pathToClass);
+ return Pair.create(realOutputDir, pathToClass);
}
final String realPathToClass = realOutputDir + pathToClass.substring(tempOutputDir.length());
@@ -809,7 +809,7 @@ public class BackendCompilerWrapper {
}
if (success) {
filesToRefresh.add(toFile);
- return new Pair(realOutputDir, realPathToClass);
+ return Pair.create(realOutputDir, realPathToClass);
}
return null;
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/rmiCompiler/RmicCompiler.java b/java/compiler/impl/src/com/intellij/compiler/impl/rmiCompiler/RmicCompiler.java
index ae0f0b716399..142b6e694d0a 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/rmiCompiler/RmicCompiler.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/rmiCompiler/RmicCompiler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -155,7 +155,7 @@ public class RmicCompiler implements ClassPostProcessingCompiler{
final Map, List> sortedByModuleAndOutputPath = new HashMap, List>();
for (ProcessingItem item1 : items) {
final RmicProcessingItem item = (RmicProcessingItem)item1;
- final Pair moduleOutputPair = new Pair(item.getModule(), item.getOutputDir());
+ final Pair moduleOutputPair = Pair.create(item.getModule(), item.getOutputDir());
List dirItems = sortedByModuleAndOutputPath.get(moduleOutputPair);
if (dirItems == null) {
dirItems = new ArrayList();
diff --git a/java/compiler/impl/src/com/intellij/compiler/make/CachingSearcher.java b/java/compiler/impl/src/com/intellij/compiler/make/CachingSearcher.java
index 8ac89b3b5f77..b232c2ee9485 100644
--- a/java/compiler/impl/src/com/intellij/compiler/make/CachingSearcher.java
+++ b/java/compiler/impl/src/com/intellij/compiler/make/CachingSearcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ public class CachingSearcher {
}
public Collection findReferences(PsiElement element, final boolean ignoreAccessScope) {
- final Pair key = new Pair(element, ignoreAccessScope? Boolean.TRUE : Boolean.FALSE);
+ final Pair key = Pair.create(element, ignoreAccessScope ? Boolean.TRUE : Boolean.FALSE);
Collection psiReferences = myElementToReferencersMap.get(key);
if (psiReferences == null) {
GlobalSearchScope searchScope = GlobalSearchScope.projectScope(myProject);
diff --git a/java/compiler/impl/src/com/intellij/compiler/make/DependencyCache.java b/java/compiler/impl/src/com/intellij/compiler/make/DependencyCache.java
index 92f3285bf8ef..722f9faa8be5 100644
--- a/java/compiler/impl/src/com/intellij/compiler/make/DependencyCache.java
+++ b/java/compiler/impl/src/com/intellij/compiler/make/DependencyCache.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -395,7 +395,7 @@ public class DependencyCache {
throws CacheCorruptedException, ExitException {
markDependencies(context, project, compiledWithErrors);
- return new Pair>(myMarkedInfos.toArray(), Collections.unmodifiableSet(myMarkedFiles));
+ return Pair.create(myMarkedInfos.toArray(), Collections.unmodifiableSet(myMarkedFiles));
}
private void markDependencies(CompileContext context, Project project, final Set compiledWithErrors)
diff --git a/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java b/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java
index f95025b448f9..787391c405a7 100644
--- a/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java
+++ b/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -220,7 +220,7 @@ public class ProcessedModulesTable extends JPanel {
List> elements = new ArrayList>();
for (int idx = 0; idx < count; idx++) {
final Module module = myTableModel.getModuleAt(idx);
- elements.add(new Pair(module, myTableModel.getGenDirName(module)));
+ elements.add(Pair.create(module, myTableModel.getGenDirName(module)));
}
return elements;
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java
index a6ba4a38190a..d324a620155b 100644
--- a/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java
+++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java
@@ -20,9 +20,9 @@ import com.intellij.util.containers.ConcurrentHashSet;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.AttributeKey;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.io.SimpleChannelInboundHandlerAdapter;
import org.jetbrains.jps.api.CmdlineProtoUtil;
import org.jetbrains.jps.api.CmdlineRemoteProto;
@@ -36,7 +36,7 @@ import java.util.concurrent.ConcurrentHashMap;
* Date: 4/25/12
*/
@ChannelHandler.Sharable
-class BuildMessageDispatcher extends SimpleChannelInboundHandler {
+class BuildMessageDispatcher extends SimpleChannelInboundHandlerAdapter {
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.server.BuildMessageDispatcher");
private static final AttributeKey SESSION_DATA = AttributeKey.valueOf("BuildMessageDispatcher.sessionData");
diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerStateSplitter.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerStateSplitter.java
index 90ee240c0a04..14fecb85dbdc 100644
--- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerStateSplitter.java
+++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerStateSplitter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ public class ArtifactManagerStateSplitter implements StateSplitter {
for (Element element : JDOMUtil.getElements(e)) {
final String name = generator.generateUniqueName(FileUtil.sanitizeFileName(element.getAttributeValue(ArtifactState.NAME_ATTRIBUTE))) + ".xml";
- result.add(new Pair(element, name));
+ result.add(Pair.create(element, name));
}
return result;
diff --git a/java/compiler/impl/testSrc/com/intellij/compiler/BaseCompilerTestCase.java b/java/compiler/impl/testSrc/com/intellij/compiler/BaseCompilerTestCase.java
index 5900ea2d6097..ee88a678cabc 100644
--- a/java/compiler/impl/testSrc/com/intellij/compiler/BaseCompilerTestCase.java
+++ b/java/compiler/impl/testSrc/com/intellij/compiler/BaseCompilerTestCase.java
@@ -171,15 +171,15 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
}
protected CompilationLog make(Module... modules) {
- return make(false, modules);
+ return make(false, false, modules);
}
- protected CompilationLog makeWithDependencies(Module... modules) {
- return make(true, modules);
+ protected CompilationLog makeWithDependencies(final boolean includeRuntimeDependencies, Module... modules) {
+ return make(true, includeRuntimeDependencies, modules);
}
- private CompilationLog make(boolean includeDependentModules, Module... modules) {
- return make(getCompilerManager().createModulesCompileScope(modules, includeDependentModules), CompilerFilter.ALL);
+ private CompilationLog make(boolean includeDependentModules, final boolean includeRuntimeDependencies, Module... modules) {
+ return make(getCompilerManager().createModulesCompileScope(modules, includeDependentModules, includeRuntimeDependencies), CompilerFilter.ALL);
}
protected CompilationLog recompile(Module... modules) {
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ModuleCompilerUtil.java b/java/compiler/openapi/src/com/intellij/compiler/ModuleCompilerUtil.java
index 44b7b2a03fc6..1a5a202569df 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ModuleCompilerUtil.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ModuleCompilerUtil.java
@@ -27,6 +27,7 @@ import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ModuleRootModel;
import com.intellij.openapi.util.Pair;
import com.intellij.util.Chunk;
+import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.graph.*;
import org.jetbrains.annotations.Nullable;
@@ -115,14 +116,17 @@ public final class ModuleCompilerUtil {
}
public Iterator getIn(final ModuleRootModel model) {
- final Module[] modules = model.getModuleDependencies();
final List dependencies = new ArrayList();
- for (Module module : modules) {
- T depModel = models.get(module);
- if (depModel != null) {
- dependencies.add(depModel);
+ model.orderEntries().compileOnly().forEachModule(new Processor() {
+ @Override
+ public boolean process(Module module) {
+ T depModel = models.get(module);
+ if (depModel != null) {
+ dependencies.add(depModel);
+ }
+ return true;
}
- }
+ });
return dependencies.iterator();
}
}));
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/CompositeGenerator.java b/java/compiler/openapi/src/com/intellij/compiler/ant/CompositeGenerator.java
index 884e125945b0..a6146ac35860 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/CompositeGenerator.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/CompositeGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,7 +83,7 @@ public class CompositeGenerator extends Generator {
* @param emptyLinesCount amount of empty lines
*/
public final void add(Generator generator, int emptyLinesCount) {
- myGenerators.add(new Pair(generator, new Integer(emptyLinesCount)));
+ myGenerators.add(Pair.create(generator, new Integer(emptyLinesCount)));
}
/**
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/Tag.java b/java/compiler/openapi/src/com/intellij/compiler/ant/Tag.java
index aa08438d4509..4811a94b75a3 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/Tag.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/Tag.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -82,6 +82,6 @@ public class Tag extends CompositeGenerator {
if (v2 == null) {
return null;
}
- return new Pair(v1, v2);
+ return Pair.create(v1, v2);
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/AntCall.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/AntCall.java
index 4768d5fbb347..d2a8ef900b75 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/AntCall.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/AntCall.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,6 @@ import com.intellij.openapi.util.Pair;
public class AntCall extends Tag{
public AntCall(final String target) {
- super("antcall", new Pair[] {new Pair("target", target)});
+ super("antcall", new Pair[] {Pair.create("target", target)});
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/AntProject.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/AntProject.java
index 3aa3eee935f7..911f880800ec 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/AntProject.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/AntProject.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,6 @@ import org.jetbrains.annotations.NonNls;
public class AntProject extends Tag {
public AntProject(@NonNls String name, @NonNls String defaultTarget) {
//noinspection HardCodedStringLiteral
- super("project", new Pair[]{new Pair("name", name), new Pair("default", defaultTarget)});
+ super("project", new Pair[]{Pair.create("name", name), Pair.create("default", defaultTarget)});
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Copy.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Copy.java
index c95348b66367..e10f81c6980e 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Copy.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Copy.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,10 +27,10 @@ import org.jetbrains.annotations.NonNls;
public class Copy extends Tag {
public Copy(@NonNls String toDir) {
//noinspection HardCodedStringLiteral
- super("copy", new Pair[] {new Pair("todir", toDir)});
+ super("copy", new Pair[] {Pair.create("todir", toDir)});
}
public Copy(@NonNls String file, @NonNls String toFile) {
//noinspection HardCodedStringLiteral
- super("copy", new Pair[] {new Pair("file", file), new Pair("tofile", toFile)});
+ super("copy", new Pair[] {Pair.create("file", file), Pair.create("tofile", toFile)});
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/DirSet.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/DirSet.java
index b4cba0848d26..1476f8b8f7e4 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/DirSet.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/DirSet.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,6 @@ public class DirSet extends Tag{
public DirSet(@NonNls final String dir) {
//noinspection HardCodedStringLiteral
- super("dirset", new Pair[] {new Pair("dir", dir)});
+ super("dirset", new Pair[] {Pair.create("dir", dir)});
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Dirname.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Dirname.java
index f833f585014b..7be6755361bd 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Dirname.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Dirname.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,6 @@ import org.jetbrains.annotations.NonNls;
public class Dirname extends Tag{
public Dirname(@NonNls String property, @NonNls String file) {
//noinspection HardCodedStringLiteral
- super("dirname", new Pair[] {new Pair("property", property), new Pair("file", file)});
+ super("dirname", new Pair[] {Pair.create("property", property), Pair.create("file", file)});
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Exclude.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Exclude.java
index 42e7a6aec854..6b9e1ff16ae7 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Exclude.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Exclude.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ public class Exclude extends Tag {
public Exclude(@NonNls final String name) {
//noinspection HardCodedStringLiteral
- super("exclude", new Pair[] {new Pair("name", name)});
+ super("exclude", new Pair[] {Pair.create("name", name)});
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Import.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Import.java
index 2c6e23c7d271..611b6344cf16 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Import.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Import.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,11 +27,11 @@ import org.jetbrains.annotations.NonNls;
public class Import extends Tag{
public Import(@NonNls String file, boolean optional) {
//noinspection HardCodedStringLiteral
- super("import", new Pair[] {new Pair("file", file), new Pair("optional", optional? "true" : "false")});
+ super("import", new Pair[] {Pair.create("file", file), Pair.create("optional", optional ? "true" : "false")});
}
public Import(@NonNls String file) {
//noinspection HardCodedStringLiteral
- super("import", new Pair[] {new Pair("file", file)});
+ super("import", new Pair[] {Pair.create("file", file)});
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Mkdir.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Mkdir.java
index ef15e5c3274b..4c2bff8aafeb 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Mkdir.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Mkdir.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,6 @@ import org.jetbrains.annotations.NonNls;
public class Mkdir extends Tag {
public Mkdir(@NonNls String directory) {
//noinspection HardCodedStringLiteral
- super("mkdir", new Pair[] {new Pair("dir", directory)});
+ super("mkdir", new Pair[] {Pair.create("dir", directory)});
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Param.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Param.java
index 19649e04699f..5eaa4856b669 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Param.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Param.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,8 +28,8 @@ public class Param extends Tag {
public Param(@NonNls final String name, final String value) {
//noinspection HardCodedStringLiteral
super("param", new Pair[] {
- new Pair("name", name),
- new Pair("value", value)
+ Pair.create("name", name),
+ Pair.create("value", value)
});
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/PatternSetRef.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/PatternSetRef.java
index 1055016894b8..6a30765b48ad 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/PatternSetRef.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/PatternSetRef.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,6 @@ import org.jetbrains.annotations.NonNls;
public class PatternSetRef extends Tag{
public PatternSetRef(@NonNls final String refid) {
//noinspection HardCodedStringLiteral
- super("patternset", new Pair[] {new Pair("refid", refid)});
+ super("patternset", new Pair[] {Pair.create("refid", refid)});
}
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Property.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Property.java
index f28d12747e11..2c2f16ad8095 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Property.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Property.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,15 +29,15 @@ public class Property extends Tag {
public Property(@NonNls final String name, final String value) {
//noinspection HardCodedStringLiteral
super("property", new Pair[] {
- new Pair("name", name),
- new Pair("value", value)
+ Pair.create("name", name),
+ Pair.create("value", value)
});
}
public Property(@NonNls final String filePath) {
//noinspection HardCodedStringLiteral
super("property", new Pair[] {
- new Pair("file", filePath),
+ Pair.create("file", filePath),
});
}
diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Target.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Target.java
index fa845a85fb0f..2b17c0b1959b 100644
--- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Target.java
+++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/Target.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public class Target extends Tag{
@SuppressWarnings({"HardCodedStringLiteral"})
private static Pair[] getOptions(@NonNls String... names) {
final List options = new ArrayList();
- options.add(new Pair("name", names[0]));
+ options.add(Pair.create("name", names[0]));
appendIfNonEmpty(options, "depends", names[1]);
appendIfNonEmpty(options, "description", names[2]);
appendIfNonEmpty(options, "unless", names[3]);
@@ -53,7 +53,7 @@ public class Target extends Tag{
private static void appendIfNonEmpty(List options, final String paramName, String value) {
if (!StringUtil.isEmptyOrSpaces(value)) {
- options.add(new Pair(paramName, value));
+ options.add(Pair.create(paramName, value));
}
}
}
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java
index f9d8bce65258..1f0106c11fa4 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java
@@ -285,11 +285,13 @@ public abstract class CompilerManager {
@NotNull
public abstract CompileScope createFilesCompileScope(@NotNull VirtualFile[] files);
@NotNull
- public abstract CompileScope createModuleCompileScope(@NotNull Module module, final boolean includeDependentModules);
+ public abstract CompileScope createModuleCompileScope(@NotNull Module module, boolean includeDependentModules);
@NotNull
- public abstract CompileScope createModulesCompileScope(@NotNull Module[] modules, final boolean includeDependentModules);
+ public abstract CompileScope createModulesCompileScope(@NotNull Module[] modules, boolean includeDependentModules);
@NotNull
- public abstract CompileScope createModuleGroupCompileScope(@NotNull Project project, @NotNull Module[] modules, final boolean includeDependentModules);
+ public abstract CompileScope createModulesCompileScope(@NotNull Module[] modules, boolean includeDependentModules, boolean includeRuntimeDependencies);
+ @NotNull
+ public abstract CompileScope createModuleGroupCompileScope(@NotNull Project project, @NotNull Module[] modules, boolean includeDependentModules);
@NotNull
public abstract CompileScope createProjectCompileScope(@NotNull Project project);
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java
index 5d29954164f9..2f41cb2288f1 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -79,7 +79,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
if(requestor instanceof Breakpoint) {
breakpoint = (Breakpoint)requestor;
}
- String text = debugProcess.getEventText(new Pair(breakpoint, event));
+ String text = debugProcess.getEventText(Pair.create(breakpoint, event));
debugProcess.showStatusText(text);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
index 39451f7122e0..d924822bf9ef 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -189,7 +189,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
if (method == null) {
return null;
}
- return new Pair(method, watcher.getLastMethodReturnValue());
+ return Pair.create(method, watcher.getLastMethodReturnValue());
}
public void setWatchMethodReturnValuesEnabled(boolean enabled) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/CodeFragmentFactoryContextWrapper.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/CodeFragmentFactoryContextWrapper.java
index 4249138bdf29..805fd8b8a91d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/CodeFragmentFactoryContextWrapper.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/CodeFragmentFactoryContextWrapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,9 +18,7 @@ package com.intellij.debugger.engine.evaluation;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilder;
-import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl;
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
-import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
@@ -31,6 +29,7 @@ import com.intellij.psi.JavaRecursiveElementVisitor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLocalVariable;
import com.intellij.util.StringBuilderSpinAllocator;
+import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.Value;
@@ -126,7 +125,7 @@ public class CodeFragmentFactoryContextWrapper extends CodeFragmentFactory {
}
}
buffer.append(" ");
- return new Pair>(buffer.toString(), reverseMap);
+ return Pair.create(buffer.toString(), reverseMap);
}
finally {
StringBuilderSpinAllocator.dispose(buffer);
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/UnBoxingEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/UnBoxingEvaluator.java
index cb4505bb3506..0f3bb4b9bdf4 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/UnBoxingEvaluator.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/UnBoxingEvaluator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,14 +38,14 @@ public class UnBoxingEvaluator implements Evaluator{
private final Evaluator myOperand;
private static final Map> TYPES_TO_CONVERSION_METHOD_MAP = new HashMap>();
static {
- TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Boolean", new Pair("booleanValue", "()Z"));
- TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Byte", new Pair("byteValue", "()B"));
- TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Character", new Pair("charValue", "()C"));
- TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Short", new Pair("shortValue", "()S"));
- TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Integer", new Pair("intValue", "()I"));
- TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Long", new Pair("longValue", "()J"));
- TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Float", new Pair("floatValue", "()F"));
- TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Double", new Pair("doubleValue", "()D"));
+ TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Boolean", Pair.create("booleanValue", "()Z"));
+ TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Byte", Pair.create("byteValue", "()B"));
+ TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Character", Pair.create("charValue", "()C"));
+ TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Short", Pair.create("shortValue", "()S"));
+ TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Integer", Pair.create("intValue", "()I"));
+ TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Long", Pair.create("longValue", "()J"));
+ TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Float", Pair.create("floatValue", "()F"));
+ TYPES_TO_CONVERSION_METHOD_MAP.put("java.lang.Double", Pair.create("doubleValue", "()D"));
}
public static boolean isTypeUnboxable(String typeName) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java
index 1419a2853e84..2c81eae90f72 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -360,7 +360,7 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
for (final Event event : events) {
final Requestor requestor = requestManager.findRequestor(event.request());
if (requestor instanceof Breakpoint) {
- eventDescriptors.add(new Pair((Breakpoint)requestor, event));
+ eventDescriptors.add(Pair.create((Breakpoint)requestor, event));
}
}
return eventDescriptors;
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/MultiProcessCommand.java b/java/debugger/impl/src/com/intellij/debugger/impl/MultiProcessCommand.java
index 9fe6b8c390ff..8abcd6d4e687 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/MultiProcessCommand.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/MultiProcessCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,6 +52,6 @@ public class MultiProcessCommand implements Runnable{
}
public void addCommand(DebugProcessImpl debugProcess, DebuggerCommandImpl command) {
- myCommands.add(new Pair(debugProcess, command));
+ myCommands.add(Pair.create(debugProcess, command));
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java
index ea54ac255023..0f813d0bf167 100644
--- a/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java
+++ b/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -497,7 +497,7 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
public List> getExpressions() {
final ArrayList> pairs = new ArrayList>(myData.size());
for (final Row row : myData) {
- pairs.add(new Pair(row.name, row.value));
+ pairs.add(Pair.create(row.name, row.value));
}
return pairs;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java
index 5694eb1cba67..a3f95f8ea983 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -323,17 +323,17 @@ public class FrameVariablesTree extends DebuggerTree {
EvaluationContextImpl evalContext) {
final int line = position.getLine();
if (line < 0) {
- return new Pair, Set>(Collections.emptySet(), Collections.emptySet());
+ return Pair.create(Collections.emptySet(), Collections.emptySet());
}
final PsiFile positionFile = position.getFile();
if (!positionFile.getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
- return new Pair, Set>(visibleVars, Collections.emptySet());
+ return Pair.create(visibleVars, Collections.emptySet());
}
final VirtualFile vFile = positionFile.getVirtualFile();
final Document doc = vFile != null? FileDocumentManager.getInstance().getDocument(vFile) : null;
if (doc == null || doc.getLineCount() == 0 || line > (doc.getLineCount() - 1)) {
- return new Pair, Set>(Collections.emptySet(), Collections.emptySet());
+ return Pair.create(Collections.emptySet(), Collections.emptySet());
}
final TextRange limit = calculateLimitRange(positionFile, doc, line);
@@ -375,7 +375,7 @@ public class FrameVariablesTree extends DebuggerTree {
//noinspection unchecked
if (element instanceof PsiCompiledElement) {
- return new Pair, Set>(visibleVars, Collections.emptySet());
+ return Pair.create(visibleVars, Collections.emptySet());
}
else {
final Set vars = new HashSet();
@@ -383,11 +383,11 @@ public class FrameVariablesTree extends DebuggerTree {
final PsiElementVisitor variablesCollector = new VariablesCollector(visibleVars, adjustRange(element, lineRange), expressions, vars, position, evalContext);
element.accept(variablesCollector);
- return new Pair, Set>(vars, expressions);
+ return Pair.create(vars, expressions);
}
}
}
- return new Pair, Set>(Collections.emptySet(), Collections.emptySet());
+ return Pair.create(Collections.emptySet(), Collections.emptySet());
}
private static TextRange calculateLimitRange(final PsiFile file, final Document doc, final int line) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/EnumerationChildrenRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/EnumerationChildrenRenderer.java
index 36878a21dfd0..2baefd798965 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/EnumerationChildrenRenderer.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/EnumerationChildrenRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ public final class EnumerationChildrenRenderer extends com.intellij.debugger.ui.
String name = item.getAttributeValue(CHILD_NAME);
TextWithImports text = DebuggerUtils.getInstance().readTextWithImports((Element) item.getChildren().get(0));
- myChildren.add(new Pair(name, text));
+ myChildren.add(Pair.create(name, text));
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/configurables/NamedChildrenConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/configurables/NamedChildrenConfigurable.java
index 7e1515f4d170..fe4861de14eb 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/configurables/NamedChildrenConfigurable.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/configurables/NamedChildrenConfigurable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -138,7 +138,7 @@ public class NamedChildrenConfigurable implements UnnamedConfigurable{
java.util.List> result = new ArrayList>();
for (int idx = 0; idx < size; idx++) {
- result.add(new Pair((String)model.getValueAt(idx, 0), (TextWithImports)model.getValueAt(idx, 1)));
+ result.add(Pair.create((String)model.getValueAt(idx, 0), (TextWithImports)model.getValueAt(idx, 1)));
}
myRenderer.setChildren(result);
}
diff --git a/java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java b/java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java
index 57efc543da2d..124220d75966 100644
--- a/java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java
+++ b/java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java
@@ -143,7 +143,7 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider(radioButton, comboBox));
+ myButtons.put(ri, Pair.create(radioButton, comboBox));
myButtonGroup.add(radioButton);
}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
index e6de88efc4e0..59024a8d89c2 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
@@ -540,6 +540,11 @@ public class GenericsHighlightUtil {
return null;
}
+ if (superMethod.hasModifierProperty(PsiModifier.STATIC) && superContainingClass != null &&
+ superContainingClass.isInterface() && PsiUtil.isLanguageLevel8OrHigher(superContainingClass)) {
+ return null;
+ }
+
final PsiType retErasure1 = TypeConversionUtil.erasure(checkMethod.getReturnType());
final PsiType retErasure2 = TypeConversionUtil.erasure(superMethod.getReturnType());
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
index ee07cf92bbcc..247c03005a92 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
@@ -1142,6 +1142,7 @@ public class HighlightMethodUtil {
}
if (isMethodStatic) {
+ if (superClass.isInterface()) return null;
int accessLevel = PsiUtil.getAccessLevel(modifierList);
String accessModifier = PsiUtil.getAccessModifier(accessLevel);
HighlightInfo info = isWeaker(method, modifierList, accessModifier, accessLevel, superMethod, true);
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstanceBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstanceBase.java
index 6c75f8be8e7d..00c66668638f 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstanceBase.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstanceBase.java
@@ -19,17 +19,14 @@ import com.intellij.codeInsight.daemon.JavaErrorMessages;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil;
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableUtil;
-import com.intellij.codeInspection.BaseJavaBatchLocalInspectionTool;
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemsHolder;
+import com.intellij.codeInspection.*;
import com.intellij.psi.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
-public class AccessStaticViaInstanceBase extends BaseJavaBatchLocalInspectionTool {
+public class AccessStaticViaInstanceBase extends BaseJavaBatchLocalInspectionTool implements CleanupLocalInspectionTool {
@NonNls public static final String ACCESS_STATIC_VIA_INSTANCE = "AccessStaticViaInstance";
@Override
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/duplicateThrows/DuplicateThrowsInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/duplicateThrows/DuplicateThrowsInspection.java
index b95c3c9c4b63..c40f4385f3e4 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/duplicateThrows/DuplicateThrowsInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/duplicateThrows/DuplicateThrowsInspection.java
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-public class DuplicateThrowsInspection extends BaseJavaBatchLocalInspectionTool {
+public class DuplicateThrowsInspection extends BaseJavaBatchLocalInspectionTool implements CleanupLocalInspectionTool {
@SuppressWarnings("PublicField")
public boolean ignoreSubclassing = false;
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java
index 80d11cbb2471..cd8d804d16d1 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java
@@ -15,10 +15,7 @@
*/
package com.intellij.codeInspection.miscGenerics;
-import com.intellij.codeInspection.BaseJavaBatchLocalInspectionTool;
-import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.codeInspection.ProblemsHolder;
+import com.intellij.codeInspection.*;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.containers.ContainerUtil;
@@ -31,7 +28,7 @@ import java.util.List;
/**
* @author ven
*/
-public abstract class GenericsInspectionToolBase extends BaseJavaBatchLocalInspectionTool {
+public abstract class GenericsInspectionToolBase extends BaseJavaBatchLocalInspectionTool implements CleanupLocalInspectionTool {
@Override
public boolean isEnabledByDefault() {
return true;
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java b/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java
index 61b501c78ec9..424c707706e5 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java
@@ -33,7 +33,7 @@ import java.util.Set;
* @author anna
* @since 15-Nov-2005
*/
-public class RedundantThrowsDeclaration extends BaseJavaBatchLocalInspectionTool {
+public class RedundantThrowsDeclaration extends BaseJavaBatchLocalInspectionTool implements CleanupLocalInspectionTool {
@Override
@NotNull
public String getGroupDisplayName() {
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddDeprecationAnnotationIntention.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddDeprecationAnnotationIntention.java
index bcc4e4c1cb5d..35c6d09d1fe3 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddDeprecationAnnotationIntention.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddDeprecationAnnotationIntention.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,6 @@ public class AddDeprecationAnnotationIntention extends AddAnnotationIntention {
@NotNull
@Override
public Pair getAnnotations(@NotNull Project project) {
- return new Pair("java.lang.annotation.Deprecated", ArrayUtil.EMPTY_STRING_ARRAY);
+ return Pair.create("java.lang.annotation.Deprecated", ArrayUtil.EMPTY_STRING_ARRAY);
}
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNotNullAnnotationIntention.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNotNullAnnotationIntention.java
index b5e322503b4c..b44de1d4c7e4 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNotNullAnnotationIntention.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNotNullAnnotationIntention.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ public class AddNotNullAnnotationIntention extends AddAnnotationIntention {
@NotNull
@Override
public Pair getAnnotations(@NotNull Project project) {
- return new Pair(NullableNotNullManager.getInstance(project).getDefaultNotNull(), getNullables(project));
+ return Pair.create(NullableNotNullManager.getInstance(project).getDefaultNotNull(), getNullables(project));
}
@NotNull
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableAnnotationIntention.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableAnnotationIntention.java
index 3979218b069a..d0e0602bd0d8 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableAnnotationIntention.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableAnnotationIntention.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ public class AddNullableAnnotationIntention extends AddAnnotationIntention {
@NotNull
@Override
public Pair getAnnotations(@NotNull Project project) {
- return new Pair(NullableNotNullManager.getInstance(project).getDefaultNullable(), getNotNulls(project));
+ return Pair.create(NullableNotNullManager.getInstance(project).getDefaultNullable(), getNotNulls(project));
}
@NotNull
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/impl/ShortenToStaticImportProcessor.java b/java/java-impl/src/com/intellij/codeInsight/template/impl/ShortenToStaticImportProcessor.java
index cf2f8c1176ba..41424cf2b526 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/impl/ShortenToStaticImportProcessor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/impl/ShortenToStaticImportProcessor.java
@@ -67,7 +67,7 @@ public class ShortenToStaticImportProcessor implements TemplateOptionalProcessor
{
for (StaticImporter importer : IMPORTERS) {
if (importer.canPerform(element)) {
- staticImportTargets.add(new Pair(element, importer));
+ staticImportTargets.add(Pair.create(element, importer));
break;
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/AssertStatementPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/AssertStatementPostfixTemplate.java
index c48ef1b97ba1..90812945f7e6 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/AssertStatementPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/AssertStatementPostfixTemplate.java
@@ -15,18 +15,20 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
-public class AssertStatementPostfixTemplate extends BooleanPostfixTemplate {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.IS_BOOLEAN;
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class AssertStatementPostfixTemplate extends JavaStatementWrapPostfixTemplate {
+
public AssertStatementPostfixTemplate() {
- super("assert", "assert expr;");
+ super("assert", "assert expr;", JAVA_PSI_INFO, IS_BOOLEAN);
}
+ @NotNull
@Override
- public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PostfixTemplatesUtils.createSimpleStatement(context, editor, "assert");
+ protected String getHead() {
+ return "assert ";
}
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/CastExpressionPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/CastExpressionPostfixTemplate.java
index 7c56047fe059..4cb9bbc5eb0e 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/CastExpressionPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/CastExpressionPostfixTemplate.java
@@ -16,7 +16,6 @@
package com.intellij.codeInsight.template.postfix.templates;
import com.intellij.codeInsight.generation.surroundWith.JavaWithCastSurrounder;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiExpression;
import org.jetbrains.annotations.NotNull;
@@ -28,6 +27,6 @@ public class CastExpressionPostfixTemplate extends ExpressionPostfixTemplateWith
@Override
protected void doIt(@NotNull final Editor editor, @NotNull final PsiExpression expression) {
- PostfixTemplatesUtils.apply(new JavaWithCastSurrounder(), expression.getProject(), editor, expression);
+ PostfixTemplatesUtils.surround(new JavaWithCastSurrounder(), editor, expression);
}
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ElseStatementPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ElseStatementPostfixTemplate.java
index f92f4c81f71b..b9b6c3437123 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ElseStatementPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ElseStatementPostfixTemplate.java
@@ -15,27 +15,21 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.CodeInsightServicesUtil;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiExpression;
+import com.intellij.codeInsight.generation.surroundWith.JavaWithIfExpressionSurrounder;
+import com.intellij.lang.surroundWith.Surrounder;
import org.jetbrains.annotations.NotNull;
-public class ElseStatementPostfixTemplate extends BooleanPostfixTemplate {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.IS_BOOLEAN;
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class ElseStatementPostfixTemplate extends ElseExpressionPostfixTemplateBase {
public ElseStatementPostfixTemplate() {
- super("else", "if (!expr)");
+ super(JAVA_PSI_INFO, IS_BOOLEAN);
}
+ @NotNull
@Override
- public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PsiExpression expression = PostfixTemplatesUtils.getTopmostExpression(context);
- assert expression != null;
- PsiExpression invertedExpression = (PsiExpression)expression.replace(CodeInsightServicesUtil.invertCondition(expression));
- TextRange range = PostfixTemplatesUtils.ifStatement(invertedExpression.getProject(), editor, invertedExpression);
- if (range != null) {
- editor.getCaretModel().moveToOffset(range.getStartOffset());
- }
+ protected Surrounder getSurrounder() {
+ return new JavaWithIfExpressionSurrounder();
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ExpressionPostfixTemplateWithChooser.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ExpressionPostfixTemplateWithChooser.java
index 69df4ccd40a7..25bd61f00b7d 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ExpressionPostfixTemplateWithChooser.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ExpressionPostfixTemplateWithChooser.java
@@ -15,7 +15,7 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import com.intellij.codeInsight.unwrap.ScopeHighlighter;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
@@ -108,7 +108,7 @@ public abstract class ExpressionPostfixTemplateWithChooser extends PostfixTempla
@NotNull
private static List maybeTopmostExpression(@NotNull PsiElement context) {
- PsiExpression expression = PostfixTemplatesUtils.getTopmostExpression(context);
+ PsiExpression expression = JavaPostfixTemplatesUtils.getTopmostExpression(context);
PsiType type = expression != null ? expression.getType() : null;
if (type == null || PsiType.VOID.equals(type)) return ContainerUtil.emptyList();
return ContainerUtil.createMaybeSingletonList(expression);
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForDescendingPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForDescendingPostfixTemplate.java
index b55405b01e3c..6b70cd2db844 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForDescendingPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForDescendingPostfixTemplate.java
@@ -15,7 +15,7 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiExpression;
import org.jetbrains.annotations.NotNull;
@@ -35,7 +35,7 @@ public class ForDescendingPostfixTemplate extends ForIndexedPostfixTemplate {
@NotNull
@Override
protected String getComparativeSign(@NotNull PsiExpression expr) {
- return PostfixTemplatesUtils.isNumber(expr.getType()) ? ">" : ">=";
+ return JavaPostfixTemplatesUtils.isNumber(expr.getType()) ? ">" : ">=";
}
@Nullable
@@ -45,7 +45,7 @@ public class ForDescendingPostfixTemplate extends ForIndexedPostfixTemplate {
if (bound == null) {
return null;
}
- return PostfixTemplatesUtils.isNumber(expression.getType())
+ return JavaPostfixTemplatesUtils.isNumber(expression.getType())
? Pair.create(bound, "0")
: Pair.create(bound + " - 1", "0");
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java
index 4fd22ed5e67d..745d76ff61a5 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java
@@ -19,7 +19,7 @@ import com.intellij.codeInsight.template.Template;
import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.codeInsight.template.impl.MacroCallNode;
import com.intellij.codeInsight.template.macro.SuggestVariableNameMacro;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -37,15 +37,15 @@ public abstract class ForIndexedPostfixTemplate extends PostfixTemplate {
@Override
public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- PsiExpression expr = PostfixTemplatesUtils.getTopmostExpression(context);
- return expr != null && (PostfixTemplatesUtils.isNumber(expr.getType()) ||
- PostfixTemplatesUtils.isArray(expr.getType()) ||
- PostfixTemplatesUtils.isIterable(expr.getType()));
+ PsiExpression expr = JavaPostfixTemplatesUtils.getTopmostExpression(context);
+ return expr != null && (JavaPostfixTemplatesUtils.isNumber(expr.getType()) ||
+ JavaPostfixTemplatesUtils.isArray(expr.getType()) ||
+ JavaPostfixTemplatesUtils.isIterable(expr.getType()));
}
@Override
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PsiExpression expr = PostfixTemplatesUtils.getTopmostExpression(context);
+ PsiExpression expr = JavaPostfixTemplatesUtils.getTopmostExpression(context);
if (expr == null) {
PostfixTemplatesUtils.showErrorHint(context.getProject(), editor);
return;
@@ -94,13 +94,13 @@ public abstract class ForIndexedPostfixTemplate extends PostfixTemplate {
@Nullable
protected static String getExpressionBound(@NotNull PsiExpression expr) {
PsiType type = expr.getType();
- if (PostfixTemplatesUtils.isNumber(type)) {
+ if (JavaPostfixTemplatesUtils.isNumber(type)) {
return expr.getText();
}
- else if (PostfixTemplatesUtils.isArray(type)) {
+ else if (JavaPostfixTemplatesUtils.isArray(type)) {
return expr.getText() + ".length";
}
- else if (PostfixTemplatesUtils.isIterable(type)) {
+ else if (JavaPostfixTemplatesUtils.isIterable(type)) {
return expr.getText() + ".size()";
}
return null;
@@ -109,7 +109,7 @@ public abstract class ForIndexedPostfixTemplate extends PostfixTemplate {
@NotNull
private static String suggestIndexType(@NotNull PsiExpression expr) {
PsiType type = expr.getType();
- if (PostfixTemplatesUtils.isNumber(type)) {
+ if (JavaPostfixTemplatesUtils.isNumber(type)) {
return type.getCanonicalText();
}
return "int";
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForeachPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForeachPostfixTemplate.java
index 88f07dca85ce..aefafaebc235 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForeachPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForeachPostfixTemplate.java
@@ -22,7 +22,7 @@ import com.intellij.codeInsight.template.impl.TextExpression;
import com.intellij.codeInsight.template.impl.VariableNode;
import com.intellij.codeInsight.template.macro.IterableComponentTypeMacro;
import com.intellij.codeInsight.template.macro.SuggestVariableNameMacro;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -37,13 +37,13 @@ public class ForeachPostfixTemplate extends PostfixTemplate {
@Override
public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- PsiExpression expr = PostfixTemplatesUtils.getTopmostExpression(context);
- return expr != null && (PostfixTemplatesUtils.isArray(expr.getType()) || PostfixTemplatesUtils.isIterable(expr.getType()));
+ PsiExpression expr = JavaPostfixTemplatesUtils.getTopmostExpression(context);
+ return expr != null && (JavaPostfixTemplatesUtils.isArray(expr.getType()) || JavaPostfixTemplatesUtils.isIterable(expr.getType()));
}
@Override
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PsiExpression expr = PostfixTemplatesUtils.getTopmostExpression(context);
+ PsiExpression expr = JavaPostfixTemplatesUtils.getTopmostExpression(context);
if (expr == null) return;
Project project = context.getProject();
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/FormatPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/FormatPostfixTemplate.java
index 288df0770259..f312d44d1d7c 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/FormatPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/FormatPostfixTemplate.java
@@ -15,29 +15,48 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.util.Condition;
import com.intellij.psi.CommonClassNames;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiExpression;
import com.intellij.psi.PsiType;
import org.jetbrains.annotations.NotNull;
-public class FormatPostfixTemplate extends PostfixTemplate {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class FormatPostfixTemplate extends JavaStatementWrapPostfixTemplate {
+ private static final Condition IS_STRING = new Condition() {
+ @Override
+ public boolean value(PsiElement expr) {
+ if (!(expr instanceof PsiExpression)) {
+ return false;
+ }
+ PsiType type = ((PsiExpression)expr).getType();
+ return type != null && CommonClassNames.JAVA_LANG_STRING.equals(type.getCanonicalText());
+ }
+ };
+
+
public FormatPostfixTemplate() {
- super("format", "String.format(expr);");
+ super("format", "String.format(expr);", JAVA_PSI_INFO, IS_STRING);
}
@Override
- public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PostfixTemplatesUtils.createStatement(context, editor, "String.format(", ", )", -2);
+ protected void afterExpand(@NotNull PsiElement newElement, @NotNull Editor editor) {
+ editor.getCaretModel().moveToOffset(newElement.getTextRange().getEndOffset() - 2);
+ JavaPostfixTemplateProvider.doNotDeleteSemicolon(newElement.getContainingFile());
}
+ @NotNull
@Override
- public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- PsiExpression expr = PostfixTemplatesUtils.getTopmostExpression(context);
- PsiType type = expr != null ? expr.getType() : null;
- return expr != null && type != null && CommonClassNames.JAVA_LANG_STRING.equals(type.getCanonicalText());
+ protected String getHead() {
+ return "String.format(";
+ }
+
+ @NotNull
+ @Override
+ protected String getTail() {
+ return ", );";
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IfStatementPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IfStatementPostfixTemplate.java
index 231a7a2cf10f..ff0ace20ab2b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IfStatementPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IfStatementPostfixTemplate.java
@@ -15,26 +15,22 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiExpression;
+import com.intellij.codeInsight.generation.surroundWith.JavaWithIfExpressionSurrounder;
+import com.intellij.lang.surroundWith.Surrounder;
import org.jetbrains.annotations.NotNull;
-public class IfStatementPostfixTemplate extends BooleanPostfixTemplate {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.IS_BOOLEAN;
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class IfStatementPostfixTemplate extends IfPostfixTemplateBase {
public IfStatementPostfixTemplate() {
- super("if", "if (expr)");
+ super(JAVA_PSI_INFO, IS_BOOLEAN);
}
+ @NotNull
@Override
- public void expand(@NotNull PsiElement context, @NotNull final Editor editor) {
- PsiExpression expression = PostfixTemplatesUtils.getTopmostExpression(context);
- assert expression != null;
- TextRange range = PostfixTemplatesUtils.ifStatement(expression.getProject(), editor, expression);
- if (range != null) {
- editor.getCaretModel().moveToOffset(range.getStartOffset());
- }
+ protected Surrounder getSurrounder() {
+ return new JavaWithIfExpressionSurrounder();
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/InstanceofExpressionPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/InstanceofExpressionPostfixTemplate.java
index 1bb19448b1ea..2b00a06b5a0f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/InstanceofExpressionPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/InstanceofExpressionPostfixTemplate.java
@@ -19,7 +19,7 @@ import com.intellij.codeInsight.guess.GuessManager;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
import com.intellij.codeInsight.template.*;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.RangeMarker;
@@ -46,13 +46,13 @@ public class InstanceofExpressionPostfixTemplate extends PostfixTemplate {
@Override
public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- return PostfixTemplatesUtils.isNotPrimitiveTypeExpression(PostfixTemplatesUtils.getTopmostExpression(context));
+ return JavaPostfixTemplatesUtils.isNotPrimitiveTypeExpression(JavaPostfixTemplatesUtils.getTopmostExpression(context));
}
@Override
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PsiExpression expression = PostfixTemplatesUtils.getTopmostExpression(context);
- if (!PostfixTemplatesUtils.isNotPrimitiveTypeExpression(expression)) return;
+ PsiExpression expression = JavaPostfixTemplatesUtils.getTopmostExpression(context);
+ if (!JavaPostfixTemplatesUtils.isNotPrimitiveTypeExpression(expression)) return;
surroundExpression(context.getProject(), editor, expression);
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IsNullCheckPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IsNullCheckPostfixTemplate.java
index 428935a7870b..26c510405b97 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IsNullCheckPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IsNullCheckPostfixTemplate.java
@@ -15,11 +15,16 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
+import com.intellij.codeInsight.generation.surroundWith.JavaWithIfExpressionSurrounder;
+import com.intellij.lang.surroundWith.Surrounder;
import org.jetbrains.annotations.NotNull;
-public class IsNullCheckPostfixTemplate extends NullCheckPostfixTemplate {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.IS_NOT_PRIMITIVE;
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class IsNullCheckPostfixTemplate extends SurroundPostfixTemplateBase {
public IsNullCheckPostfixTemplate() {
- super("null", "if (expr == null)");
+ super("null", "if (expr == null)", JAVA_PSI_INFO, IS_NOT_PRIMITIVE);
}
@NotNull
@@ -27,4 +32,10 @@ public class IsNullCheckPostfixTemplate extends NullCheckPostfixTemplate {
protected String getTail() {
return "== null";
}
+
+ @NotNull
+ @Override
+ protected Surrounder getSurrounder() {
+ return new JavaWithIfExpressionSurrounder();
+ }
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/JavaStatementWrapPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/JavaStatementWrapPostfixTemplate.java
new file mode 100644
index 000000000000..b88a702fe31b
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/JavaStatementWrapPostfixTemplate.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.template.postfix.templates;
+
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.util.Condition;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+
+public abstract class JavaStatementWrapPostfixTemplate extends StatementWrapPostfixTemplate {
+
+ protected JavaStatementWrapPostfixTemplate(@NotNull String name,
+ @NotNull String descr,
+ @NotNull PostfixTemplatePsiInfo psiInfo,
+ @NotNull Condition typeChecker) {
+ super(name, descr, psiInfo, typeChecker);
+ }
+
+ @Override
+ protected void afterExpand(@NotNull PsiElement newElement, @NotNull Editor editor) {
+ super.afterExpand(newElement, editor);
+ JavaPostfixTemplateProvider.doNotDeleteSemicolon(newElement.getContainingFile());
+ }
+
+ @NotNull
+ @Override
+ protected String getTail() {
+ return ";";
+ }
+}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotExpressionPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotExpressionPostfixTemplate.java
index 29cfb22c02fa..55e53fe4126c 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotExpressionPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotExpressionPostfixTemplate.java
@@ -16,7 +16,7 @@
package com.intellij.codeInsight.template.postfix.templates;
import com.intellij.codeInsight.CodeInsightServicesUtil;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiExpression;
@@ -26,7 +26,7 @@ public class NotExpressionPostfixTemplate extends ExpressionPostfixTemplateWithC
private static final Condition BOOLEAN_TYPE_CONDITION = new Condition() {
@Override
public boolean value(PsiExpression expression) {
- return PostfixTemplatesUtils.isBoolean(expression.getType());
+ return JavaPostfixTemplatesUtils.isBoolean(expression.getType());
}
};
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotNullCheckPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotNullCheckPostfixTemplate.java
index 58a9ebf7a484..47a794518289 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotNullCheckPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotNullCheckPostfixTemplate.java
@@ -15,16 +15,21 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
+import com.intellij.codeInsight.generation.surroundWith.JavaWithIfExpressionSurrounder;
+import com.intellij.lang.surroundWith.Surrounder;
import org.jetbrains.annotations.NotNull;
-public class NotNullCheckPostfixTemplate extends NullCheckPostfixTemplate {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.IS_NOT_PRIMITIVE;
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class NotNullCheckPostfixTemplate extends SurroundPostfixTemplateBase {
public NotNullCheckPostfixTemplate() {
this("notnull");
}
public NotNullCheckPostfixTemplate(String alias) {
- super(alias, "if (expr != null)");
+ super(alias, "if (expr != null)", JAVA_PSI_INFO, IS_NOT_PRIMITIVE);
}
@NotNull
@@ -32,4 +37,10 @@ public class NotNullCheckPostfixTemplate extends NullCheckPostfixTemplate {
protected String getTail() {
return "!= null";
}
+
+ @NotNull
+ @Override
+ protected Surrounder getSurrounder() {
+ return new JavaWithIfExpressionSurrounder();
+ }
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java
deleted file mode 100644
index c77b2d527b54..000000000000
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2000-2014 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.template.postfix.templates;
-
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiElementFactory;
-import com.intellij.psi.PsiExpression;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author ignatov
- */
-public abstract class NullCheckPostfixTemplate extends PostfixTemplate {
- protected NullCheckPostfixTemplate(@NotNull String name, @NotNull String example) {
- super(name, example);
- }
-
- @NotNull
- abstract String getTail();
-
- @Override
- public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- return PostfixTemplatesUtils.isNotPrimitiveTypeExpression(PostfixTemplatesUtils.getTopmostExpression(context));
- }
-
- @Override
- public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PsiExpression expr = PostfixTemplatesUtils.getTopmostExpression(context);
- if (!PostfixTemplatesUtils.isNotPrimitiveTypeExpression(expr)) return;
-
- Project project = expr.getProject();
- PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
- PsiExpression condition = factory.createExpressionFromText(expr.getText() + getTail(), context);
-
- PsiElement replace = expr.replace(condition);
- assert replace instanceof PsiExpression;
-
- TextRange range = PostfixTemplatesUtils.ifStatement(project, editor, (PsiExpression)replace);
- if (range != null) {
- editor.getCaretModel().moveToOffset(range.getStartOffset());
- }
- }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ReturnStatementPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ReturnStatementPostfixTemplate.java
index 21707353d31f..4f60680e788e 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ReturnStatementPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ReturnStatementPostfixTemplate.java
@@ -15,18 +15,19 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
-public class ReturnStatementPostfixTemplate extends NonVoidPostfixTemplate {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.IS_NON_VOID;
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class ReturnStatementPostfixTemplate extends JavaStatementWrapPostfixTemplate {
public ReturnStatementPostfixTemplate() {
- super("return", "return expr;");
+ super("return", "return expr;", JAVA_PSI_INFO, IS_NON_VOID);
}
+ @NotNull
@Override
- public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PostfixTemplatesUtils.createSimpleStatement(context, editor, "return");
+ protected String getHead() {
+ return "return ";
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SoutPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SoutPostfixTemplate.java
index b04d001402c9..149141840f5f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SoutPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SoutPostfixTemplate.java
@@ -15,18 +15,25 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
-public class SoutPostfixTemplate extends NonVoidPostfixTemplate {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.IS_NON_VOID;
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class SoutPostfixTemplate extends JavaStatementWrapPostfixTemplate {
public SoutPostfixTemplate() {
- super("sout", "System.out.println(expr);");
+ super("sout", "System.out.println(expr);", JAVA_PSI_INFO, IS_NON_VOID);
}
+ @NotNull
@Override
- public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PostfixTemplatesUtils.createStatement(context, editor, "System.out.println(", ")");
+ protected String getHead() {
+ return "System.out.println(";
+ }
+
+ @NotNull
+ @Override
+ protected String getTail() {
+ return ");";
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/StatementPostfixTemplateBase.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/StatementPostfixTemplateBase.java
deleted file mode 100644
index 593e45f930d5..000000000000
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/StatementPostfixTemplateBase.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2000-2014 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.template.postfix.templates;
-
-import com.intellij.codeInsight.CodeInsightUtilCore;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.util.PsiTreeUtil;
-
-/**
- * @author ignatov
- */
-public abstract class StatementPostfixTemplateBase extends PostfixTemplate {
- protected StatementPostfixTemplateBase(String name, String example) {
- super(name, example);
- }
-
- protected void surroundWith(PsiElement context, Editor editor, String text) {
- PsiExpression expr = PostfixTemplatesUtils.getTopmostExpression(context);
- PsiElement parent = expr != null ? expr.getParent() : null;
- if (!(parent instanceof PsiExpressionStatement)) return;
-
- Project project = context.getProject();
- PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
- CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
- PsiElement statement = codeStyleManager.reformat(factory.createStatementFromText(text + " (" + expr.getText() + ") {\nst;\n}", context));
- statement = parent.replace(statement);
-
- //noinspection ConstantConditions
- PsiCodeBlock block = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(PsiTreeUtil.getChildOfType(statement, PsiCodeBlock.class));
- TextRange range = block.getStatements()[0].getTextRange();
- editor.getDocument().deleteString(range.getStartOffset(), range.getEndOffset());
-
- editor.getCaretModel().moveToOffset(range.getStartOffset());
- }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SwitchStatementPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SwitchStatementPostfixTemplate.java
index e84aa8ed38fd..21122d0f0128 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SwitchStatementPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SwitchStatementPostfixTemplate.java
@@ -15,49 +15,65 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.util.Condition;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-public class SwitchStatementPostfixTemplate extends StatementPostfixTemplateBase {
- public SwitchStatementPostfixTemplate() {
- super("switch", "switch (expr)");
- }
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
- private static boolean isSwitchCompatibleType(@Nullable PsiType type, @NotNull PsiElement context) {
- if (type == null) return false;
- if (PsiType.INT.isAssignableFrom(type)) return true;
-
- if (type instanceof PsiClassType) {
- PsiClass psiClass = ((PsiClassType)type).resolve();
- if (psiClass != null && psiClass.isEnum()) return true;
- }
-
- if (type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
- if (ApplicationManager.getApplication().isUnitTestMode()) return true; // todo: mock jdk 6 and 7
- PsiFile containingFile = context.getContainingFile();
- if (containingFile instanceof PsiJavaFile) {
- LanguageLevel level = ((PsiJavaFile)containingFile).getLanguageLevel();
- if (level.isAtLeast(LanguageLevel.JDK_1_7)) return true;
+public class SwitchStatementPostfixTemplate extends JavaStatementWrapPostfixTemplate {
+ private static final Condition SWITCH_TYPE = new Condition() {
+ @Override
+ public boolean value(PsiElement expression) {
+ if (!(expression instanceof PsiExpression)) {
+ return false;
}
+
+ PsiType type = ((PsiExpression)expression).getType();
+
+ if (type == null) return false;
+ if (PsiType.INT.isAssignableFrom(type)) return true;
+
+ if (type instanceof PsiClassType) {
+ PsiClass psiClass = ((PsiClassType)type).resolve();
+ if (psiClass != null && psiClass.isEnum()) return true;
+ }
+
+ if (type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
+ if (ApplicationManager.getApplication().isUnitTestMode()) return true; // todo: mock jdk 6 and 7
+ PsiFile containingFile = expression.getContainingFile();
+ if (containingFile instanceof PsiJavaFile) {
+ LanguageLevel level = ((PsiJavaFile)containingFile).getLanguageLevel();
+ if (level.isAtLeast(LanguageLevel.JDK_1_7)) return true;
+ }
+ }
+
+ return false;
}
+ };
- return false;
+ public SwitchStatementPostfixTemplate() {
+ super("switch", "switch (expr)", JAVA_PSI_INFO, SWITCH_TYPE);
}
@Override
- public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- PsiExpression expr = PostfixTemplatesUtils.getTopmostExpression(context);
- return expr != null && isSwitchCompatibleType(expr.getType(), context);
+ protected void afterExpand(@NotNull PsiElement newStatement, @NotNull Editor editor) {
+ JavaPostfixTemplatesUtils.formatPsiCodeBlock(newStatement, editor);
}
+ @NotNull
@Override
- public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- surroundWith(context, editor, "switch");
+ protected String getHead() {
+ return "switch (";
+ }
+
+ @NotNull
+ @Override
+ protected String getTail() {
+ return ") {\nst;\n}";
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SynchronizedStatementPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SynchronizedStatementPostfixTemplate.java
index 2bf17b5fad5f..b2f6fd25ffe3 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SynchronizedStatementPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/SynchronizedStatementPostfixTemplate.java
@@ -15,29 +15,34 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Document;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiExpression;
-import com.intellij.psi.PsiPrimitiveType;
-import com.intellij.psi.PsiType;
import org.jetbrains.annotations.NotNull;
-public class SynchronizedStatementPostfixTemplate extends StatementPostfixTemplateBase {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.IS_NOT_PRIMITIVE;
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class SynchronizedStatementPostfixTemplate extends JavaStatementWrapPostfixTemplate {
public SynchronizedStatementPostfixTemplate() {
- super("synchronized", "synchronized (expr)");
+ super("synchronized", "synchronized (expr)", JAVA_PSI_INFO, IS_NOT_PRIMITIVE);
}
@Override
- public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- PsiExpression expression = PostfixTemplatesUtils.getTopmostExpression(context);
- PsiType type = expression != null ? expression.getType() : null;
- return type != null && !(type instanceof PsiPrimitiveType);
+ protected void afterExpand(@NotNull PsiElement newStatement, @NotNull Editor editor) {
+ JavaPostfixTemplatesUtils.formatPsiCodeBlock(newStatement, editor);
}
+ @NotNull
@Override
- public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- surroundWith(context, editor, "synchronized");
+ protected String getHead() {
+ return "synchronized (";
}
+
+ @NotNull
+ @Override
+ protected String getTail() {
+ return ") {\nst;\n}";
+ }
+
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ThrowExceptionPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ThrowExceptionPostfixTemplate.java
index 98762cd5c0f7..b8dbd640d246 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ThrowExceptionPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ThrowExceptionPostfixTemplate.java
@@ -15,26 +15,17 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiExpression;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import org.jetbrains.annotations.NotNull;
-public class ThrowExceptionPostfixTemplate extends PostfixTemplate {
+public class ThrowExceptionPostfixTemplate extends JavaStatementWrapPostfixTemplate {
public ThrowExceptionPostfixTemplate() {
- super("throw", "throw expr;");
+ super("throw", "throw expr;", JavaPostfixTemplatesUtils.JAVA_PSI_INFO, JavaPostfixTemplatesUtils.IS_THROWABLE);
}
+ @NotNull
@Override
- public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- PsiExpression expression = PostfixTemplatesUtils.getTopmostExpression(context);
- return expression != null && PostfixTemplatesUtils.isThrowable(expression.getType());
- }
-
- @Override
- public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PostfixTemplatesUtils.createSimpleStatement(context, editor, "throw");
+ protected String getHead() {
+ return "throw ";
}
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryStatementPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryStatementPostfixTemplate.java
index 9b890d6e473f..0c58e42e7430 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryStatementPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryStatementPostfixTemplate.java
@@ -16,7 +16,6 @@
package com.intellij.codeInsight.template.postfix.templates;
import com.intellij.codeInsight.generation.surroundWith.JavaWithTryCatchSurrounder;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryWithResourcesPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryWithResourcesPostfixTemplate.java
index 74a56c8da21a..b112eecc0457 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryWithResourcesPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryWithResourcesPostfixTemplate.java
@@ -22,7 +22,7 @@ import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.codeInsight.template.impl.MacroCallNode;
import com.intellij.codeInsight.template.impl.TextExpression;
import com.intellij.codeInsight.template.macro.SuggestVariableNameMacro;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
+import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -45,7 +45,7 @@ public class TryWithResourcesPostfixTemplate extends PostfixTemplate {
public boolean isApplicable(@NotNull PsiElement element, @NotNull Document copyDocument, int newOffset) {
if (!PsiUtil.isLanguageLevel7OrHigher(element)) return false;
- PsiExpression initializer = PostfixTemplatesUtils.getTopmostExpression(element);
+ PsiExpression initializer = JavaPostfixTemplatesUtils.getTopmostExpression(element);
if (initializer == null) return false;
@@ -62,7 +62,7 @@ public class TryWithResourcesPostfixTemplate extends PostfixTemplate {
@Override
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PsiExpression expression = PostfixTemplatesUtils.getTopmostExpression(context);
+ PsiExpression expression = JavaPostfixTemplatesUtils.getTopmostExpression(context);
assert expression != null;
Project project = context.getProject();
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/WhileStatementPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/WhileStatementPostfixTemplate.java
index 7ec46518e9f7..ba301df53591 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/WhileStatementPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/WhileStatementPostfixTemplate.java
@@ -15,19 +15,21 @@
*/
package com.intellij.codeInsight.template.postfix.templates;
-import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
-public class WhileStatementPostfixTemplate extends BooleanPostfixTemplate {
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.IS_BOOLEAN;
+import static com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils.JAVA_PSI_INFO;
+
+public class WhileStatementPostfixTemplate extends TypedPostfixTemplate {
public WhileStatementPostfixTemplate() {
- super("while", "while (expr)");
+ super("while", "while (expr)", JAVA_PSI_INFO, IS_BOOLEAN);
}
@Override
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
- PsiExpression expression = PostfixTemplatesUtils.getTopmostExpression(context);
+ PsiElement expression = myPsiInfo.getTopmostExpression(context);
assert expression != null;
PsiElementFactory factory = JavaPsiFacade.getElementFactory(context.getProject());
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/JavaPostfixTemplatesUtils.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/JavaPostfixTemplatesUtils.java
new file mode 100644
index 000000000000..3c035eced952
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/JavaPostfixTemplatesUtils.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.template.postfix.util;
+
+import com.intellij.codeInsight.CodeInsightServicesUtil;
+import com.intellij.codeInsight.CodeInsightUtilCore;
+import com.intellij.codeInsight.template.postfix.templates.PostfixTemplatePsiInfo;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public abstract class JavaPostfixTemplatesUtils {
+ private JavaPostfixTemplatesUtils() {
+ }
+
+ public static PostfixTemplatePsiInfo JAVA_PSI_INFO = new PostfixTemplatePsiInfo() {
+
+ @NotNull
+ @Override
+ public PsiElement createStatement(@NotNull PsiElement context,
+ @NotNull String prefix,
+ @NotNull String suffix) {
+ return JavaPostfixTemplatesUtils.createStatement(context, prefix, suffix);
+ }
+
+ @NotNull
+ @Override
+ public PsiElement createExpression(@NotNull PsiElement context,
+ @NotNull String prefix,
+ @NotNull String suffix) {
+ return JavaPostfixTemplatesUtils.createExpression(context, prefix, suffix);
+ }
+
+ @Nullable
+ @Override
+ public PsiExpression getTopmostExpression(@NotNull PsiElement element) {
+ return JavaPostfixTemplatesUtils.getTopmostExpression(element);
+ }
+
+ @NotNull
+ @Override
+ public PsiExpression getNegatedExpression(@NotNull PsiElement element) {
+ return CodeInsightServicesUtil.invertCondition((PsiExpression)element);
+ }
+ };
+
+ public static Condition IS_BOOLEAN = new Condition() {
+ @Override
+ public boolean value(PsiElement element) {
+ return element instanceof PsiExpression && isBoolean(((PsiExpression)element).getType());
+ }
+ };
+
+ public static Condition IS_THROWABLE = new Condition() {
+ @Override
+ public boolean value(PsiElement element) {
+ return element instanceof PsiExpression && isThrowable((((PsiExpression)element).getType()));
+ }
+ };
+
+ public static Condition IS_NON_VOID = new Condition() {
+ @Override
+ public boolean value(PsiElement element) {
+ return element instanceof PsiExpression && isNonVoid((((PsiExpression)element).getType()));
+ }
+ };
+
+ public static Condition IS_NOT_PRIMITIVE = new Condition() {
+ @Override
+ public boolean value(PsiElement element) {
+ return element instanceof PsiExpression && isNotPrimitiveTypeExpression(((PsiExpression)element));
+ }
+ };
+
+ public static PsiElement createStatement(@NotNull PsiElement context,
+ @NotNull String prefix,
+ @NotNull String suffix) {
+ PsiExpression expr = getTopmostExpression(context);
+ PsiElement parent = expr != null ? expr.getParent() : null;
+ assert parent instanceof PsiStatement;
+ PsiElementFactory factory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
+ return factory.createStatementFromText(prefix + expr.getText() + suffix, expr);
+ }
+
+ public static PsiElement createExpression(@NotNull PsiElement context,
+ @NotNull String prefix,
+ @NotNull String suffix) {
+ PsiExpression expr = getTopmostExpression(context);
+ PsiElement parent = expr != null ? expr.getParent() : null;
+ assert parent instanceof PsiStatement;
+ PsiElementFactory factory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
+ return factory.createExpressionFromText(prefix + expr.getText() + suffix, expr);
+ }
+
+ @Contract("null -> false")
+ public static boolean isNotPrimitiveTypeExpression(@Nullable PsiExpression expression) {
+ return expression != null && !(expression.getType() instanceof PsiPrimitiveType);
+ }
+
+ @Contract("null -> false")
+ public static boolean isIterable(@Nullable PsiType type) {
+ return type != null && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_ITERABLE);
+ }
+
+ @Contract("null -> false")
+ public static boolean isThrowable(@Nullable PsiType type) {
+ return type != null && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_THROWABLE);
+ }
+
+ @Contract("null -> false")
+ public static boolean isArray(@Nullable PsiType type) {
+ return type != null && type instanceof PsiArrayType;
+ }
+
+ @Contract("null -> false")
+ public static boolean isBoolean(@Nullable PsiType type) {
+ return type != null && (PsiType.BOOLEAN.equals(type) || PsiType.BOOLEAN.equals(PsiPrimitiveType.getUnboxedType(type)));
+ }
+
+ @Contract("null -> false")
+ public static boolean isNonVoid(@Nullable PsiType type) {
+ return type != null && !PsiType.VOID.equals(type);
+ }
+
+ @Contract("null -> false")
+ public static boolean isNumber(@Nullable PsiType type) {
+ if (type == null) {
+ return false;
+ }
+ if (PsiType.INT.equals(type) || PsiType.BYTE.equals(type) || PsiType.LONG.equals(type)) {
+ return true;
+ }
+
+ PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);
+ return PsiType.INT.equals(unboxedType) || PsiType.BYTE.equals(unboxedType) || PsiType.LONG.equals(unboxedType);
+ }
+
+ @Nullable
+ public static PsiExpression getTopmostExpression(PsiElement context) {
+ PsiExpressionStatement statement = PsiTreeUtil.getNonStrictParentOfType(context, PsiExpressionStatement.class);
+ return statement != null ? PsiTreeUtil.getChildOfType(statement, PsiExpression.class) : null;
+ }
+
+ public static void formatPsiCodeBlock(PsiElement newStatement, Editor editor) {
+ CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(newStatement.getProject());
+ PsiElement statement = newStatement.replace(codeStyleManager.reformat(newStatement));
+
+ PsiCodeBlock type = PsiTreeUtil.getChildOfType(statement, PsiCodeBlock.class);
+ assert type != null;
+ PsiCodeBlock block = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(type);
+ TextRange range = block.getStatements()[0].getTextRange();
+ editor.getDocument().deleteString(range.getStartOffset(), range.getEndOffset());
+
+ editor.getCaretModel().moveToOffset(range.getStartOffset());
+ }
+}
+
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/PostfixTemplatesUtils.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/PostfixTemplatesUtils.java
deleted file mode 100644
index 62c10fee29a3..000000000000
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/PostfixTemplatesUtils.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2000-2014 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.template.postfix.util;
-
-import com.intellij.codeInsight.generation.surroundWith.JavaExpressionSurrounder;
-import com.intellij.codeInsight.generation.surroundWith.JavaWithIfExpressionSurrounder;
-import com.intellij.codeInsight.template.postfix.templates.JavaPostfixTemplateProvider;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.*;
-import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.refactoring.util.CommonRefactoringUtil;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public abstract class PostfixTemplatesUtils {
- private PostfixTemplatesUtils() {
- }
-
- public static void showErrorHint(Project project, Editor editor) {
- CommonRefactoringUtil.showErrorHint(project, editor, "Can't expand postfix template", "Can't expand postfix template", "");
- }
-
- public static void createSimpleStatement(@NotNull PsiElement context, @NotNull Editor editor, @NotNull String text) {
- createStatement(context, editor, text + " ", "");
- }
-
- public static void createStatement(@NotNull PsiElement context, @NotNull Editor editor, @NotNull String prefix, @NotNull String suffix) {
- createStatement(context, editor, prefix, suffix, 0);
- }
-
- public static void createStatement(@NotNull PsiElement context, @NotNull Editor editor, @NotNull String prefix, @NotNull String suffix, int offset) {
- PsiExpression expr = getTopmostExpression(context);
- PsiElement parent = expr != null ? expr.getParent() : null;
- assert parent instanceof PsiStatement;
- PsiElementFactory factory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
- PsiStatement statement = factory.createStatementFromText(prefix + expr.getText() + suffix + ";", parent);
- PsiElement replace = parent.replace(statement);
- editor.getCaretModel().moveToOffset(replace.getTextRange().getEndOffset() + offset);
- JavaPostfixTemplateProvider.doNotDeleteSemicolon(replace.getContainingFile());
- }
-
- @Contract("null -> false")
- public static boolean isNotPrimitiveTypeExpression(@Nullable PsiExpression expression) {
- return expression != null && !(expression.getType() instanceof PsiPrimitiveType);
- }
-
- @Contract("null -> false")
- public static boolean isIterable(@Nullable PsiType type) {
- return type != null && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_ITERABLE);
- }
-
- @Contract("null -> false")
- public static boolean isThrowable(@Nullable PsiType type) {
- return type != null && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_THROWABLE);
- }
-
- @Contract("null -> false")
- public static boolean isArray(@Nullable PsiType type) {
- return type != null && type instanceof PsiArrayType;
- }
-
- @Contract("null -> false")
- public static boolean isBoolean(@Nullable PsiType type) {
- return type != null && (PsiType.BOOLEAN.equals(type) || PsiType.BOOLEAN.equals(PsiPrimitiveType.getUnboxedType(type)));
- }
-
- @Contract("null -> false")
- public static boolean isNonVoid(@Nullable PsiType type) {
- return type != null && !PsiType.VOID.equals(type);
- }
-
- @Contract("null -> false")
- public static boolean isNumber(@Nullable PsiType type) {
- if (type == null) {
- return false;
- }
- if (PsiType.INT.equals(type) || PsiType.BYTE.equals(type) || PsiType.LONG.equals(type)) {
- return true;
- }
-
- PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);
- return PsiType.INT.equals(unboxedType) || PsiType.BYTE.equals(unboxedType) || PsiType.LONG.equals(unboxedType);
- }
-
- @Nullable
- public static TextRange ifStatement(@NotNull Project project, @NotNull Editor editor, @NotNull PsiExpression expr) {
- JavaExpressionSurrounder surrounder = new JavaWithIfExpressionSurrounder();
- PsiElement[] elements = {expr};
- if (surrounder.isApplicable(elements)) {
- return surrounder.surroundElements(project, editor, elements);
- }
- else {
- showErrorHint(project, editor);
- }
- return null;
- }
-
- @Nullable
- public static TextRange apply(@NotNull JavaExpressionSurrounder surrounder, @NotNull Project project, @NotNull Editor editor, @NotNull PsiExpression expr) {
- PsiElement[] elements = {expr};
- if (surrounder.isApplicable(elements)) {
- return surrounder.surroundElements(project, editor, elements);
- }
- else {
- showErrorHint(project, editor);
- }
- return null;
- }
-
- @Nullable
- public static PsiExpression getTopmostExpression(PsiElement context) {
- PsiExpressionStatement statement = PsiTreeUtil.getNonStrictParentOfType(context, PsiExpressionStatement.class);
- return statement != null ? PsiTreeUtil.getChildOfType(statement, PsiExpression.class) : null;
- }
-}
-
diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocHelper.java b/java/java-impl/src/com/intellij/javadoc/JavadocHelper.java
index 38a51e1f10f0..88cda8ed89ef 100644
--- a/java/java-impl/src/com/intellij/javadoc/JavadocHelper.java
+++ b/java/java-impl/src/com/intellij/javadoc/JavadocHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,10 @@ package com.intellij.javadoc;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.editor.*;
+import com.intellij.openapi.editor.CaretModel;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
@@ -183,7 +186,7 @@ public class JavadocHelper {
result.add(info);
}
- return new Pair>(anchorInfo, result);
+ return Pair.create(anchorInfo, result);
}
@Nullable
diff --git a/java/java-impl/src/com/intellij/packageDependencies/ui/TreeModelBuilder.java b/java/java-impl/src/com/intellij/packageDependencies/ui/TreeModelBuilder.java
index 4b1de571c01d..7b5ebd05393f 100644
--- a/java/java-impl/src/com/intellij/packageDependencies/ui/TreeModelBuilder.java
+++ b/java/java-impl/src/com/intellij/packageDependencies/ui/TreeModelBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -339,7 +339,7 @@ public class TreeModelBuilder {
return getModuleDirNode(aPackage, null, ScopeType.LIB);
}
- Pair descriptor = new Pair(myShowIndividualLibs ? libraryOrJdk : null, aPackage);
+ Pair descriptor = Pair.create(myShowIndividualLibs ? libraryOrJdk : null, aPackage);
PackageNode node = getMap(myLibraryPackageNodes, ScopeType.LIB).get(descriptor);
if (node != null) return node;
@@ -361,7 +361,7 @@ public class TreeModelBuilder {
return getModuleNode(module, scopeType);
}
- Pair descriptor = new Pair(myShowModules ? module : null, aPackage);
+ Pair descriptor = Pair.create(myShowModules ? module : null, aPackage);
PackageNode node = getMap(myModulePackageNodes, scopeType).get(descriptor);
if (node != null) return node;
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
index 391a8fd86d8c..b76aeaa4b3fd 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
@@ -1649,7 +1649,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
IElementType type1 = token1.getElementType();
IElementType type2 = token2.getElementType();
- Pair pair = new Pair(type1, type2);
+ Pair pair = Pair.create(type1, type2);
Boolean res = myCanStickJavaTokensMatrix.get(pair);
if (res == null) {
if (!checkToken(token1) || !checkToken(token2)) return true;
diff --git a/java/java-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java
deleted file mode 100644
index ca9d77d0f6b0..000000000000
--- a/java/java-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2000-2011 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.psi.impl.file.impl;
-
-import com.intellij.ide.startup.StartupManagerEx;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.openapi.startup.StartupManager;
-import com.intellij.psi.impl.PsiManagerEx;
-import com.intellij.util.messages.MessageBus;
-
-/**
- * @author max
- */
-public class JavaFileManagerImpl extends JavaFileManagerBase {
-
- public JavaFileManagerImpl(final PsiManagerEx manager, final ProjectRootManager projectRootManager, MessageBus bus,
- final StartupManager startupManager) {
- super(manager, projectRootManager, bus);
-
- if (!((StartupManagerEx)startupManager).startupActivityPassed() &&
- !ApplicationManager.getApplication().isUnitTestMode() &&
- !manager.getProject().isDefault()) {
- Logger.getInstance("#com.intellij.psi.impl.file.impl.JavaFileManagerImpl")
- .error("Access to psi files should be performed only after startup activity");
- }
- }
-}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
index 05e359137e72..b424af918851 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -302,7 +302,7 @@ public class JDParser {
result.add(new Pair(sb.toString(), false));
sb.setLength(0);
}
- result.add(new Pair(s1, marks[i]));
+ result.add(Pair.create(s1, marks[i]));
}
else {
if (s1.isEmpty()) {
@@ -310,10 +310,10 @@ public class JDParser {
result.add(new Pair(sb.toString(), false));
sb.setLength(0);
}
- result.add(new Pair("", marks[i]));
+ result.add(Pair.create("", marks[i]));
}
else if (mySettings.JD_PRESERVE_LINE_FEEDS) {
- result.add(new Pair(s1, marks[i]));
+ result.add(Pair.create(s1, marks[i]));
}
else {
if (sb.length() != 0) sb.append(' ');
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/CompletionParameterTypeInferencePolicy.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/CompletionParameterTypeInferencePolicy.java
index 7be5fdd38805..f06f2082d3be 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/CompletionParameterTypeInferencePolicy.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/CompletionParameterTypeInferencePolicy.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ public class CompletionParameterTypeInferencePolicy extends ProcessCandidatePara
return new Pair(PsiWildcardType.createExtends(psiManager, superType), ConstraintType.EQUALS);
}
else {
- return new Pair(superType, ConstraintType.SUBTYPE);
+ return Pair.create(superType, ConstraintType.SUBTYPE);
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/extractInterface/ExtractInterfaceHandler.java b/java/java-impl/src/com/intellij/refactoring/extractInterface/ExtractInterfaceHandler.java
index e14173504618..1de742dbd55f 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractInterface/ExtractInterfaceHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractInterface/ExtractInterfaceHandler.java
@@ -142,8 +142,8 @@ public class ExtractInterfaceHandler implements RefactoringActionHandler, Elemen
DocCommentPolicy javaDocPolicy) throws IncorrectOperationException {
aClass.getProject().getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC)
.refactoringStarted(ExtractSuperClassUtil.REFACTORING_EXTRACT_SUPER_ID, ExtractSuperClassUtil.createBeforeData(aClass, selectedMembers));
+ final PsiClass anInterface = JavaDirectoryService.getInstance().createInterface(targetDir, interfaceName);
try {
- PsiClass anInterface = JavaDirectoryService.getInstance().createInterface(targetDir, interfaceName);
PsiJavaCodeReferenceElement ref = ExtractSuperClassUtil.createExtendingReference(anInterface, aClass, selectedMembers);
final PsiReferenceList referenceList = aClass.isInterface() ? aClass.getExtendsList() : aClass.getImplementsList();
assert referenceList != null;
@@ -154,7 +154,7 @@ public class ExtractInterfaceHandler implements RefactoringActionHandler, Elemen
}
finally {
aClass.getProject().getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC)
- .refactoringDone(ExtractSuperClassUtil.REFACTORING_EXTRACT_SUPER_ID, ExtractSuperClassUtil.createAfterData(aClass));
+ .refactoringDone(ExtractSuperClassUtil.REFACTORING_EXTRACT_SUPER_ID, ExtractSuperClassUtil.createAfterData(anInterface));
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperClassUtil.java b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperClassUtil.java
index 11815b222c82..8812398b4f75 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperClassUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperClassUtil.java
@@ -70,8 +70,8 @@ public class ExtractSuperClassUtil {
project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC)
.refactoringStarted(REFACTORING_EXTRACT_SUPER_ID, createBeforeData(subclass, selectedMemberInfos));
+ final PsiClass superclass = JavaDirectoryService.getInstance().createClass(targetDirectory, superclassName);
try {
- PsiClass superclass = JavaDirectoryService.getInstance().createClass(targetDirectory, superclassName);
final PsiModifierList superClassModifierList = superclass.getModifierList();
assert superClassModifierList != null;
superClassModifierList.setModifierProperty(PsiModifier.FINAL, false);
@@ -115,7 +115,7 @@ public class ExtractSuperClassUtil {
return superclass;
}
finally {
- project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(REFACTORING_EXTRACT_SUPER_ID, createAfterData(subclass));
+ project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(REFACTORING_EXTRACT_SUPER_ID, createAfterData(superclass));
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousConstructorProcessor.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousConstructorProcessor.java
index 97ce0591f8ed..3be6e594b5e0 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousConstructorProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousConstructorProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -365,7 +365,7 @@ class InlineToAnonymousConstructorProcessor {
super.visitReferenceExpression(expression);
final PsiElement psiElement = expression.resolve();
if (psiElement instanceof PsiParameter) {
- parameterReferences.add(new Pair(expression, (PsiParameter) psiElement));
+ parameterReferences.add(Pair.create(expression, (PsiParameter)psiElement));
}
else if ((psiElement instanceof PsiField || psiElement instanceof PsiMethod) &&
((PsiMember) psiElement).getContainingClass() == myClass.getSuperClass()) {
diff --git a/java/java-impl/src/com/intellij/refactoring/move/MoveInstanceMembersUtil.java b/java/java-impl/src/com/intellij/refactoring/move/MoveInstanceMembersUtil.java
index f74c8c79f2d1..571710723547 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/MoveInstanceMembersUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/MoveInstanceMembersUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -102,7 +102,7 @@ public class MoveInstanceMembersUtil {
final PsiElement resolved = ((PsiReferenceExpression)expression).resolve();
if (resolved instanceof PsiMember && !((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC)) {
PsiClass referencedClass = getReferencedClass((PsiMember)resolved, qualifier, expression);
- return new Pair((PsiMember)resolved, referencedClass);
+ return Pair.create((PsiMember)resolved, referencedClass);
}
}
} else if (expression instanceof PsiNewExpression) {
diff --git a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaClassProcessor.java b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaClassProcessor.java
index 3a4526101285..e8590261677a 100644
--- a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaClassProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaClassProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -141,7 +141,7 @@ public class RenameJavaClassProcessor extends RenamePsiElementProcessor {
final String dollaredStringToSearch = ClassUtil.getJVMClassName(aClass);
final String dollaredStringToReplace = dollaredStringToSearch == null ? null : RefactoringUtil.getNewInnerClassName(aClass, dollaredStringToSearch, newName);
if (dollaredStringToReplace != null) {
- return new Pair(dollaredStringToSearch, dollaredStringToReplace);
+ return Pair.create(dollaredStringToSearch, dollaredStringToReplace);
}
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/resolver/BindingFactory.java b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/resolver/BindingFactory.java
index 14f334e829f2..49525a67de44 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/resolver/BindingFactory.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/resolver/BindingFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1022,7 +1022,7 @@ public class BindingFactory {
return;
}
- list.addFirst(new Pair(risen.apply(x), risen));
+ list.addFirst(Pair.create(risen.apply(x), risen));
}
else {
final PsiClass[] descendants = getGreatestLowerClasses(xClass, yClass);
@@ -1097,11 +1097,11 @@ public class BindingFactory {
if (risen == null) {
final PsiElementFactory factory = JavaPsiFacade.getInstance(xClass.getProject()).getElementFactory();
- list.addFirst(new Pair(Util.banalize(factory.createType(xClass, factory.createRawSubstitutor(xClass))),
- create()));
+ list.addFirst(Pair.create(Util.banalize(factory.createType(xClass, factory.createRawSubstitutor(xClass))),
+ create()));
}
else {
- list.addFirst(new Pair(risen.apply(x), risen));
+ list.addFirst(Pair.create(risen.apply(x), risen));
}
}
else {
diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java
index 105c383f478c..1435dc1f2271 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -379,7 +379,7 @@ public class TypeEvaluator {
final LinkedList types = myTypeMap.get(usageInfo);
final PsiElement element = usageInfo.getElement();
if (element instanceof PsiVariable || element instanceof PsiMethod) {
- list.addLast(new Pair(usageInfo, types.getFirst()));
+ list.addLast(Pair.create(usageInfo, types.getFirst()));
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java
index 0542ff298dc6..274fbd52f621 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -236,7 +236,7 @@ public class TypeMigrationLabeler {
isCovariantPosition, this);
if (conversion == null) {
- markFailedConversion(new Pair(fromType, toType), expr);
+ markFailedConversion(Pair.create(fromType, toType), expr);
}
else {
setConversionMapping(expr, conversion);
@@ -250,7 +250,7 @@ public class TypeMigrationLabeler {
if (originalType.equals(PsiType.NULL)) {
if (migrationType instanceof PsiPrimitiveType) {
- markFailedConversion(new Pair(originalType, migrationType), expr);
+ markFailedConversion(Pair.create(originalType, migrationType), expr);
}
return;
}
@@ -259,7 +259,7 @@ public class TypeMigrationLabeler {
} else if (expr instanceof PsiClassObjectAccessExpression) {
if (!TypeConversionUtil.isAssignable(migrationType, expr.getType())) {
- markFailedConversion(new Pair(expr.getType(), migrationType), expr);
+ markFailedConversion(Pair.create(expr.getType(), migrationType), expr);
return;
}
} else if (expr instanceof PsiArrayInitializerExpression && migrationType instanceof PsiArrayType) {
@@ -306,7 +306,7 @@ public class TypeMigrationLabeler {
}
if (isGenericsArrayType(elemenType)){
- markFailedConversion(new Pair(originalType, migrationType), expr);
+ markFailedConversion(Pair.create(originalType, migrationType), expr);
return;
}
@@ -502,7 +502,7 @@ public class TypeMigrationLabeler {
alreadyProcessed = true;
}
- if (!alreadyProcessed) myMigrationRoots.addFirst(new Pair(usageInfo, type));
+ if (!alreadyProcessed) myMigrationRoots.addFirst(Pair.create(usageInfo, type));
return alreadyProcessed;
}
@@ -544,7 +544,7 @@ public class TypeMigrationLabeler {
void markFailedConversion(final Pair typePair, final PsiExpression expression) {
LOG.assertTrue(typePair.getSecond() != null);
- myFailedConversions.add(new Pair(PsiAnchor.create(expression), typePair.getSecond()));
+ myFailedConversions.add(Pair.create(PsiAnchor.create(expression), typePair.getSecond()));
}
void setConversionMapping(final PsiExpression expression, final Object obj) {
@@ -657,7 +657,7 @@ public class TypeMigrationLabeler {
if (argumentList != null) {
final PsiExpression[] expressions = argumentList.getExpressions();
if (checkNumberOfArguments && parametersCount != expressions.length) {
- markFailedConversion(new Pair(param.getType(), migrationType), (PsiCallExpression)parent);
+ markFailedConversion(Pair.create(param.getType(), migrationType), (PsiCallExpression)parent);
}
if (index > -1 && index < expressions.length) {
for (int idx = index; idx < (param.isVarArgs() ? expressions.length : index + 1); idx++) {
diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationStatementProcessor.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationStatementProcessor.java
index d151bf324b71..f3574536c2eb 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationStatementProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationStatementProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -146,7 +146,7 @@ class TypeMigrationStatementProcessor extends JavaRecursiveElementVisitor {
final PsiType migrationType = myTypeEvaluator.evaluateType(consideredExpression);
final PsiType fixedType = typeElement.getType();
if (migrationType != null && !TypeConversionUtil.isAssignable(migrationType, fixedType)) {
- myLabeler.markFailedConversion(new Pair(fixedType, migrationType), consideredExpression);
+ myLabeler.markFailedConversion(Pair.create(fixedType, migrationType), consideredExpression);
}
}
}
@@ -159,7 +159,7 @@ class TypeMigrationStatementProcessor extends JavaRecursiveElementVisitor {
final PsiType fixedType = typeElement.getType();
final PsiType migrationType = myTypeEvaluator.evaluateType(expression.getOperand());
if (migrationType != null && !TypeConversionUtil.areTypesConvertible(migrationType, fixedType)) {
- myLabeler.markFailedConversion(new Pair(fixedType, migrationType), expression);
+ myLabeler.markFailedConversion(Pair.create(fixedType, migrationType), expression);
}
}
}
@@ -189,7 +189,7 @@ class TypeMigrationStatementProcessor extends JavaRecursiveElementVisitor {
if (returnType != null && valueType != null) {
if (!myLabeler.addMigrationRoot(method, valueType, myStatement, TypeConversionUtil.isAssignable(returnType, valueType), true)
&& TypeMigrationLabeler.typeContainsTypeParameters(returnType)) {
- myLabeler.markFailedConversion(new Pair(returnType, valueType), value);
+ myLabeler.markFailedConversion(Pair.create(returnType, valueType), value);
}
}
}
@@ -393,7 +393,7 @@ class TypeMigrationStatementProcessor extends JavaRecursiveElementVisitor {
final PsiType type = typeView.getType();
if (migrationType == null || !TypeConversionUtil.isAssignable(migrationType, type)) {
if (migrationType != null && !TypeConversionUtil.isAssignable(type, migrationType)) {
- myLabeler.markFailedConversion(new Pair(parentExpression.getType(), type), parentExpression);
+ myLabeler.markFailedConversion(Pair.create(parentExpression.getType(), type), parentExpression);
return;
}
migrationType = type;
@@ -410,7 +410,7 @@ class TypeMigrationStatementProcessor extends JavaRecursiveElementVisitor {
private void checkIndexExpression(final PsiExpression indexExpression) {
final PsiType indexType = myTypeEvaluator.evaluateType(indexExpression);
if (indexType != null && !TypeConversionUtil.isAssignable(PsiType.INT, indexType)) {
- myLabeler.markFailedConversion(new Pair(indexExpression.getType(), indexType), indexExpression);
+ myLabeler.markFailedConversion(Pair.create(indexExpression.getType(), indexType), indexExpression);
}
}
@@ -535,7 +535,7 @@ class TypeMigrationStatementProcessor extends JavaRecursiveElementVisitor {
}
public Pair getTypePair() {
- return new Pair(myOriginType, myType);
+ return Pair.create(myOriginType, myType);
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
index 5fb9e504c1bf..888c05d932a5 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1069,7 +1069,7 @@ public class RefactoringUtil {
if (!found) {
for (PsiDocTag paramTag : paramTags) {
final String paramName = getNameOfReferencedParameter(paramTag);
- if (eqCondition.value(new Pair(parameter, paramName))) {
+ if (eqCondition.value(Pair.create(parameter, paramName))) {
tagForParam.put(parameter, paramTag);
found = true;
break;
diff --git a/java/java-impl/src/com/intellij/testIntegration/JavaTestFinder.java b/java/java-impl/src/com/intellij/testIntegration/JavaTestFinder.java
index f7051258941c..5bf07904d7fe 100644
--- a/java/java-impl/src/com/intellij/testIntegration/JavaTestFinder.java
+++ b/java/java-impl/src/com/intellij/testIntegration/JavaTestFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ public class JavaTestFinder implements TestFinder {
for (Pair eachNameWithWeight : TestFinderHelper.collectPossibleClassNamesWithWeights(klass.getName())) {
for (PsiClass eachClass : cache.getClassesByName(eachNameWithWeight.first, scope)) {
if (isTestSubjectClass(eachClass)) {
- classesWithWeights.add(new Pair(eachClass, eachNameWithWeight.second));
+ classesWithWeights.add(Pair.create(eachClass, eachNameWithWeight.second));
}
}
}
@@ -104,7 +104,7 @@ public class JavaTestFinder implements TestFinder {
for (PsiClass eachClass : cache.getClassesByName(eachName, scope)) {
if (frameworks.isTestClass(eachClass) || frameworks.isPotentialTestClass(eachClass)) {
classesWithProximities.add(
- new Pair(eachClass, TestFinderHelper.calcTestNameProximity(klassName, eachName)));
+ Pair.create(eachClass, TestFinderHelper.calcTestNameProximity(klassName, eachName)));
}
}
}
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerBase.java b/java/java-indexing-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java
similarity index 89%
rename from java/java-indexing-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerBase.java
rename to java/java-indexing-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java
index b41b36311a2a..d8c5d1c88b10 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerBase.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java
@@ -19,6 +19,7 @@ import com.intellij.ProjectTopics;
import com.intellij.ide.highlighter.JavaClassFileType;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.vfs.VirtualFile;
@@ -32,8 +33,6 @@ import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.Query;
import com.intellij.util.containers.ConcurrentHashMap;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.messages.MessageBus;
-import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
@@ -43,24 +42,18 @@ import java.util.*;
/**
* Author: dmitrylomov
*/
-public abstract class JavaFileManagerBase implements JavaFileManager, Disposable {
+public class JavaFileManagerImpl implements JavaFileManager, Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.file.impl.JavaFileManagerImpl");
private final ConcurrentHashMap myCachedObjectClassMap = new ConcurrentHashMap();
private final PsiManagerEx myManager;
- private final ProjectRootManager myProjectRootManager;
private volatile Set myNontrivialPackagePrefixes = null;
private boolean myDisposed = false;
private final PackageIndex myPackageIndex;
- protected final MessageBusConnection myConnection;
- public JavaFileManagerBase(
- final PsiManagerEx manager, final ProjectRootManager projectRootManager,
- final MessageBus bus) {
- myManager = manager;
- myProjectRootManager = projectRootManager;
+ public JavaFileManagerImpl(Project project) {
+ myManager = (PsiManagerEx)PsiManager.getInstance(project);
myPackageIndex = PackageIndex.getInstance(myManager.getProject());
- myConnection = bus.connect();
- myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
+ project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
@Override
public void rootsChanged(final ModuleRootEvent event) {
myNontrivialPackagePrefixes = null;
@@ -201,9 +194,10 @@ public abstract class JavaFileManagerBase implements JavaFileManager, Disposable
@Override
public Collection getNonTrivialPackagePrefixes() {
- if (myNontrivialPackagePrefixes == null) {
- Set names = new HashSet();
- final ProjectRootManager rootManager = myProjectRootManager;
+ Set names = myNontrivialPackagePrefixes;
+ if (names == null) {
+ names = new HashSet();
+ final ProjectRootManager rootManager = ProjectRootManager.getInstance(myManager.getProject());
final List sourceRoots = rootManager.getModuleSourceRoots(JavaModuleSourceRootTypes.SOURCES);
final ProjectFileIndex fileIndex = rootManager.getFileIndex();
for (final VirtualFile sourceRoot : sourceRoots) {
@@ -214,7 +208,7 @@ public abstract class JavaFileManagerBase implements JavaFileManager, Disposable
}
myNontrivialPackagePrefixes = names;
}
- return myNontrivialPackagePrefixes;
+ return names;
}
}
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaAllOverridingMethodsSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaAllOverridingMethodsSearcher.java
index d855ab6f14db..35ec8b2800e7 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaAllOverridingMethodsSearcher.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaAllOverridingMethodsSearcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,13 +66,13 @@ public class JavaAllOverridingMethodsSearcher implements QueryExecutor(method, inInheritor))) return false;
+ if (!consumer.process(Pair.create(method, inInheritor))) return false;
}
}
}
continue;
}
- if (!consumer.process(new Pair(method, inInheritor))) return false;
+ if (!consumer.process(Pair.create(method, inInheritor))) return false;
}
return true;
diff --git a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
index 577d38a30a15..351cb8f75c82 100644
--- a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -154,7 +154,7 @@ public class GenericsUtil {
PsiManager manager,
PsiClass nestedLayer,
PsiTypeParameter parameter) {
- Pair types = new Pair(type1, type2);
+ Pair types = Pair.create(type1, type2);
if (compared.contains(types)) {
if (nestedLayer != null) {
PsiSubstitutor subst = PsiSubstitutor.EMPTY;
diff --git a/java/java-psi-api/src/com/intellij/psi/impl/source/resolve/DefaultParameterTypeInferencePolicy.java b/java/java-psi-api/src/com/intellij/psi/impl/source/resolve/DefaultParameterTypeInferencePolicy.java
index aeb83e4f4cd4..e0920f62cd00 100644
--- a/java/java-psi-api/src/com/intellij/psi/impl/source/resolve/DefaultParameterTypeInferencePolicy.java
+++ b/java/java-psi-api/src/com/intellij/psi/impl/source/resolve/DefaultParameterTypeInferencePolicy.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public class DefaultParameterTypeInferencePolicy extends ParameterTypeInferenceP
@Override
public Pair getInferredTypeWithNoConstraint(PsiManager manager, PsiType superType) {
- return new Pair(superType, ConstraintType.SUBTYPE);
+ return Pair.create(superType, ConstraintType.SUBTYPE);
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
index a2f1dc9c0daa..d2bd655bb23f 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -123,7 +123,7 @@ public class JavaDocInfoGenerator {
elements = rawElements;
}
- return new Pair>(elements, mapProvider(pair.second, dropFirst));
+ return Pair.create(elements, mapProvider(pair.second, dropFirst));
}
@Override
@@ -1481,7 +1481,7 @@ public class JavaDocInfoGenerator {
String tagName = value.getText();
if (tagName != null && areWeakEqual(tagName, paramName)) {
- parmTag = new Pair>(localTag, ourEmptyProvider);
+ parmTag = Pair.create(localTag, ourEmptyProvider);
break;
}
}
@@ -1498,7 +1498,7 @@ public class JavaDocInfoGenerator {
try {
final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
final PsiDocTag tag = elementFactory.createDocTagFromText("@exception " + paramName);
- collectedTags.addLast(new Pair>(tag, ourEmptyProvider));
+ collectedTags.addLast(Pair.create(tag, ourEmptyProvider));
}
catch (IncorrectOperationException e) {
LOG.error(e);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java
index 3f4cea44d90a..748d907aec47 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java
@@ -925,7 +925,7 @@ public class PsiClassImplUtil {
final PsiMethod[] methodsByName = psiClass.findMethodsByName(name, false);
final List> ret = new ArrayList>(methodsByName.length);
for (final PsiMethod method : methodsByName) {
- ret.add(new Pair(method, PsiSubstitutor.EMPTY));
+ ret.add(Pair.create(method, PsiSubstitutor.EMPTY));
}
return ret;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java
index f4f9e881d4ba..d70fa1f4be4b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java
@@ -184,7 +184,7 @@ public class PsiSuperMethodImplUtil {
// methods must be inherited from unrelated classes, so flatten hierarchy here
// class C implements SAM1, SAM2 { void methodimpl() {} }
//hms.getSuperSignatures().remove(aSuper);
- flattened.add(new Pair(signature, aSuper));
+ flattened.add(Pair.create(signature, aSuper));
}
}
putInMap(aClass, result, map, hms, signature);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java
index cc40582facb2..84e3b27dd60a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -157,7 +157,7 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
}
if (rawInference != null) return rawInference;
- if (lowerBound != PsiType.NULL) return new Pair(lowerBound, ConstraintType.EQUALS);
+ if (lowerBound != PsiType.NULL) return Pair.create(lowerBound, ConstraintType.EQUALS);
if (parent != null) {
final Pair constraint =
@@ -168,14 +168,14 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
}
if (upperBound != PsiType.NULL) {
- return new Pair(upperBound, ConstraintType.SUBTYPE);
+ return Pair.create(upperBound, ConstraintType.SUBTYPE);
}
return constraint;
}
}
- if (upperBound != PsiType.NULL) return new Pair(upperBound, ConstraintType.SUBTYPE);
+ if (upperBound != PsiType.NULL) return Pair.create(upperBound, ConstraintType.SUBTYPE);
return null;
}
@@ -403,7 +403,7 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
final boolean captureWildcard) {
if (arg instanceof PsiWildcardType && !captureWildcard) return FAILED_INFERENCE;
if (arg != PsiType.NULL) {
- return new Pair(arg, constraintType);
+ return Pair.create(arg, constraintType);
}
return null;
}
@@ -460,7 +460,7 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
arg instanceof PsiIntersectionType ||
(psiClass != null && (isContraVariantPosition || !CommonClassNames.JAVA_LANG_OBJECT.equals(psiClass.getQualifiedName()) || (arg instanceof PsiArrayType)))) {
PsiType bound = intersectAllExtends(typeParam, arg);
- return new Pair(bound, ConstraintType.SUPERTYPE);
+ return Pair.create(bound, ConstraintType.SUPERTYPE);
}
if (psiClass == null && arg instanceof PsiClassType) {
return Pair.create(arg, ConstraintType.EQUALS);
@@ -651,8 +651,8 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
}
}
- if (lowerBound != PsiType.NULL) return new Pair(lowerBound, ConstraintType.SUPERTYPE);
- if (upperBound != PsiType.NULL) return new Pair(upperBound, ConstraintType.SUBTYPE);
+ if (lowerBound != PsiType.NULL) return Pair.create(lowerBound, ConstraintType.SUPERTYPE);
+ if (upperBound != PsiType.NULL) return Pair.create(upperBound, ConstraintType.SUBTYPE);
return wildcardCaptured;
}
@@ -787,6 +787,6 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
}
}
- return new Pair(guess, constraint.getSecond());
+ return Pair.create(guess, constraint.getSecond());
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/StaticOverloading.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/StaticOverloading.java
new file mode 100644
index 000000000000..9d0f9dd30271
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/StaticOverloading.java
@@ -0,0 +1,8 @@
+interface StaticBase {
+ static void foo(T t) {}
+}
+
+class Foo implements StaticBase {
+ static void foo(T t){}
+}
+
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java
index dfc6a7317641..95b3bfb7395d 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java
@@ -39,6 +39,7 @@ public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTe
public void testFinalStaticDefaultMethods() { doTest(false, false); }
public void testIDEA122720() { doTest(false, false); }
public void testIDEA123839() { doTest(false, false); }
+ public void testStaticOverloading() { doTest(false, false); }
public void testDefaultSupersInStaticContext() {
doTest(false, false);
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/CodeFragmentsTest.java b/java/java-tests/testSrc/com/intellij/psi/CodeFragmentsTest.java
index 6c68160bd5f8..8f6956808dea 100644
--- a/java/java-tests/testSrc/com/intellij/psi/CodeFragmentsTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/CodeFragmentsTest.java
@@ -1,6 +1,8 @@
package com.intellij.psi;
+import com.intellij.openapi.editor.Document;
import com.intellij.testFramework.PlatformTestCase;
+import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.PsiTestCase;
import com.intellij.psi.search.GlobalSearchScope;
@@ -13,4 +15,19 @@ public class CodeFragmentsTest extends PsiTestCase{
ref.bindToElement(arrayListClass);
assertEquals("ArrayList.foo()", fragment.getText());
}
+
+ public void testDontLoseDocument() {
+ PsiExpressionCodeFragment fragment = JavaCodeFragmentFactory.getInstance(myProject).createExpressionCodeFragment("a", null, null, true);
+ Document document = PsiDocumentManager.getInstance(myProject).getDocument(fragment);
+ document.insertString(1, "b");
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
+ assertEquals("ab", fragment.getText());
+ assertEquals("ab", fragment.getExpression().getText());
+
+ //noinspection UnusedAssignment
+ document = null;
+
+ PlatformTestUtil.tryGcSoftlyReachableObjects();
+ assertEquals("ab", PsiDocumentManager.getInstance(myProject).getDocument(fragment).getText());
+ }
}
diff --git a/java/openapi/src/com/intellij/util/xml/converters/values/GenericDomValueConvertersRegistry.java b/java/openapi/src/com/intellij/util/xml/converters/values/GenericDomValueConvertersRegistry.java
index 34fb74d5b951..064a306fe6ba 100644
--- a/java/openapi/src/com/intellij/util/xml/converters/values/GenericDomValueConvertersRegistry.java
+++ b/java/openapi/src/com/intellij/util/xml/converters/values/GenericDomValueConvertersRegistry.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ public class GenericDomValueConvertersRegistry {
@Nullable
public Converter> getConverter(@NotNull GenericDomValue domValue, @Nullable PsiType type) {
- final Pair pair = new Pair(type, domValue);
+ final Pair pair = Pair.create(type, domValue);
for (@NotNull Condition> condition : myConditionConverters.keySet()) {
if (condition.value(pair)) {
return myConditionConverters.get(condition);
diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/ClassfileAnalyzer.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/ClassfileAnalyzer.java
index 98dffabc70e6..03dddda7183f 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/ClassfileAnalyzer.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/ClassfileAnalyzer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,9 @@ import org.jetbrains.asm4.signature.SignatureReader;
import org.jetbrains.asm4.signature.SignatureVisitor;
import java.lang.annotation.RetentionPolicy;
-import java.util.*;
+import java.util.EnumSet;
+import java.util.Map;
+import java.util.Set;
/**
* @author: db
@@ -334,7 +336,7 @@ class ClassfileAnalyzer {
repr.updateClassUsages(myContext, myUsages);
}
- return new Pair>(repr, myUsages);
+ return Pair.create(repr, myUsages);
}
@Override
diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Difference.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Difference.java
index e95258d74823..d96cf7c7b59e 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Difference.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Difference.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -105,7 +105,7 @@ abstract class Difference {
final Difference diff = py.difference(px);
if (!diff.no()) {
- changed.add(new Pair(x, diff));
+ changed.add(Pair.create(x, diff));
}
}
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Mappings.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Mappings.java
index 20e3b76e4e16..2907b36db5e0 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Mappings.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Mappings.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -360,7 +360,7 @@ public class Mappings {
final Collection methods = r.findMethods(predicate);
for (MethodRepr mm : methods) {
if (isVisibleIn(fromClass, m, r)) {
- container.add(new Pair(mm, r));
+ container.add(Pair.create(mm, r));
cont = false;
}
}
@@ -413,7 +413,7 @@ public class Mappings {
final Collection methods = superClass.findMethods(predicate);
for (MethodRepr mm : methods) {
if (isVisibleIn(superClass, mm, fromClass)) {
- container.add(new Pair(mm, superClass));
+ container.add(Pair.create(mm, superClass));
cont = false;
}
}
@@ -422,7 +422,7 @@ public class Mappings {
}
}
else {
- container.add(new Pair(MOCK_METHOD, MOCK_CLASS));
+ container.add(Pair.create(MOCK_METHOD, MOCK_CLASS));
}
}
}
@@ -433,7 +433,7 @@ public class Mappings {
if (superClass != null) {
final FieldRepr ff = superClass.findField(f.name);
if (ff != null && isVisibleIn(superClass, ff, fromClass)) {
- container.add(new Pair(ff, superClass));
+ container.add(Pair.create(ff, superClass));
}
else{
addOverriddenFields(f, superClass, container);
diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/ObjectObjectMultiMaplet.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/ObjectObjectMultiMaplet.java
index 35edf8421a93..4f24b5cffdd7 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/ObjectObjectMultiMaplet.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/ObjectObjectMultiMaplet.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ abstract class ObjectObjectMultiMaplet