mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Generated
-3
@@ -3,9 +3,6 @@
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/jps</output-path>
|
||||
<root id="archive" name="jps-plugins.jar">
|
||||
<element id="module-output" name="jps-appLauncher" />
|
||||
<element id="module-output" name="jps-gwt" />
|
||||
<element id="module-output" name="jps-javaee" />
|
||||
<element id="module-output" name="jps-jpa" />
|
||||
<element id="module-output" name="jps-scala" />
|
||||
</root>
|
||||
</artifact>
|
||||
|
||||
Generated
-1
@@ -6,7 +6,6 @@
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/jps/model/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/jps/plugins/appLauncher/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/jps/plugins/gwt/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/jps/plugins/javaee/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/jps/plugins/jpa/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/jps/plugins/scala/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/jps/src" />
|
||||
|
||||
Generated
+11
-11
@@ -1,12 +1,12 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Mac">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/build/conf/mac/lib/quaqua.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/eawtstub.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/eawtstub_src.zip!/eawtstub_src/src" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<component name="libraryTable">
|
||||
<library name="Mac">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/build/conf/mac/lib/quaqua.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/eawtstub.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/eawtstub_src.zip!/src" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
Generated
+1
-1
@@ -6,7 +6,7 @@
|
||||
<root url="jar://$PROJECT_DIR$/lib/dev/jmock-cglib-1.0.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/dev/easymockclassextension.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/dev/objenesis-1.0.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/dev/mockobjects-core-0.09.jar!/ " />
|
||||
<root url="jar://$PROJECT_DIR$/lib/dev/mockobjects-core-0.09.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/dev/hamcrest-core-1.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/dev/hamcrest-library-1.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/dev/jmock-2.5.1.jar!/" />
|
||||
|
||||
Generated
+10
-10
@@ -1,11 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="tcServiceMessages">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/serviceMessages.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/serviceMessages_279xxx_src.zip!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<component name="libraryTable">
|
||||
<library name="tcServiceMessages">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/serviceMessages.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/serviceMessages_279xxx_src.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
Generated
+2
-4
@@ -9,7 +9,8 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/IntelliLang/IntelliLang-xml.iml" filepath="$PROJECT_DIR$/plugins/IntelliLang/IntelliLang-xml.iml" group="plugins/IntelliLang" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/IntentionPowerPak/IntentionPowerPackPlugin.iml" filepath="$PROJECT_DIR$/plugins/IntentionPowerPak/IntentionPowerPackPlugin.iml" group="plugins" />
|
||||
<module fileurl="file://$PROJECT_DIR$/RegExpSupport/RegExpSupport.iml" filepath="$PROJECT_DIR$/RegExpSupport/RegExpSupport.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/android/android.iml" filepath="$PROJECT_DIR$/plugins/android/android.iml" group="plugins" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/android/android.iml" filepath="$PROJECT_DIR$/plugins/android/android.iml" group="plugins/Android" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/android/rt/android-rt.iml" filepath="$PROJECT_DIR$/plugins/android/rt/android-rt.iml" group="plugins/Android" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/annotations/annotations.iml" filepath="$PROJECT_DIR$/platform/annotations/annotations.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/ant/ant.iml" filepath="$PROJECT_DIR$/plugins/ant/ant.iml" group="plugins" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/antLayout/antlayout.iml" filepath="$PROJECT_DIR$/jps/antLayout/antlayout.iml" />
|
||||
@@ -59,9 +60,6 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/jps.iml" filepath="$PROJECT_DIR$/jps/jps.iml" group="jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/plugins/appLauncher/jps-appLauncher.iml" filepath="$PROJECT_DIR$/jps/plugins/appLauncher/jps-appLauncher.iml" group="jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/jps-builders/jps-builders.iml" filepath="$PROJECT_DIR$/jps/jps-builders/jps-builders.iml" group="jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/plugins/gwt/jps-gwt.iml" filepath="$PROJECT_DIR$/jps/plugins/gwt/jps-gwt.iml" group="jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/plugins/javaee/jps-javaee.iml" filepath="$PROJECT_DIR$/jps/plugins/javaee/jps-javaee.iml" group="jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/plugins/jpa/jps-jpa.iml" filepath="$PROJECT_DIR$/jps/plugins/jpa/jps-jpa.iml" group="jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/model/jps-model.iml" filepath="$PROJECT_DIR$/jps/model/jps-model.iml" group="jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/plugins/scala/jps-scala.iml" filepath="$PROJECT_DIR$/jps/plugins/scala/jps-scala.iml" group="jps" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jps/jps-tests.iml" filepath="$PROJECT_DIR$/jps/jps-tests.iml" group="jps" />
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class RegExpElementImpl extends ASTWrapperPsiElement implements
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + ": <" + getUnescapedText() + ">";
|
||||
return getClass().getSimpleName() + ": <" + getText() + ">";
|
||||
}
|
||||
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
|
||||
@@ -364,6 +364,8 @@ public def layoutCommunityPlugins(String home) {
|
||||
include(name: "**/*.jar")
|
||||
exclude(name: "**/ddmlib_1.jar")
|
||||
}
|
||||
|
||||
jar("android_rt.jar") {module("android-rt")}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ libraryLicense(name: "Axis", libraryName: "axis-1.4", version: "1.4", license: "
|
||||
libraryLicense(name: "CGLib", libraryName: "CGLIB", version: "2.2.2", license: "Apache", url: "http://cglib.sourceforge.net/", licenseUrl: "http://www.apache.org/foundation/licence-FAQ.html")
|
||||
libraryLicense(name: "classworlds", libraryName: "classworlds-1.1.jar", version: "1.1", license: "codehaus", url: "http://classworlds.codehaus.org/", licenseUrl: "http://classworlds.codehaus.org/license.html")
|
||||
libraryLicense(name: "Android SDK Tools", libraryName: "android-sdk-tools", license: "Apache 2.0", url: "http://source.android.com/")
|
||||
libraryLicense(name: "Android SDK Tools JPS", libraryName: "android-sdk-tools-jps", license: "Apache 2.0", url: "http://source.android.com/")
|
||||
libraryLicense(name: "Apache Commons BeanUtils", libraryName: "commons-beanutils.jar", version: "1.6", license: "Apache 2.0", url: "http://commons.apache.org/beanutils/")
|
||||
libraryLicense(name: "Apache Commons Codec", libraryName: "commons-codec", version: "1.3", license: "Apache 2.0", url: "http://commons.apache.org/codec/", licenseUrl: "http://commons.apache.org/license.html")
|
||||
libraryLicense(name: "Apache Commons Collections", libraryName: "commons-collections", version: "3.1", license: "Apache 2.0", url: "http://commons.apache.org/collections/", licenseUrl: "http://commons.apache.org/license.html")
|
||||
@@ -190,9 +191,9 @@ libraryLicense(name: "JavaHelp", version: "2.0_02", license: "included as licens
|
||||
libraryLicense(name: "JCIP Annotations", libraryName: "jcip", license: "Creative Commons Attribution License", url: "http://www.jcip.net", licenseUrl: "http://creativecommons.org/licenses/by/2.5")
|
||||
libraryLicense(name: "JDOM", version: "1.1 (with patches by JetBrains)", license: "modified Apache", url: "http://www.jdom.org/", licenseUrl: "http://www.jdom.org/docs/faq.html#a0030")
|
||||
libraryLicense(name: "jgit-1.1.0", version: "1.1.0.201109151100", license: "EDL/BSD", url: "http://www.eclipse.org/jgit/", licenseUrl: "http://www.eclipse.org/org/documents/edl-v10.php", attachedTo: "git4idea")
|
||||
libraryLicense(name: "JGoodies Forms", libraryName: "jgoodies-forms", version: "CVS snapshot as of 5 May 2006", license: "BSD ", url: "http://www.jgoodies.com/freeware/forms/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html")
|
||||
libraryLicense(name: "JGoodies Looks", attachedTo: "platform-impl", version: "2.4.2", license: "BSD ", url: "http://www.jgoodies.com/freeware/looks/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html")
|
||||
libraryLicense(name: "JGoodies Common", attachedTo: "platform-impl", version: "1.2.1", license: "BSD ", url: "http://www.jgoodies.com/freeware/looks/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html")
|
||||
libraryLicense(name: "JGoodies Forms", libraryName: "jgoodies-forms", version: "1.1-preview 2006-05-04 11:55:37", license: "BSD ", url: "http://www.jgoodies.com/freeware/forms/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html")
|
||||
libraryLicense(name: "JGoodies Looks", libraryName: "jgoodies-looks", version: "2.4.2", license: "BSD ", url: "http://www.jgoodies.com/freeware/looks/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html")
|
||||
libraryLicense(name: "JGoodies Common", libraryName: "jgoodies-common", version: "1.2.1", license: "BSD ", url: "http://www.jgoodies.com/freeware/looks/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html")
|
||||
libraryLicense(name: "JNA", libraryName: "jna", version: "3.2.4", license: "LGPL 2.1", url: "https://jna.dev.java.net/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php")
|
||||
libraryLicense(name: "JNA", libraryName: "jna.jar", version: "3.2.7", license: "LGPL 2.1", url: "https://jna.dev.java.net/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php")
|
||||
libraryLicense(name: "JSch", libraryName: "JSch", version: "0.1.44", license: "BSD", url: "http://www.jcraft.com/jsch/", licenseUrl: "http://www.jcraft.com/jsch/LICENSE.txt")
|
||||
@@ -238,4 +239,4 @@ libraryLicense(name: "Kryo", libraryName: "Kryo", version: "1.04", license: "New
|
||||
jetbrainsLibrary("JPS")
|
||||
jetbrainsLibrary("Maven Embedder")
|
||||
jetbrainsLibrary("tcServiceMessages")
|
||||
jetbrainsLibrary("optimizedFileManager.jar")
|
||||
jetbrainsLibrary("optimizedFileManager.jar")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<component>
|
||||
<version codename="Community Edition" major="11" minor="0" eap="true" update-channel="IDEA11EAP"/>
|
||||
<version codename="Community Edition" major="11" minor="1" eap="true" update-channel="IDEA11dot1EAP"/>
|
||||
|
||||
<build number="__BUILD_NUMBER__" date="__BUILD_DATE__"/>
|
||||
<install-over minbuild="0" maxbuild="0" version="10.5"/>
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.compiler;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.application.options.PathMacrosImpl;
|
||||
import com.intellij.compiler.server.impl.CompileServerClasspathManager;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
@@ -35,9 +36,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerAdapter;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkType;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.*;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ModuleRootListener;
|
||||
@@ -45,6 +44,7 @@ import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.ShutDownTracker;
|
||||
@@ -61,6 +61,7 @@ import com.intellij.util.Alarm;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.api.*;
|
||||
@@ -99,6 +100,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
private final ProjectManager myProjectManager;
|
||||
private static final int MAKE_TRIGGER_DELAY = 5 * 1000 /*5 seconds*/;
|
||||
private final Map<RequestFuture, Project> myAutomakeFutures = new HashMap<RequestFuture, Project>();
|
||||
private final CompileServerClasspathManager myClasspathManager = new CompileServerClasspathManager();
|
||||
|
||||
public CompileServerManager(final ProjectManager projectManager) {
|
||||
myProjectManager = projectManager;
|
||||
@@ -271,9 +273,8 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
if (!config.useCompileServer() || !config.MAKE_PROJECT_ON_SAVE) {
|
||||
continue;
|
||||
}
|
||||
final RequestFuture future = submitCompilationTask(
|
||||
project, false, true, Collections.<String>emptyList(), Collections.<String>emptyList(), new AutoMakeResponseHandler(project)
|
||||
);
|
||||
final RequestFuture future = submitCompilationTask(project, false, true, Collections.<String>emptyList(), Collections.<String>emptyList(),
|
||||
Collections.<String>emptyList(), new AutoMakeResponseHandler(project));
|
||||
if (future != null) {
|
||||
futures.add(future);
|
||||
synchronized (myAutomakeFutures) {
|
||||
@@ -311,7 +312,9 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RequestFuture submitCompilationTask(final Project project, final boolean isRebuild, final boolean isMake, final Collection<String> modules, final Collection<String> paths, final JpsServerResponseHandler handler) {
|
||||
public RequestFuture submitCompilationTask(final Project project, final boolean isRebuild, final boolean isMake,
|
||||
final Collection<String> modules, final Collection<String> artifacts,
|
||||
final Collection<String> paths, final JpsServerResponseHandler handler) {
|
||||
final String projectId = project.getLocation();
|
||||
final Ref<RequestFuture> futureRef = new Ref<RequestFuture>(null);
|
||||
final RunnableFuture future = myTaskExecutor.submit(new Runnable() {
|
||||
@@ -321,7 +324,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
if (client != null) {
|
||||
final RequestFuture requestFuture = isRebuild ?
|
||||
client.sendRebuildRequest(projectId, handler) :
|
||||
client.sendCompileRequest(isMake, projectId, modules, paths, handler);
|
||||
client.sendCompileRequest(isMake, projectId, modules, artifacts, paths, handler);
|
||||
futureRef.set(requestFuture);
|
||||
}
|
||||
else {
|
||||
@@ -461,8 +464,9 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
private static RequestFuture sendSetupRequest(final @NotNull CompileServerClient client) throws Exception {
|
||||
final Map<String, String> data = new HashMap<String, String>();
|
||||
|
||||
// need this for tests and when this macro is missing from PathMacros registry
|
||||
data.put(PathMacrosImpl.APPLICATION_HOME_MACRO_NAME, FileUtil.toSystemIndependentName(PathManager.getHomePath()));
|
||||
for (Map.Entry<String, String> entry : PathMacrosImpl.getGlobalSystemMacros().entrySet()) {
|
||||
data.put(entry.getKey(), FileUtil.toSystemIndependentName(entry.getValue()));
|
||||
}
|
||||
|
||||
final PathMacros pathVars = PathMacros.getInstance();
|
||||
for (String name : pathVars.getAllMacroNames()) {
|
||||
@@ -487,8 +491,19 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
if (homePath == null) {
|
||||
continue;
|
||||
}
|
||||
final SdkAdditionalData data = sdk.getSdkAdditionalData();
|
||||
final String additionalDataXml;
|
||||
final SdkType sdkType = sdk.getSdkType();
|
||||
if (data == null) {
|
||||
additionalDataXml = null;
|
||||
}
|
||||
else {
|
||||
final Element element = new Element("additional");
|
||||
sdkType.saveAdditionalData(data, element);
|
||||
additionalDataXml = JDOMUtil.writeElement(element, "\n");
|
||||
}
|
||||
final List<String> paths = convertToLocalPaths(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
|
||||
globals.add(new SdkLibrary(name, homePath, paths));
|
||||
globals.add(new SdkLibrary(name, sdkType.getName(), homePath, paths, additionalDataXml));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,6 +597,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
cmdLine.addParameter("-classpath");
|
||||
|
||||
final List<File> cp = ClasspathBootstrap.getCompileServerApplicationClasspath();
|
||||
cp.addAll(myClasspathManager.getCompileServerPluginsClasspath());
|
||||
|
||||
cmdLine.addParameter(classpathToString(cp));
|
||||
|
||||
|
||||
@@ -144,8 +144,6 @@ public class CompileDriver {
|
||||
}
|
||||
};
|
||||
|
||||
private OutputPathFinder myOutputFinder; // need this for updating zip archives (experimental feature)
|
||||
|
||||
private Set<File> myAllOutputDirectories;
|
||||
private static final long ONE_MINUTE_MS = 60L /*sec*/ * 1000L /*millisec*/;
|
||||
|
||||
@@ -414,19 +412,25 @@ public class CompileDriver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RequestFuture compileOnServer(final CompileContextImpl compileContext, Collection<Module> modules, final Collection<String> paths, @Nullable final CompileStatusNotification callback)
|
||||
private RequestFuture compileOnServer(final @NotNull CompileContextImpl compileContext, @NotNull Collection<Module> modules, @NotNull Collection<Artifact> artifacts,
|
||||
final @NotNull Collection<String> paths, @Nullable final CompileStatusNotification callback)
|
||||
throws Exception {
|
||||
Collection<String> moduleNames = Collections.emptyList();
|
||||
if (modules != null && modules.size() > 0) {
|
||||
if (modules.size() > 0) {
|
||||
moduleNames = new ArrayList<String>(modules.size());
|
||||
for (Module module : modules) {
|
||||
moduleNames.add(module.getName());
|
||||
}
|
||||
}
|
||||
List<String> artifactNames = new ArrayList<String>();
|
||||
for (Artifact artifact : artifacts) {
|
||||
artifactNames.add(artifact.getName());
|
||||
}
|
||||
|
||||
final CompileServerManager csManager = CompileServerManager.getInstance();
|
||||
final MessageBus messageBus = myProject.getMessageBus();
|
||||
csManager.cancelAutoMakeTasks(myProject);
|
||||
return csManager.submitCompilationTask(myProject, compileContext.isRebuild(), compileContext.isMake(), moduleNames, paths, new JpsServerResponseHandler() {
|
||||
return csManager.submitCompilationTask(myProject, compileContext.isRebuild(), compileContext.isMake(), moduleNames, artifactNames, paths, new JpsServerResponseHandler() {
|
||||
|
||||
@Override
|
||||
public void handleCompileMessage(JpsRemoteProto.Message.Response.CompileMessage compilerMessage) {
|
||||
@@ -584,7 +588,8 @@ public class CompileDriver {
|
||||
}
|
||||
final Collection<String> paths = fetchFiles(compileContext);
|
||||
final List<Module> modules = paths.isEmpty()? Arrays.asList(compileContext.getCompileScope().getAffectedModules()) : Collections.<Module>emptyList();
|
||||
final RequestFuture future = compileOnServer(compileContext, modules, paths, callback);
|
||||
final Set<Artifact> artifacts = ArtifactCompileScope.getArtifactsToBuild(myProject, compileContext.getCompileScope(), true);
|
||||
final RequestFuture future = compileOnServer(compileContext, modules, artifacts, paths, callback);
|
||||
if (future != null) {
|
||||
try {
|
||||
startCancelWatcher(indicator, future);
|
||||
@@ -658,6 +663,7 @@ public class CompileDriver {
|
||||
finish - start
|
||||
);
|
||||
CompilerCacheManager.getInstance(myProject).flushCaches();
|
||||
FileUtil.delete(CompilerPaths.getRebuildMarkerFile(myProject));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -748,8 +754,6 @@ public class CompileDriver {
|
||||
}
|
||||
|
||||
myAllOutputDirectories = getAllOutputDirectories(compileContext);
|
||||
// need this for updating zip archives experiment, uncomment if the feature is turned on
|
||||
//myOutputFinder = new OutputPathFinder(myAllOutputDirectories);
|
||||
status = doCompile(compileContext, isRebuild, forceCompile, false);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
@@ -820,6 +824,10 @@ public class CompileDriver {
|
||||
}
|
||||
|
||||
private void checkCachesVersion(final CompileContextImpl compileContext, final long currentVFSTimestamp) {
|
||||
if (CompilerPaths.getRebuildMarkerFile(compileContext.getProject()).exists()) {
|
||||
compileContext.requestRebuildNextTime("Compiler caches are out of date, project rebuild is required");
|
||||
return;
|
||||
}
|
||||
final CompileStatus compileStatus = readStatus();
|
||||
if (compileStatus == null) {
|
||||
compileContext.requestRebuildNextTime(CompilerBundle.message("error.compiler.caches.corrupted"));
|
||||
|
||||
+164
-13
@@ -19,6 +19,7 @@ import com.intellij.ProjectTopics;
|
||||
import com.intellij.compiler.CompileServerManager;
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerIOUtil;
|
||||
import com.intellij.compiler.CompilerWorkspaceConfiguration;
|
||||
import com.intellij.compiler.make.MakeUtil;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Application;
|
||||
@@ -82,12 +83,16 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
public static boolean ourDebugMode = false;
|
||||
@NonNls
|
||||
private static final String PATHS_TO_DELETE_FILENAME = "paths_to_delete.dat";
|
||||
private static final String SUSPENDED_PROJECTS_FILENAME = "suspended.dat";
|
||||
private static final String OUTPUT_ROOTS_FILENAME = "output_roots.dat";
|
||||
private static final FileAttribute ourSourceFileAttribute = new FileAttribute("_make_source_file_info_", 3);
|
||||
private static final FileAttribute ourOutputFileAttribute = new FileAttribute("_make_output_file_info_", 3);
|
||||
private static final Key<Map<String, VirtualFile>> SOURCE_FILES_CACHE = Key.create("_source_url_to_vfile_cache_");
|
||||
|
||||
private final Object myDataLock = new Object();
|
||||
|
||||
private final TIntHashSet mySuspendedProjects = new TIntHashSet(); // projectId for allprojects that should not be monitored
|
||||
|
||||
private final TIntObjectHashMap<TIntHashSet> mySourcesToRecompile = new TIntObjectHashMap<TIntHashSet>(); // ProjectId->set of source file paths
|
||||
private PersistentHashMap<Integer, TIntObjectHashMap<Pair<Integer, Integer>>> myOutputRootsStorage; // ProjectId->map[moduleId->Pair(outputDirId, testOutputDirId)]
|
||||
private final TIntObjectHashMap<Map<String, SourceUrlClassNamePair>> myOutputsToDelete = new TIntObjectHashMap<Map<String, SourceUrlClassNamePair>>(); // Map: projectId -> Map{output path -> [sourceUrl; classname]}
|
||||
@@ -126,7 +131,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
};
|
||||
private final ProjectManager myProjectManager;
|
||||
private final TIntIntHashMap myInitInProgress = new TIntIntHashMap(); // projectId fior successfully initialized projects
|
||||
private final TIntIntHashMap myInitInProgress = new TIntIntHashMap(); // projectId for successfully initialized projects
|
||||
private final Object myAsyncScanLock = new Object();
|
||||
|
||||
public TranslatingCompilerFilesMonitor(VirtualFileManager vfsManager, ProjectManager projectManager, Application application) {
|
||||
@@ -140,6 +145,46 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
return ApplicationManager.getApplication().getComponent(TranslatingCompilerFilesMonitor.class);
|
||||
}
|
||||
|
||||
public void suspendProject(Project project) {
|
||||
final int projectId = getProjectId(project);
|
||||
|
||||
synchronized (myDataLock) {
|
||||
if (!mySuspendedProjects.add(projectId)) {
|
||||
return;
|
||||
}
|
||||
FileUtil.createIfDoesntExist(CompilerPaths.getRebuildMarkerFile(project));
|
||||
// cleanup internal structures to free memory
|
||||
mySourcesToRecompile.remove(projectId);
|
||||
myOutputsToDelete.remove(projectId);
|
||||
myGeneratedDataPaths.remove(project);
|
||||
myProjectOutputRoots.remove(projectId);
|
||||
}
|
||||
|
||||
try {
|
||||
myOutputRootsStorage.remove(projectId);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void watchProject(Project project) {
|
||||
synchronized (myDataLock) {
|
||||
mySuspendedProjects.remove(getProjectId(project));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSuspended(Project project) {
|
||||
return isSuspended(getProjectId(project));
|
||||
}
|
||||
|
||||
public boolean isSuspended(int projectId) {
|
||||
synchronized (myDataLock) {
|
||||
return mySuspendedProjects.contains(projectId);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile getSourceFileByOutput(VirtualFile outputFile) {
|
||||
final OutputFileInfo outputFileInfo = loadOutputInfo(outputFile);
|
||||
@@ -420,6 +465,36 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
loadSuspendedProjects();
|
||||
loadPathsToDelete();
|
||||
ensureOutputStorageInitialized();
|
||||
}
|
||||
|
||||
private void loadSuspendedProjects() {
|
||||
final File file = new File(CompilerPaths.getCompilerSystemDirectory(), SUSPENDED_PROJECTS_FILENAME);
|
||||
try {
|
||||
final DataInputStream is = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
|
||||
try {
|
||||
final int projectsCount = is.readInt();
|
||||
synchronized (myDataLock) {
|
||||
for (int idx = 0; idx < projectsCount; idx++) {
|
||||
mySuspendedProjects.add(is.readInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ignored) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
FileUtil.delete(file);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPathsToDelete() {
|
||||
final File file = new File(CompilerPaths.getCompilerSystemDirectory(), PATHS_TO_DELETE_FILENAME);
|
||||
try {
|
||||
final DataInputStream is = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
|
||||
@@ -430,20 +505,29 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
final int projectId = is.readInt();
|
||||
final int size = is.readInt();
|
||||
if (size > 0) {
|
||||
final Map<String, SourceUrlClassNamePair> map = new HashMap<String, SourceUrlClassNamePair>();
|
||||
myOutputsToDelete.put(projectId, map);
|
||||
final Map<String, SourceUrlClassNamePair> map;
|
||||
if (mySuspendedProjects.contains(projectId)) {
|
||||
map = null;
|
||||
}
|
||||
else {
|
||||
map = new HashMap<String, SourceUrlClassNamePair>();
|
||||
myOutputsToDelete.put(projectId, map);
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
final String outputPath = FileUtil.toSystemIndependentName(CompilerIOUtil.readString(is));
|
||||
final String _outputPath = CompilerIOUtil.readString(is);
|
||||
final String srcUrl = CompilerIOUtil.readString(is);
|
||||
final String className = CompilerIOUtil.readString(is);
|
||||
if (map == null) {
|
||||
continue;
|
||||
}
|
||||
if (LOG.isDebugEnabled() || ourDebugMode) {
|
||||
final String message = "INIT path to delete: " + outputPath;
|
||||
final String message = "INIT path to delete: " + FileUtil.toSystemIndependentName(_outputPath);
|
||||
LOG.debug(message);
|
||||
if (ourDebugMode) {
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
map.put(outputPath, new SourceUrlClassNamePair(srcUrl, className));
|
||||
map.put(FileUtil.toSystemIndependentName(_outputPath), new SourceUrlClassNamePair(srcUrl, className));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -462,8 +546,6 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
FileUtil.delete(file);
|
||||
}
|
||||
|
||||
ensureOutputStorageInitialized();
|
||||
}
|
||||
|
||||
private void ensureOutputStorageInitialized() {
|
||||
@@ -528,12 +610,46 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
saveSuspendedProjects();
|
||||
savePathsToDelete();
|
||||
}
|
||||
|
||||
private void saveSuspendedProjects() {
|
||||
final File file = new File(CompilerPaths.getCompilerSystemDirectory(), SUSPENDED_PROJECTS_FILENAME);
|
||||
try {
|
||||
FileUtil.createParentDirs(file);
|
||||
final DataOutputStream os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
|
||||
try {
|
||||
synchronized (myDataLock) {
|
||||
os.writeInt(mySuspendedProjects.size());
|
||||
for (int projectId : mySuspendedProjects.toArray()) {
|
||||
os.writeInt(projectId);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void savePathsToDelete() {
|
||||
final File file = new File(CompilerPaths.getCompilerSystemDirectory(), PATHS_TO_DELETE_FILENAME);
|
||||
try {
|
||||
FileUtil.createParentDirs(file);
|
||||
final DataOutputStream os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
|
||||
try {
|
||||
synchronized (myDataLock) {
|
||||
mySuspendedProjects.forEach(new TIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(int projectId) {
|
||||
myOutputsToDelete.remove(projectId);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final int[] keys = myOutputsToDelete.keys();
|
||||
os.writeInt(keys.length);
|
||||
for (int projectId : keys) {
|
||||
@@ -839,10 +955,12 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearPaths(final int projectId){
|
||||
public boolean clearPaths(final int projectId){
|
||||
if (myProjectToOutputPathMap != null) {
|
||||
myProjectToOutputPathMap.remove(projectId);
|
||||
final Serializable removed = myProjectToOutputPathMap.remove(projectId);
|
||||
return removed != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
long getTimestamp(final int projectId) {
|
||||
@@ -899,7 +1017,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
public static List<String> getCompiledClassNames(VirtualFile srcFile, Project project) {
|
||||
SourceFileInfo info = loadSourceInfo(srcFile);
|
||||
final SourceFileInfo info = loadSourceInfo(srcFile);
|
||||
if (info == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -1083,6 +1201,9 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
|
||||
public void scanSourcesForCompilableFiles(final Project project) {
|
||||
final int projectId = getProjectId(project);
|
||||
if (isSuspended(projectId)) {
|
||||
return;
|
||||
}
|
||||
startAsyncScan(projectId);
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
|
||||
public void run() {
|
||||
@@ -1186,11 +1307,21 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
final ProjectRef projRef = new ProjectRef(project);
|
||||
final int projectId = getProjectId(project);
|
||||
|
||||
if (CompilerWorkspaceConfiguration.getInstance(project).useCompileServer()) {
|
||||
suspendProject(project);
|
||||
}
|
||||
else {
|
||||
watchProject(project);
|
||||
}
|
||||
|
||||
conn.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
private VirtualFile[] myRootsBefore;
|
||||
private Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, project);
|
||||
|
||||
public void beforeRootsChange(final ModuleRootEvent event) {
|
||||
if (isSuspended(projectId)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
myRootsBefore = ProjectRootManager.getInstance(projRef.get()).getContentSourceRoots();
|
||||
}
|
||||
@@ -1200,6 +1331,9 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
public void rootsChanged(final ModuleRootEvent event) {
|
||||
if (isSuspended(projectId)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final VirtualFile[] rootsBefore = myRootsBefore;
|
||||
myRootsBefore = null;
|
||||
@@ -1323,6 +1457,9 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
if (srcInfo != null) {
|
||||
final boolean srcWillBeDeleted = VfsUtil.isAncestor(eventFile, srcFile, false);
|
||||
for (int projectId : srcInfo.getProjectIds().toArray()) {
|
||||
if (isSuspended(projectId)) {
|
||||
continue;
|
||||
}
|
||||
if (srcInfo.isAssociated(projectId, filePath)) {
|
||||
if (srcWillBeDeleted) {
|
||||
if (LOG.isDebugEnabled() || ourDebugMode) {
|
||||
@@ -1351,6 +1488,9 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
deletionProc.setRootBeingDeleted(eventFile);
|
||||
final int sourceFileId = Math.abs(getFileId(file));
|
||||
for (int projectId : projects.toArray()) {
|
||||
if (isSuspended(projectId)) {
|
||||
continue;
|
||||
}
|
||||
// mark associated outputs for deletion
|
||||
srcInfo.processOutputPaths(projectId, deletionProc);
|
||||
if (LOG.isDebugEnabled() || ourDebugMode) {
|
||||
@@ -1390,7 +1530,15 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
final SourceFileInfo srcInfo = file.isValid()? loadSourceInfo(file) : null;
|
||||
if (srcInfo != null) {
|
||||
for (int projectId : srcInfo.getProjectIds().toArray()) {
|
||||
addSourceForRecompilation(projectId, file, srcInfo);
|
||||
if (isSuspended(projectId)) {
|
||||
if (srcInfo.clearPaths(projectId)) {
|
||||
srcInfo.updateTimestamp(projectId, -1L);
|
||||
saveSourceInfo(file, srcInfo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
addSourceForRecompilation(projectId, file, srcInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1415,8 +1563,11 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
if (!project.isInitialized()) {
|
||||
continue; // the content of this project will be scanned during its post-startup activities
|
||||
}
|
||||
final ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
|
||||
final int projectId = getProjectId(project);
|
||||
if (isSuspended(projectId)) {
|
||||
continue;
|
||||
}
|
||||
final ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
|
||||
if (rootManager.getFileIndex().isInSourceContent(file)) {
|
||||
final TranslatingCompiler[] translators = CompilerManager.getInstance(project).getCompilers(TranslatingCompiler.class);
|
||||
processRecursively(file, false, new FileProcessor() {
|
||||
|
||||
@@ -110,11 +110,14 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
applyResourcePatterns(extensionString, (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject));
|
||||
|
||||
// this will schedule for compilation all files that might become compilable after resource patterns' changing
|
||||
TranslatingCompilerFilesMonitor.getInstance().scanSourcesForCompilableFiles(myProject);
|
||||
final TranslatingCompilerFilesMonitor monitor = TranslatingCompilerFilesMonitor.getInstance();
|
||||
if (!workspaceConfiguration.USE_COMPILE_SERVER) {
|
||||
CompileServerManager.getInstance().shutdownServer();
|
||||
monitor.watchProject(myProject);
|
||||
monitor.scanSourcesForCompilableFiles(myProject);
|
||||
}
|
||||
else {
|
||||
monitor.suspendProject(myProject);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
CompileServerManager.getInstance().sendReloadRequest(myProject);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.intellij.compiler.server;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.PluginAware;
|
||||
import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class CompileServerPlugin implements PluginAware {
|
||||
public static final ExtensionPointName<CompileServerPlugin> EP_NAME = ExtensionPointName.create("com.intellij.compileServer.plugin");
|
||||
private PluginDescriptor myPluginDescriptor;
|
||||
private String myJarPath;
|
||||
|
||||
/**
|
||||
* Specifies path to a jar file which should be added to the classpath of the compile server. The path is relative to the plugin 'lib' directory.
|
||||
* In the development node the name of this file without extension is treated as a module name and the output directory of the module is added to the classpath.
|
||||
*/
|
||||
@Attribute("jar-path")
|
||||
public String getJarPath() {
|
||||
return myJarPath;
|
||||
}
|
||||
|
||||
public void setJarPath(String jarPath) {
|
||||
myJarPath = jarPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setPluginDescriptor(PluginDescriptor pluginDescriptor) {
|
||||
myPluginDescriptor = pluginDescriptor;
|
||||
}
|
||||
|
||||
public PluginDescriptor getPluginDescriptor() {
|
||||
return myPluginDescriptor;
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.compiler.server.impl;
|
||||
|
||||
import com.intellij.compiler.server.CompileServerPlugin;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class CompileServerClasspathManager {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.server.impl.CompileServerClasspathManager");
|
||||
private List<File> myCompileServerPluginsClasspath;
|
||||
|
||||
public List<File> getCompileServerPluginsClasspath() {
|
||||
if (myCompileServerPluginsClasspath == null) {
|
||||
myCompileServerPluginsClasspath = computeCompileServerPluginsClasspath();
|
||||
}
|
||||
return myCompileServerPluginsClasspath;
|
||||
}
|
||||
|
||||
private static List<File> computeCompileServerPluginsClasspath() {
|
||||
final List<File> classpath = new ArrayList<File>();
|
||||
for (CompileServerPlugin serverPlugin : CompileServerPlugin.EP_NAME.getExtensions()) {
|
||||
final PluginId pluginId = serverPlugin.getPluginDescriptor().getPluginId();
|
||||
final IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
|
||||
LOG.assertTrue(plugin != null, pluginId);
|
||||
final File baseFile = plugin.getPath();
|
||||
if (baseFile.isFile()) {
|
||||
classpath.add(baseFile);
|
||||
}
|
||||
else if (baseFile.isDirectory()) {
|
||||
final String relativePath = serverPlugin.getJarPath();
|
||||
File jarFile = new File(new File(baseFile, "lib"), relativePath);
|
||||
if (jarFile.exists()) {
|
||||
classpath.add(jarFile);
|
||||
}
|
||||
else {
|
||||
//development mode: add directory out/classes/production/<jar-name> to classpath, assuming that jar-name is equal to module name
|
||||
final String moduleName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(relativePath));
|
||||
final File dir = new File(baseFile.getParentFile(), moduleName);
|
||||
if (!dir.exists()) {
|
||||
LOG.warn("Cannot add plugin " + pluginId + " to compile server classpath: " + jarFile.getAbsolutePath() + " and " +
|
||||
dir.getAbsolutePath() + " don't exist");
|
||||
}
|
||||
classpath.add(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
return classpath;
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,10 @@ public class CompilerPaths {
|
||||
return new File(getCompilerSystemDirectory(project), ".caches");
|
||||
}
|
||||
|
||||
public static File getRebuildMarkerFile(Project project) {
|
||||
return new File(getCompilerSystemDirectory(project), "rebuild_required");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param project
|
||||
* @return a directory under IDEA "system" directory where all files related to compiler subsystem are stored (such as compiler caches or generated files)
|
||||
|
||||
+5
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,22 +16,20 @@
|
||||
package com.intellij.debugger.actions;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.*;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
|
||||
/*
|
||||
* Class SetValueAction
|
||||
/**
|
||||
* @author Jeka
|
||||
*/
|
||||
public class CompareValueWithClipboardAction extends BaseValueAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.actions.CompareValueWithClipboardAction");
|
||||
protected void processText(final Project project, final String text) {
|
||||
DiffManager.getInstance().getDiffTool().show(new ClipboardSelectionContents(text, project));
|
||||
}
|
||||
@@ -57,10 +55,11 @@ public class CompareValueWithClipboardAction extends BaseValueAction {
|
||||
return !SystemInfo.isMac;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DiffContent[] getContents() {
|
||||
if (myContents != null) return myContents;
|
||||
DiffContent clipboardContent = createClipboardContent();
|
||||
if (clipboardContent == null) return null;
|
||||
if (clipboardContent == null) clipboardContent = new SimpleContent("");
|
||||
|
||||
myContents = new DiffContent[2];
|
||||
myContents[0] = clipboardContent;
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ import java.util.Map;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Aug 30, 2010
|
||||
*/
|
||||
public class CodeFragmentFactoryContextWrapper implements CodeFragmentFactory{
|
||||
public class CodeFragmentFactoryContextWrapper extends CodeFragmentFactory {
|
||||
public static final Key<Value> LABEL_VARIABLE_VALUE_KEY = Key.create("_label_variable_value_key_");
|
||||
public static final String DEBUG_LABEL_SUFFIX = "_DebugLabel";
|
||||
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Jun 7, 2005
|
||||
*/
|
||||
public class DefaultCodeFragmentFactory implements CodeFragmentFactory {
|
||||
public class DefaultCodeFragmentFactory extends CodeFragmentFactory {
|
||||
private static final class SingletonHolder {
|
||||
public static final DefaultCodeFragmentFactory ourInstance = new DefaultCodeFragmentFactory();
|
||||
}
|
||||
|
||||
+7
-1
@@ -53,6 +53,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
|
||||
private StateRestoringCheckBox myCbShowStaticFinalFields;
|
||||
private final ArrayRendererConfigurable myArrayRendererConfigurable;
|
||||
private JCheckBox myCbEnableAutoExpressions;
|
||||
private JCheckBox myCbEnableAlternateViews;
|
||||
|
||||
private JCheckBox myCbEnableToString;
|
||||
@@ -92,6 +93,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
myCbShowStatic = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.static.fields"));
|
||||
myCbShowStaticFinalFields = new StateRestoringCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.static.final.fields"));
|
||||
myCbEnableAlternateViews = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.alternate.view"));
|
||||
myCbEnableAutoExpressions = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.auto.expressions"));
|
||||
myCbShowStatic.addChangeListener(new ChangeListener(){
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
if(myCbShowStatic.isSelected()) {
|
||||
@@ -163,7 +165,8 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
arraysPanel.setBorder(IdeBorderFactory.createTitledBorder("Arrays", false, true, true));
|
||||
panel.add(arraysPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
||||
|
||||
panel.add(myCbEnableAlternateViews, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
|
||||
panel.add(myCbEnableAutoExpressions, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
|
||||
panel.add(myCbEnableAlternateViews, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 10), 0, 0));
|
||||
// starting 4-th row
|
||||
panel.add(myCbEnableToString, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0));
|
||||
panel.add(myRbAllThatOverride, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 12, 0, 0), 0, 0));
|
||||
@@ -189,6 +192,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
generalSettings.AUTOSCROLL_TO_NEW_LOCALS = myCbAutoscroll.isSelected();
|
||||
rendererSettings.setAlternateCollectionViewsEnabled(myCbEnableAlternateViews.isSelected());
|
||||
generalSettings.HIDE_NULL_ARRAY_ELEMENTS = myCbHideNullArrayElements.isSelected();
|
||||
generalSettings.ENABLE_AUTO_EXPRESSIONS = myCbEnableAutoExpressions.isSelected();
|
||||
|
||||
final ClassRenderer classRenderer = rendererSettings.getClassRenderer();
|
||||
classRenderer.SORT_ASCENDING = myCbSort.isSelected();
|
||||
@@ -219,6 +223,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
myCbAutoscroll.setSelected(generalSettings.AUTOSCROLL_TO_NEW_LOCALS);
|
||||
myCbHideNullArrayElements.setSelected(generalSettings.HIDE_NULL_ARRAY_ELEMENTS);
|
||||
myCbEnableAlternateViews.setSelected(rendererSettings.areAlternateCollectionViewsEnabled());
|
||||
myCbEnableAutoExpressions.setSelected(generalSettings.ENABLE_AUTO_EXPRESSIONS);
|
||||
|
||||
ClassRenderer classRenderer = rendererSettings.getClassRenderer();
|
||||
|
||||
@@ -264,6 +269,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
ViewsGeneralSettings generalSettings = ViewsGeneralSettings.getInstance();
|
||||
return
|
||||
(generalSettings.AUTOSCROLL_TO_NEW_LOCALS != myCbAutoscroll.isSelected()) ||
|
||||
(generalSettings.ENABLE_AUTO_EXPRESSIONS != myCbEnableAutoExpressions.isSelected()) ||
|
||||
(generalSettings.HIDE_NULL_ARRAY_ELEMENTS != myCbHideNullArrayElements.isSelected()) || myAutoTooltip.isChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public class ViewsGeneralSettings implements PersistentStateComponent<Element> {
|
||||
public boolean SHOW_OBJECTID = true;
|
||||
public boolean HIDE_NULL_ARRAY_ELEMENTS = true;
|
||||
public boolean AUTOSCROLL_TO_NEW_LOCALS = true;
|
||||
public boolean ENABLE_AUTO_EXPRESSIONS = true;
|
||||
|
||||
public ViewsGeneralSettings() {
|
||||
}
|
||||
|
||||
@@ -28,10 +28,14 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class ExpressionEvaluationDialog extends EvaluationDialog {
|
||||
@@ -77,15 +81,25 @@ public class ExpressionEvaluationDialog extends EvaluationDialog {
|
||||
}
|
||||
|
||||
protected JComponent createCenterPanel() {
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
final JLabel expressionLabel = new JLabel(DebuggerBundle.message("label.evaluate.dialog.expression"));
|
||||
panel.add(expressionLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
||||
panel.add(getExpressionCombo(), new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 0), 0, 0));
|
||||
final JPanel exprPanel = new JPanel(new BorderLayout());
|
||||
exprPanel.add(new JLabel(DebuggerBundle.message("label.evaluate.dialog.expression")), BorderLayout.WEST);
|
||||
exprPanel.add(getExpressionCombo(), BorderLayout.CENTER);
|
||||
final JLabel help = new JLabel(
|
||||
String.format("Press Enter to Evaluate or %s+Enter to evaluate and add to the Watches", SystemInfo.isMac ? "Command" : "Control"), SwingConstants.RIGHT);
|
||||
help.setBorder(IdeBorderFactory.createEmptyBorder(2,0,6,0));
|
||||
UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, help);
|
||||
help.setForeground(UIUtil.getInactiveTextColor());
|
||||
exprPanel.add(help, BorderLayout.SOUTH);
|
||||
|
||||
final JLabel resultLabel = new JLabel(DebuggerBundle.message("label.evaluate.dialog.result"));
|
||||
panel.add(resultLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
|
||||
panel.add(getEvaluationPanel(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0));
|
||||
|
||||
final JPanel resultPanel = new JPanel(new BorderLayout());
|
||||
//resultPanel.add(new JLabel(DebuggerBundle.message("label.evaluate.dialog.result")), BorderLayout.NORTH);
|
||||
resultPanel.add(getEvaluationPanel(), BorderLayout.CENTER);
|
||||
|
||||
panel.add(exprPanel, BorderLayout.NORTH);
|
||||
panel.add(resultPanel, BorderLayout.CENTER);
|
||||
|
||||
return panel;
|
||||
}
|
||||
@@ -103,6 +117,31 @@ public class ExpressionEvaluationDialog extends EvaluationDialog {
|
||||
return new Action[] { getOKAction(), getCancelAction(), new SwitchAction(), getHelpAction() } ;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createDefaultActions() {
|
||||
super.createDefaultActions();
|
||||
myOKAction = new OkAction(){
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
super.actionPerformed(e);
|
||||
final int mask = SystemInfo.isMac ? InputEvent.META_MASK : InputEvent.CTRL_MASK;
|
||||
if ((e.getModifiers() & mask) != 0) {
|
||||
addCurrentExpressionToWatches();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void addCurrentExpressionToWatches() {
|
||||
final DebuggerSessionTab tab = DebuggerPanelsManager.getInstance(getProject()).getSessionTab();
|
||||
if (tab != null) {
|
||||
final TextWithImports evaluate = getCodeToEvaluate();
|
||||
if (evaluate != null) {
|
||||
tab.getWatchPanel().getWatchTree().addWatch(evaluate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void doHelpAction() {
|
||||
HelpManager.getInstance().invokeHelp(HelpID.EVALUATE);
|
||||
}
|
||||
|
||||
@@ -51,8 +51,10 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBoxWithWidePopup;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.CaptionPanel;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.border.CustomLineBorder;
|
||||
import com.intellij.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.sun.jdi.ObjectCollectedException;
|
||||
@@ -114,6 +116,8 @@ public class FramesPanel extends UpdatableDebuggerView {
|
||||
|
||||
final ActionToolbar toolbar = createToolbar();
|
||||
Wrapper threads = new Wrapper();
|
||||
CustomLineBorder border = new CustomLineBorder(CaptionPanel.CNT_ACTIVE_COLOR, 0, 0, 1, 0);
|
||||
threads.setBorder(border);
|
||||
threads.add(toolbar.getComponent(), BorderLayout.EAST);
|
||||
threads.add(myThreadsCombo, BorderLayout.CENTER);
|
||||
add(threads, BorderLayout.NORTH);
|
||||
|
||||
@@ -128,29 +128,35 @@ public class FrameVariablesTree extends DebuggerTree {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Map<String, LocalVariableProxyImpl> visibleVariables = getVisibleVariables(stackDescriptor);
|
||||
final EvaluationContextImpl evalContext = debuggerContext.createEvaluationContext();
|
||||
final Pair<Set<String>, Set<TextWithImports>> usedVars =
|
||||
ApplicationManager.getApplication().runReadAction(new Computable<Pair<Set<String>, Set<TextWithImports>>>() {
|
||||
public Pair<Set<String>, Set<TextWithImports>> compute() {
|
||||
return findReferencedVars(visibleVariables.keySet(), sourcePosition, evalContext);
|
||||
}
|
||||
});
|
||||
// add locals
|
||||
if (myAutoWatchMode) {
|
||||
for (String var : usedVars.first) {
|
||||
final LocalVariableDescriptorImpl descriptor = myNodeManager.getLocalVariableDescriptor(stackDescriptor, visibleVariables.get(var));
|
||||
myChildren.add(myNodeManager.createNode(descriptor, evaluationContext));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!ViewsGeneralSettings.getInstance().ENABLE_AUTO_EXPRESSIONS && !myAutoWatchMode) {
|
||||
// optimization
|
||||
super.buildVariables(stackDescriptor, evaluationContext);
|
||||
}
|
||||
// add expressions
|
||||
final EvaluationContextImpl evalContextCopy = evaluationContext.createEvaluationContext(evaluationContext.getThisObject());
|
||||
evalContextCopy.setAutoLoadClasses(false);
|
||||
for (TextWithImports text : usedVars.second) {
|
||||
myChildren.add(myNodeManager.createNode(myNodeManager.getWatchItemDescriptor(stackDescriptor, text, null), evalContextCopy));
|
||||
else {
|
||||
final Map<String, LocalVariableProxyImpl> visibleVariables = getVisibleVariables(stackDescriptor);
|
||||
final EvaluationContextImpl evalContext = debuggerContext.createEvaluationContext();
|
||||
final Pair<Set<String>, Set<TextWithImports>> usedVars =
|
||||
ApplicationManager.getApplication().runReadAction(new Computable<Pair<Set<String>, Set<TextWithImports>>>() {
|
||||
public Pair<Set<String>, Set<TextWithImports>> compute() {
|
||||
return findReferencedVars(visibleVariables.keySet(), sourcePosition, evalContext);
|
||||
}
|
||||
});
|
||||
// add locals
|
||||
if (myAutoWatchMode) {
|
||||
for (String var : usedVars.first) {
|
||||
final LocalVariableDescriptorImpl descriptor = myNodeManager.getLocalVariableDescriptor(stackDescriptor, visibleVariables.get(var));
|
||||
myChildren.add(myNodeManager.createNode(descriptor, evaluationContext));
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.buildVariables(stackDescriptor, evaluationContext);
|
||||
}
|
||||
// add expressions
|
||||
final EvaluationContextImpl evalContextCopy = evaluationContext.createEvaluationContext(evaluationContext.getThisObject());
|
||||
evalContextCopy.setAutoLoadClasses(false);
|
||||
for (TextWithImports text : usedVars.second) {
|
||||
myChildren.add(myNodeManager.createNode(myNodeManager.getWatchItemDescriptor(stackDescriptor, text, null), evalContextCopy));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EvaluateException e) {
|
||||
@@ -450,6 +456,7 @@ public class FrameVariablesTree extends DebuggerTree {
|
||||
private final Set<String> myVars;
|
||||
private final SourcePosition myPosition;
|
||||
private final EvaluationContextImpl myEvalContext;
|
||||
private final boolean myCollectExpressions;
|
||||
|
||||
public VariablesCollector(final Set<String> visibleLocals,
|
||||
final TextRange lineRange,
|
||||
@@ -462,6 +469,7 @@ public class FrameVariablesTree extends DebuggerTree {
|
||||
myVars = vars;
|
||||
myPosition = position;
|
||||
myEvalContext = evalContext;
|
||||
myCollectExpressions = ViewsGeneralSettings.getInstance().ENABLE_AUTO_EXPRESSIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -473,9 +481,11 @@ public class FrameVariablesTree extends DebuggerTree {
|
||||
|
||||
@Override
|
||||
public void visitMethodCallExpression(final PsiMethodCallExpression expression) {
|
||||
final PsiMethod psiMethod = expression.resolveMethod();
|
||||
if (psiMethod != null && !DebuggerUtils.hasSideEffectsOrReferencesMissingVars(expression, myVisibleLocals)) {
|
||||
myExpressions.add(new TextWithImportsImpl(expression));
|
||||
if (myCollectExpressions) {
|
||||
final PsiMethod psiMethod = expression.resolveMethod();
|
||||
if (psiMethod != null && !DebuggerUtils.hasSideEffectsOrReferencesMissingVars(expression, myVisibleLocals)) {
|
||||
myExpressions.add(new TextWithImportsImpl(expression));
|
||||
}
|
||||
}
|
||||
super.visitMethodCallExpression(expression);
|
||||
}
|
||||
@@ -487,7 +497,7 @@ public class FrameVariablesTree extends DebuggerTree {
|
||||
if (psiElement instanceof PsiVariable) {
|
||||
final PsiVariable var = (PsiVariable)psiElement;
|
||||
if (var instanceof PsiField) {
|
||||
if (!DebuggerUtils.hasSideEffectsOrReferencesMissingVars(reference, myVisibleLocals)) {
|
||||
if (myCollectExpressions && !DebuggerUtils.hasSideEffectsOrReferencesMissingVars(reference, myVisibleLocals)) {
|
||||
/*
|
||||
if (var instanceof PsiEnumConstant && reference.getQualifier() == null) {
|
||||
final PsiClass enumClass = ((PsiEnumConstant)var).getContainingClass();
|
||||
@@ -532,7 +542,7 @@ public class FrameVariablesTree extends DebuggerTree {
|
||||
|
||||
@Override
|
||||
public void visitArrayAccessExpression(final PsiArrayAccessExpression expression) {
|
||||
if (!DebuggerUtils.hasSideEffectsOrReferencesMissingVars(expression, myVisibleLocals)) {
|
||||
if (myCollectExpressions && !DebuggerUtils.hasSideEffectsOrReferencesMissingVars(expression, myVisibleLocals)) {
|
||||
myExpressions.add(new TextWithImportsImpl(expression));
|
||||
}
|
||||
super.visitArrayAccessExpression(expression);
|
||||
|
||||
@@ -43,10 +43,10 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonRunnable;
|
||||
import com.intellij.ui.ListenerUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.border.CustomLineBorder;
|
||||
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -218,13 +218,20 @@ public class MainWatchPanel extends WatchPanel implements DataProvider {
|
||||
executeAction(DebuggerActions.NEW_WATCH, tree);
|
||||
}
|
||||
});
|
||||
// TODO[den]: add "Add to watches action"
|
||||
// TODO[den]: add "Add to watches action" on Mac
|
||||
if (!SystemInfo.isMac) {
|
||||
decorator.addExtraAction(AnActionButton.fromAction(ActionManager.getInstance().getAction(XDebuggerActions.ADD_TO_WATCH)));
|
||||
}
|
||||
decorator.setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
executeAction(DebuggerActions.REMOVE_WATCH, tree);
|
||||
}
|
||||
});
|
||||
CustomLineBorder border = new CustomLineBorder(CaptionPanel.CNT_ACTIVE_COLOR,
|
||||
SystemInfo.isMac ? 1 : 0, 0,
|
||||
SystemInfo.isMac ? 0 : 1, 0);
|
||||
decorator.setToolbarBorder(border);
|
||||
final JPanel panel = decorator.createPanel();
|
||||
panel.setBorder(null);
|
||||
return panel;
|
||||
|
||||
+7
-7
@@ -22,21 +22,21 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaCodeFragment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
public interface CodeFragmentFactory {
|
||||
ExtensionPointName<CodeFragmentFactory> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.debugger.codeFragmentFactory");
|
||||
public abstract class CodeFragmentFactory {
|
||||
public static final ExtensionPointName<CodeFragmentFactory> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.debugger.codeFragmentFactory");
|
||||
|
||||
JavaCodeFragment createCodeFragment(TextWithImports item, PsiElement context, Project project);
|
||||
public abstract JavaCodeFragment createCodeFragment(TextWithImports item, PsiElement context, Project project);
|
||||
|
||||
JavaCodeFragment createPresentationCodeFragment(TextWithImports item, PsiElement context, Project project);
|
||||
public abstract JavaCodeFragment createPresentationCodeFragment(TextWithImports item, PsiElement context, Project project);
|
||||
|
||||
boolean isContextAccepted(PsiElement contextElement);
|
||||
public abstract boolean isContextAccepted(PsiElement contextElement);
|
||||
|
||||
LanguageFileType getFileType();
|
||||
public abstract LanguageFileType getFileType();
|
||||
|
||||
/**
|
||||
* In case if createCodeFragment returns java code use
|
||||
* com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl#getInstance()
|
||||
* @return builder, which can evaluate expression for your code fragment
|
||||
*/
|
||||
EvaluatorBuilder getEvaluatorBuilder();
|
||||
public abstract EvaluatorBuilder getEvaluatorBuilder();
|
||||
}
|
||||
|
||||
+22
-4
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration.libraryEditor;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
@@ -31,6 +33,10 @@ import com.intellij.openapi.roots.JavadocOrderRootType;
|
||||
import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonUpdater;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -62,12 +68,24 @@ public class JavadocOrderRootTypeUIFactory implements OrderRootTypeUIFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isShowUrlButton() {
|
||||
return true;
|
||||
protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) {
|
||||
AnActionButton specifyUrlButton = new AnActionButton(ProjectBundle.message("sdk.paths.specify.url.button"), PlatformIcons.TABLE_URL) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
onSpecifyUrlButtonClicked();
|
||||
}
|
||||
};
|
||||
specifyUrlButton.setShortcut(CustomShortcutSet.fromString("alt S"));
|
||||
specifyUrlButton.addCustomUpdater(new AnActionButtonUpdater() {
|
||||
@Override
|
||||
public boolean isEnabled(AnActionEvent e) {
|
||||
return myEnabled && !isUrlInserted();
|
||||
}
|
||||
});
|
||||
toolbarDecorator.addExtraAction(specifyUrlButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSpecifyUrlButtonClicked() {
|
||||
private void onSpecifyUrlButtonClicked() {
|
||||
VirtualFile virtualFile = Util.showSpecifyJavadocUrlDialog(myPanel, getInitialValue());
|
||||
if(virtualFile != null){
|
||||
addElement(virtualFile);
|
||||
|
||||
+8
-3
@@ -32,8 +32,7 @@ public class ModuleProjectStructureElement extends ProjectStructureElement {
|
||||
return myModule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(ProjectStructureProblemsHolder problemsHolder) {
|
||||
public void checkModulesNames(ProjectStructureProblemsHolder problemsHolder) {
|
||||
final ModifiableModuleModel moduleModel = myContext.getModulesConfigurator().getModuleModel();
|
||||
final Module[] all = moduleModel.getModules();
|
||||
if (!ArrayUtil.contains(myModule, all)) {
|
||||
@@ -42,11 +41,17 @@ public class ModuleProjectStructureElement extends ProjectStructureElement {
|
||||
|
||||
for (Module each : all) {
|
||||
if (each != myModule && myContext.getRealName(each).equals(myContext.getRealName(myModule))) {
|
||||
problemsHolder.registerProblem(ProjectBundle.message("project.roots.module.duplicate.name.message"), null, ProjectStructureProblemType.error("duplicate-module-name"), createPlace(),
|
||||
problemsHolder.registerProblem(ProjectBundle.message("project.roots.module.duplicate.name.message"), null,
|
||||
ProjectStructureProblemType.error("duplicate-module-name"), createPlace(),
|
||||
null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(ProjectStructureProblemsHolder problemsHolder) {
|
||||
checkModulesNames(problemsHolder);
|
||||
|
||||
final ModuleRootModel rootModel = myContext.getModulesConfigurator().getRootModel(myModule);
|
||||
if (rootModel == null) return; //already disposed
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class ProjectStructureDaemonAnalyzer implements Disposable {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("checking " + element);
|
||||
}
|
||||
element.check(problemsHolder);
|
||||
ProjectStructureValidator.check(element, problemsHolder);
|
||||
}
|
||||
}.execute();
|
||||
invokeLater(new Runnable() {
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration.projectRoot.daemon;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
|
||||
/**
|
||||
* User: ksafonov
|
||||
*/
|
||||
public abstract class ProjectStructureValidator {
|
||||
|
||||
private static final ExtensionPointName<ProjectStructureValidator> EP_NAME =
|
||||
ExtensionPointName.create("com.intellij.projectStructureValidator");
|
||||
|
||||
public static void check(ProjectStructureElement element, ProjectStructureProblemsHolder problemsHolder) {
|
||||
for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
|
||||
if (validator.checkElement(element, problemsHolder)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
element.check(problemsHolder);
|
||||
}
|
||||
|
||||
protected boolean checkElement(ProjectStructureElement element, ProjectStructureProblemsHolder problemsHolder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,11 +19,13 @@ import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.ClassConditionKey;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -65,7 +67,16 @@ public class JavaChainLookupElement extends LookupElementDecorator<LookupElement
|
||||
}
|
||||
|
||||
private String maybeAddParentheses(String s) {
|
||||
return myQualifier.getObject() instanceof PsiMethod ? s + "()" : s;
|
||||
return getQualifierObject() instanceof PsiMethod ? s + "()" : s;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object getQualifierObject() {
|
||||
Object qObject = myQualifier.getObject();
|
||||
if (qObject instanceof ResolveResult) {
|
||||
qObject = ((ResolveResult)qObject).getElement();
|
||||
}
|
||||
return qObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,6 +87,10 @@ public class JavaChainLookupElement extends LookupElementDecorator<LookupElement
|
||||
String name = maybeAddParentheses(qualifierPresentation.getItemText());
|
||||
final String qualifierText = myQualifier.as(CastingLookupElementDecorator.CLASS_CONDITION_KEY) != null ? "(" + name + ")" : name;
|
||||
presentation.setItemText(qualifierText + "." + presentation.getItemText());
|
||||
|
||||
if (getQualifierObject() instanceof PsiClass) {
|
||||
presentation.setTailText(StringUtil.notNullize(presentation.getTailText()) + qualifierPresentation.getTailText());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,7 +114,7 @@ public class JavaChainLookupElement extends LookupElementDecorator<LookupElement
|
||||
CompletionUtil.emulateInsertion(getDelegate(), context.getTailOffset(), context);
|
||||
}
|
||||
|
||||
private static boolean shouldParenthesizeQualifier(final PsiFile file, final int startOffset, final int endOffset) {
|
||||
protected boolean shouldParenthesizeQualifier(final PsiFile file, final int startOffset, final int endOffset) {
|
||||
PsiElement element = file.findElementAt(startOffset);
|
||||
if (element == null) {
|
||||
return false;
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.codeInsight.lookup.CharFilter;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.patterns.PsiJavaPatterns;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
@@ -84,7 +85,7 @@ public class JavaCharFilter extends CharFilter {
|
||||
public Result acceptChar(char c, final int prefixLength, final Lookup lookup) {
|
||||
if (!lookup.isCompletion()) return null;
|
||||
|
||||
if (!(lookup.getPsiFile() instanceof PsiJavaFile)) {
|
||||
if (!lookup.getPsiFile().getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -141,6 +142,9 @@ public class JavaCharFilter extends CharFilter {
|
||||
return Result.SELECT_ITEM_AND_FINISH_LOOKUP;
|
||||
}
|
||||
}
|
||||
if (c == '(' && PsiKeyword.RETURN.equals(item.getLookupString())) {
|
||||
return Result.HIDE_LOOKUP;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -57,7 +57,8 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
CompletionResultSet result = _result.withPrefixMatcher(CompletionUtil.findReferenceOrAlphanumericPrefix(parameters));
|
||||
addAllClasses(parameters, JavaCompletionSorting.addJavaSorting(parameters, result), parameters.getInvocationCount() <= 1, new Consumer<LookupElement>() {
|
||||
addAllClasses(parameters, parameters.getInvocationCount() <= 1,
|
||||
JavaCompletionSorting.addJavaSorting(parameters, result).getPrefixMatcher(), new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
_result.addElement(element);
|
||||
@@ -68,8 +69,8 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
public static void addAllClasses(CompletionParameters parameters,
|
||||
final CompletionResultSet result,
|
||||
final boolean filterByScope,
|
||||
@NotNull final PrefixMatcher matcher,
|
||||
@NotNull final Consumer<LookupElement> consumer) {
|
||||
final PsiElement insertedElement = parameters.getPosition();
|
||||
|
||||
@@ -110,7 +111,7 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
final boolean lookingForAnnotations = PsiJavaPatterns.psiElement().afterLeaf("@").accepts(insertedElement);
|
||||
AllClassesGetter.processJavaClasses(parameters, result.getPrefixMatcher(), filterByScope, new Consumer<PsiClass>() {
|
||||
AllClassesGetter.processJavaClasses(parameters, matcher, filterByScope, new Consumer<PsiClass>() {
|
||||
@Override
|
||||
public void consume(PsiClass psiClass) {
|
||||
if (lookingForAnnotations && !psiClass.isAnnotationType()) return;
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
withParent(or(psiElement(PsiResourceVariable.class), psiElement(PsiResourceList.class)))));
|
||||
|
||||
@Nullable
|
||||
private static ElementFilter getReferenceFilter(PsiElement position) {
|
||||
public static ElementFilter getReferenceFilter(PsiElement position) {
|
||||
// Completion after extends in interface, type parameter and implements in class
|
||||
final PsiClass containingClass = PsiTreeUtil.getParentOfType(position, PsiClass.class, false, PsiCodeBlock.class, PsiMethod.class, PsiExpressionList.class, PsiVariable.class);
|
||||
if (containingClass != null && psiElement().afterLeaf(PsiKeyword.EXTENDS, PsiKeyword.IMPLEMENTS, ",", "&").accepts(position)) {
|
||||
@@ -239,7 +239,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
if (!isClassNamePossible(parameters.getPosition()) || !mayStartClassName(result, parameters.isRelaxedMatching())) return;
|
||||
|
||||
if (mayShowAllClasses(parameters)) {
|
||||
JavaClassNameCompletionContributor.addAllClasses(parameters, result, parameters.getInvocationCount() <= 2, new Consumer<LookupElement>() {
|
||||
JavaClassNameCompletionContributor.addAllClasses(parameters, parameters.getInvocationCount() <= 2, result.getPrefixMatcher(), new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
if (!inheritors.alreadyProcessed(element)) {
|
||||
|
||||
@@ -346,6 +346,9 @@ public class JavaCompletionUtil {
|
||||
|
||||
@Nullable
|
||||
private static PsiType getPsiType(final Object o) {
|
||||
if (o instanceof ResolveResult) {
|
||||
return getPsiType(((ResolveResult)o).getElement());
|
||||
}
|
||||
if (o instanceof PsiVariable) {
|
||||
return ((PsiVariable)o).getType();
|
||||
}
|
||||
|
||||
+89
-20
@@ -15,10 +15,21 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
|
||||
import com.intellij.codeInsight.lookup.AutoCompletionPolicy;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiReferenceExpression;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.filters.ElementFilter;
|
||||
import com.intellij.util.CollectConsumer;
|
||||
import com.intellij.util.Consumer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
@@ -26,29 +37,87 @@ public class JavaNoVariantsDelegator extends NoVariantsDelegator {
|
||||
|
||||
@Override
|
||||
protected void delegate(CompletionParameters parameters, CompletionResultSet result, Consumer<CompletionResult> passResult) {
|
||||
if (parameters.getCompletionType() == CompletionType.BASIC &&
|
||||
parameters.getInvocationCount() <= 1 &&
|
||||
JavaCompletionContributor.mayStartClassName(result, false) &&
|
||||
JavaCompletionContributor.isClassNamePossible(parameters.getPosition())) {
|
||||
final ClassByNameMerger merger = new ClassByNameMerger(parameters.getInvocationCount() == 0, result);
|
||||
if (parameters.getCompletionType() == CompletionType.BASIC) {
|
||||
PsiElement position = parameters.getPosition();
|
||||
if (parameters.getInvocationCount() <= 1 &&
|
||||
JavaCompletionContributor.mayStartClassName(result, false) &&
|
||||
JavaCompletionContributor.isClassNamePossible(position)) {
|
||||
suggestNonImportedClasses(parameters, result);
|
||||
return;
|
||||
}
|
||||
|
||||
JavaClassNameCompletionContributor.addAllClasses(parameters, JavaCompletionSorting.addJavaSorting(parameters, result),
|
||||
true, new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
JavaPsiClassReferenceElement classElement = element.as(JavaPsiClassReferenceElement.CLASS_CONDITION_KEY);
|
||||
if (classElement != null) {
|
||||
classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
|
||||
}
|
||||
suggestChainedCalls(parameters, result, position);
|
||||
}
|
||||
|
||||
merger.consume(classElement);
|
||||
}
|
||||
});
|
||||
|
||||
merger.finishedClassProcessing();
|
||||
|
||||
} else if (parameters.getCompletionType() == CompletionType.SMART && parameters.getInvocationCount() == 2) {
|
||||
if (parameters.getCompletionType() == CompletionType.SMART && parameters.getInvocationCount() == 2) {
|
||||
result.runRemainingContributors(parameters.withInvocationCount(3), passResult);
|
||||
}
|
||||
}
|
||||
|
||||
private static void suggestChainedCalls(CompletionParameters parameters, CompletionResultSet result, PsiElement position) {
|
||||
PsiElement parent = position.getParent();
|
||||
if (!(parent instanceof PsiJavaCodeReferenceElement)) {
|
||||
return;
|
||||
}
|
||||
PsiElement qualifier = ((PsiJavaCodeReferenceElement)parent).getQualifier();
|
||||
if (!(qualifier instanceof PsiJavaCodeReferenceElement) ||
|
||||
((PsiJavaCodeReferenceElement)qualifier).isQualified() ||
|
||||
((PsiJavaCodeReferenceElement)qualifier).resolve() != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String fullPrefix = position.getContainingFile().getText().substring(parent.getTextRange().getStartOffset(), parameters.getOffset());
|
||||
CompletionResultSet qualifiedCollector = result.withPrefixMatcher(fullPrefix);
|
||||
ElementFilter filter = JavaCompletionContributor.getReferenceFilter(position);
|
||||
for (LookupElement base : suggestQualifierItems(parameters, (PsiJavaCodeReferenceElement)qualifier, filter)) {
|
||||
PsiType type = JavaCompletionUtil.getLookupElementType(base);
|
||||
if (type != null && !PsiType.VOID.equals(type)) {
|
||||
PsiReferenceExpression ref = ReferenceExpressionCompletionContributor.createMockReference(position, type, base);
|
||||
for (final LookupElement item : JavaSmartCompletionContributor.completeReference(position, ref, filter, true, true, parameters,
|
||||
result.getPrefixMatcher())) {
|
||||
qualifiedCollector.addElement(new JavaChainLookupElement(base, item));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<LookupElement> suggestQualifierItems(CompletionParameters parameters,
|
||||
PsiJavaCodeReferenceElement qualifier,
|
||||
ElementFilter filter) {
|
||||
String referenceName = qualifier.getReferenceName();
|
||||
if (referenceName == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
PrefixMatcher qMatcher = new CamelHumpMatcher(referenceName);
|
||||
Set<LookupElement> plainVariants =
|
||||
JavaSmartCompletionContributor.completeReference(qualifier, qualifier, filter, true, true, parameters, qMatcher);
|
||||
if (!plainVariants.isEmpty()) {
|
||||
return plainVariants;
|
||||
}
|
||||
|
||||
final Set<LookupElement> allClasses = new LinkedHashSet<LookupElement>();
|
||||
JavaClassNameCompletionContributor.addAllClasses(parameters.withPosition(qualifier.getReferenceNameElement(), qualifier.getTextRange().getEndOffset()),
|
||||
true, qMatcher, new CollectConsumer<LookupElement>(allClasses));
|
||||
return allClasses;
|
||||
}
|
||||
|
||||
private static void suggestNonImportedClasses(CompletionParameters parameters, CompletionResultSet result) {
|
||||
final ClassByNameMerger merger = new ClassByNameMerger(parameters.getInvocationCount() == 0, result);
|
||||
|
||||
JavaClassNameCompletionContributor.addAllClasses(parameters,
|
||||
true, JavaCompletionSorting.addJavaSorting(parameters, result).getPrefixMatcher(), new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
JavaPsiClassReferenceElement classElement = element.as(JavaPsiClassReferenceElement.CLASS_CONDITION_KEY);
|
||||
if (classElement != null) {
|
||||
classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
|
||||
}
|
||||
|
||||
merger.consume(classElement);
|
||||
}
|
||||
});
|
||||
|
||||
merger.finishedClassProcessing();
|
||||
}
|
||||
}
|
||||
|
||||
+19
-10
@@ -155,14 +155,15 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
|
||||
final ElementFilter filter = getReferenceFilter(element);
|
||||
if (filter != null) {
|
||||
final List<ExpectedTypeInfo> infos = Arrays.asList(getExpectedTypes(parameters));
|
||||
for (final LookupElement item : completeReference(element, reference, filter, true, parameters)) {
|
||||
for (final LookupElement item : completeReference(element, reference, filter, true, false, parameters, result.getPrefixMatcher())) {
|
||||
if (item.getObject() instanceof PsiClass) {
|
||||
result.addElement(decorate(LookupElementDecorator.withInsertHandler((LookupItem)item, ConstructorInsertHandler.SMART_INSTANCE), infos));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (INSIDE_TYPECAST_EXPRESSION.accepts(element)) {
|
||||
for (final LookupElement item : completeReference(element, reference, new GeneratorFilter(AssignableToFilter.class, new CastTypeGetter()), false, parameters)) {
|
||||
for (final LookupElement item : completeReference(element, reference, new GeneratorFilter(AssignableToFilter.class, new CastTypeGetter()), false, true, parameters,
|
||||
result.getPrefixMatcher())) {
|
||||
result.addElement(item);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +183,7 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
|
||||
final PsiElement element = parameters.getPosition();
|
||||
final PsiReference reference = element.getContainingFile().findReferenceAt(parameters.getOffset());
|
||||
assert reference != null;
|
||||
for (final LookupElement item : completeReference(element, reference, THROWABLES_FILTER, true, parameters)) {
|
||||
for (final LookupElement item : completeReference(element, reference, THROWABLES_FILTER, true, false, parameters, result.getPrefixMatcher())) {
|
||||
result.addElement(item);
|
||||
}
|
||||
}
|
||||
@@ -456,7 +457,12 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
|
||||
return ExpectedTypesProvider.getExpectedTypes(expression, true, parameters.getCompletionType() == CompletionType.SMART, false);
|
||||
}
|
||||
|
||||
static Set<LookupElement> completeReference(final PsiElement element, PsiReference reference, final ElementFilter filter, final boolean acceptClasses, CompletionParameters parameters) {
|
||||
static Set<LookupElement> completeReference(final PsiElement element,
|
||||
PsiReference reference,
|
||||
final ElementFilter filter,
|
||||
final boolean acceptClasses,
|
||||
final boolean acceptMembers,
|
||||
CompletionParameters parameters, @Nullable final PrefixMatcher matcher) {
|
||||
if (reference instanceof PsiMultiReference) {
|
||||
reference = ContainerUtil.findInstance(((PsiMultiReference) reference).getReferences(), PsiJavaReference.class);
|
||||
}
|
||||
@@ -470,15 +476,18 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
public boolean isClassAcceptable(Class hintClass) {
|
||||
if (acceptClasses) {
|
||||
return ReflectionCache.isAssignable(PsiClass.class, hintClass);
|
||||
if (ReflectionCache.isAssignable(PsiClass.class, hintClass)) {
|
||||
return acceptClasses;
|
||||
}
|
||||
|
||||
return ReflectionCache.isAssignable(PsiVariable.class, hintClass) ||
|
||||
ReflectionCache.isAssignable(PsiMethod.class, hintClass) ||
|
||||
ReflectionCache.isAssignable(CandidateInfo.class, hintClass);
|
||||
if (ReflectionCache.isAssignable(PsiVariable.class, hintClass) ||
|
||||
ReflectionCache.isAssignable(PsiMethod.class, hintClass) ||
|
||||
ReflectionCache.isAssignable(CandidateInfo.class, hintClass)) {
|
||||
return acceptMembers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, true, parameters.getInvocationCount() <= 1, null, parameters);
|
||||
}, true, parameters.getInvocationCount() <= 1, matcher, parameters);
|
||||
}
|
||||
|
||||
return Collections.emptySet();
|
||||
|
||||
+34
-20
@@ -33,8 +33,11 @@ import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.filters.*;
|
||||
import com.intellij.psi.filters.element.ModifierFilter;
|
||||
import com.intellij.psi.filters.types.AssignableFromFilter;
|
||||
import com.intellij.psi.impl.FakePsiElement;
|
||||
import com.intellij.psi.impl.light.LightVariableBuilder;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.infos.CandidateInfo;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -122,7 +125,7 @@ public class ReferenceExpressionCompletionContributor {
|
||||
final boolean secondTime = parameters.getParameters().getInvocationCount() >= 2;
|
||||
|
||||
final Set<LookupElement> base =
|
||||
JavaSmartCompletionContributor.completeReference(element, reference, filter, false, parameters.getParameters());
|
||||
JavaSmartCompletionContributor.completeReference(element, reference, filter, false, true, parameters.getParameters(), null);
|
||||
for (final LookupElement item : base) {
|
||||
addSingleArrayElementAccess(element, item, parameters, result);
|
||||
}
|
||||
@@ -177,7 +180,7 @@ public class ReferenceExpressionCompletionContributor {
|
||||
public boolean isClassAcceptable(Class hintClass) {
|
||||
return true;
|
||||
}
|
||||
}), false, parameters.getParameters());
|
||||
}), false, true, parameters.getParameters(), null);
|
||||
for (LookupElement lookupElement : elements) {
|
||||
if (lookupElement.getObject() instanceof PsiMethod) {
|
||||
final JavaMethodCallElement item = lookupElement.as(JavaMethodCallElement.CLASS_CONDITION_KEY);
|
||||
@@ -419,32 +422,43 @@ public class ReferenceExpressionCompletionContributor {
|
||||
final Consumer<LookupElement> result,
|
||||
PsiType qualifierType,
|
||||
final PsiType expectedType, JavaSmartCompletionParameters parameters) throws IncorrectOperationException {
|
||||
final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(place.getProject());
|
||||
PsiType varType = qualifierType;
|
||||
if (varType instanceof PsiEllipsisType) {
|
||||
varType = ((PsiEllipsisType)varType).getComponentType();
|
||||
}
|
||||
if (varType instanceof PsiWildcardType || varType instanceof PsiCapturedWildcardType) {
|
||||
varType = TypeConversionUtil.erasure(expectedType);
|
||||
}
|
||||
|
||||
final String typeText = varType.getCanonicalText();
|
||||
final JavaCodeFragment block = factory.createCodeBlockCodeFragment(typeText + " xxx;xxx.xxx;", place, false);
|
||||
final PsiElement secondChild = block.getChildren()[1];
|
||||
if (!(secondChild instanceof PsiExpressionStatement)) {
|
||||
LOG.error(typeText + " of " + varType.getClass());
|
||||
}
|
||||
final PsiExpressionStatement expressionStatement = (PsiExpressionStatement)secondChild;
|
||||
final PsiReferenceExpression mockRef = (PsiReferenceExpression) expressionStatement.getExpression();
|
||||
final PsiReferenceExpression mockRef = createMockReference(place, qualifierType, qualifierItem);
|
||||
|
||||
final ElementFilter filter = getReferenceFilter(place, true);
|
||||
for (final LookupElement item : completeFinalReference(place, mockRef, filter, parameters)) {
|
||||
if (shoudChain(place, varType, expectedType, item)) {
|
||||
if (shoudChain(place, qualifierType, expectedType, item)) {
|
||||
result.consume(new JavaChainLookupElement(qualifierItem, item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static PsiReferenceExpression createMockReference(final PsiElement place, @NotNull PsiType qualifierType, LookupElement qualifierItem) {
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(place.getProject());
|
||||
if (qualifierItem.getObject() instanceof PsiClass) {
|
||||
return (PsiReferenceExpression)factory
|
||||
.createExpressionFromText(((PsiClass)qualifierItem.getObject()).getQualifiedName() + ".xxx", place);
|
||||
}
|
||||
|
||||
return (PsiReferenceExpression) factory.createExpressionFromText("xxx.xxx", createContextWithXxxVariable(place, qualifierType));
|
||||
}
|
||||
|
||||
public static FakePsiElement createContextWithXxxVariable(final PsiElement place, final PsiType varType) {
|
||||
return new FakePsiElement() {
|
||||
@Override
|
||||
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
PsiElement lastParent,
|
||||
@NotNull PsiElement place) {
|
||||
return processor.execute(new LightVariableBuilder("xxx", varType, place), ResolveState.initial());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getParent() {
|
||||
return place;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean shoudChain(PsiElement element, PsiType qualifierType, PsiType expectedType, LookupElement item) {
|
||||
if (item.getObject() instanceof PsiMethod) {
|
||||
final PsiMethod method = (PsiMethod)item.getObject();
|
||||
|
||||
@@ -640,9 +640,9 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
|
||||
private static boolean isEnumValuesMethodUsed(PsiMember member, ProgressIndicator progress, GlobalUsageHelper helper) {
|
||||
final PsiClassImpl containingClass = (PsiClassImpl)member.getContainingClass();
|
||||
if (containingClass == null) return true;
|
||||
final PsiMethod valuesMethod = containingClass.getValuesMethod();
|
||||
final PsiClass containingClass = member.getContainingClass();
|
||||
if (containingClass == null || !(containingClass instanceof PsiClassImpl)) return true;
|
||||
final PsiMethod valuesMethod = ((PsiClassImpl)containingClass).getValuesMethod();
|
||||
if (valuesMethod == null) return true;
|
||||
return isMethodReferenced(valuesMethod, progress, helper);
|
||||
}
|
||||
|
||||
+20
-7
@@ -89,7 +89,7 @@ public class CreateClassFromNewFix extends CreateFromUsageBaseFix {
|
||||
setupInheritance(newExpression, aClass);
|
||||
|
||||
PsiExpressionList argList = newExpression.getArgumentList();
|
||||
Project project = aClass.getProject();
|
||||
final Project project = aClass.getProject();
|
||||
if (argList != null && argList.getExpressions().length > 0) {
|
||||
PsiMethod constructor = elementFactory.createConstructor();
|
||||
constructor = (PsiMethod) aClass.add(constructor);
|
||||
@@ -101,14 +101,27 @@ public class CreateClassFromNewFix extends CreateFromUsageBaseFix {
|
||||
|
||||
getReferenceElement(newExpression).bindToElement(aClass);
|
||||
aClass = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(aClass);
|
||||
Template template = templateBuilder.buildTemplate();
|
||||
final Template template = templateBuilder.buildTemplate();
|
||||
template.setToReformat(true);
|
||||
|
||||
Editor editor = positionCursor(project, aClass.getContainingFile(), aClass);
|
||||
TextRange textRange = aClass.getTextRange();
|
||||
editor.getDocument().deleteString(textRange.getStartOffset(), textRange.getEndOffset());
|
||||
|
||||
startTemplate(editor, template, project, null, getText());
|
||||
final Editor editor = positionCursor(project, aClass.getContainingFile(), aClass);
|
||||
final TextRange textRange = aClass.getTextRange();
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
new WriteCommandAction(project, getText(), getText()) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
editor.getDocument().deleteString(textRange.getStartOffset(), textRange.getEndOffset());
|
||||
}
|
||||
}.execute();
|
||||
startTemplate(editor, template, project, null, getText());
|
||||
}
|
||||
};
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
runnable.run();
|
||||
} else {
|
||||
ApplicationManager.getApplication().invokeLater(runnable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
positionCursor(project, aClass.getContainingFile(), aClass);
|
||||
|
||||
+5
@@ -52,6 +52,11 @@ public class CreateFieldFromUsageFix extends CreateVarFromUsageFix {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canBeTargetClass(PsiClass psiClass) {
|
||||
return super.canBeTargetClass(psiClass) && !psiClass.isInterface() && !psiClass.isAnnotationType();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invokeImpl(final PsiClass targetClass) {
|
||||
final Project project = myReferenceExpression.getProject();
|
||||
|
||||
+29
-4
@@ -130,7 +130,12 @@ public abstract class CreateFromUsageBaseFix extends BaseIntentionAction {
|
||||
int index = list.getSelectedIndex();
|
||||
if (index < 0) return;
|
||||
final PsiClass aClass = (PsiClass) list.getSelectedValue();
|
||||
doInvoke(project, aClass);
|
||||
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doInvoke(project, aClass);
|
||||
}
|
||||
}, getText(), null);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -321,10 +326,15 @@ public abstract class CreateFromUsageBaseFix extends BaseIntentionAction {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if (!allowOuterClasses ||
|
||||
!isAllowOuterTargetClass() ||
|
||||
ApplicationManager.getApplication().isUnitTestMode())
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return Collections.singletonList(psiClass);
|
||||
}
|
||||
|
||||
if (!allowOuterClasses || !isAllowOuterTargetClass()) {
|
||||
final ArrayList<PsiClass> classes = new ArrayList<PsiClass>();
|
||||
collectSupers(psiClass, classes);
|
||||
return classes;
|
||||
}
|
||||
|
||||
List<PsiClass> result = new ArrayList<PsiClass>();
|
||||
|
||||
@@ -337,6 +347,21 @@ public abstract class CreateFromUsageBaseFix extends BaseIntentionAction {
|
||||
}
|
||||
}
|
||||
|
||||
private void collectSupers(PsiClass psiClass, ArrayList<PsiClass> classes) {
|
||||
classes.add(psiClass);
|
||||
|
||||
final PsiClass[] supers = psiClass.getSupers();
|
||||
for (PsiClass aSuper : supers) {
|
||||
if (canBeTargetClass(aSuper)) {
|
||||
collectSupers(aSuper, classes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canBeTargetClass(PsiClass psiClass) {
|
||||
return psiClass.getManager().isInProject(psiClass);
|
||||
}
|
||||
|
||||
protected static void startTemplate (@NotNull Editor editor, final Template template, @NotNull final Project project) {
|
||||
startTemplate(editor, template, project, null);
|
||||
}
|
||||
|
||||
+1
@@ -122,6 +122,7 @@ public class PullAsAbstractUpFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
}
|
||||
|
||||
private static void pullUp(PsiMethod method, PsiClass containingClass, PsiClass baseClass) {
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(baseClass.getContainingFile())) return;
|
||||
final MemberInfo memberInfo = new MemberInfo(method);
|
||||
memberInfo.setChecked(true);
|
||||
memberInfo.setToAbstract(true);
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.filters.ClassFilter;
|
||||
import com.intellij.psi.filters.position.SuperParentFilter;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
@@ -146,6 +147,11 @@ public class JavaTypedHandler extends TypedHandlerDelegate {
|
||||
handleAfterJavaLT(editor, JavaTokenType.LT, JavaTokenType.GT, INVALID_INSIDE_REFERENCE);
|
||||
return Result.STOP;
|
||||
}
|
||||
else if (c == ':') {
|
||||
if (autoIndentCase(editor, project, file)) {
|
||||
return Result.STOP;
|
||||
}
|
||||
}
|
||||
return Result.CONTINUE;
|
||||
}
|
||||
|
||||
@@ -283,4 +289,18 @@ public class JavaTypedHandler extends TypedHandlerDelegate {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean autoIndentCase(Editor editor, Project project, PsiFile file) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
|
||||
PsiElement currElement = file.findElementAt(offset - 1);
|
||||
if (currElement != null) {
|
||||
PsiElement parent = currElement.getParent();
|
||||
if (parent != null && parent instanceof PsiSwitchLabelStatement) {
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, parent.getTextOffset());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -34,6 +34,8 @@ import gnu.trove.TIntProcedure;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
@@ -104,7 +106,7 @@ public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction
|
||||
}
|
||||
importList.add(importStaticStatement);
|
||||
|
||||
PsiFile[] roots = file.getPsiRoots();
|
||||
List<PsiFile> roots = file.getViewProvider().getAllFiles();
|
||||
for (final PsiFile root : roots) {
|
||||
PsiElement copy = root.copy();
|
||||
final PsiManager manager = root.getManager();
|
||||
|
||||
@@ -40,10 +40,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
@@ -162,11 +159,25 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{
|
||||
Collection<InspectionTool> suppressedTools = new THashSet<InspectionTool>();
|
||||
InspectionTool[] tools = getInspectionTools(psiElement, manager);
|
||||
for (Collection<String> ids : suppressedScopes.values()) {
|
||||
for (String id : ids) {
|
||||
String shortName = id.trim();
|
||||
for (Iterator<String> iterator = ids.iterator(); iterator.hasNext(); ) {
|
||||
final String shortName = iterator.next().trim();
|
||||
for (InspectionTool tool : tools) {
|
||||
if (tool instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)tool).getTool().getID().equals(shortName) || tool.getShortName().equals(shortName)) {
|
||||
suppressedTools.add(tool);
|
||||
if (tool instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)tool).getTool().getID().equals(shortName)) {
|
||||
if (!((LocalInspectionToolWrapper)tool).isUnfair()) {
|
||||
suppressedTools.add(tool);
|
||||
} else {
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (tool.getShortName().equals(shortName)) {
|
||||
//ignore global unused as it won't be checked anyway
|
||||
if (!(tool instanceof LocalInspectionToolWrapper) && !(tool instanceof GlobalInspectionToolWrapper)) {
|
||||
iterator.remove();
|
||||
break;
|
||||
} else {
|
||||
suppressedTools.add(tool);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ public class EntryPointsManagerImpl implements PersistentStateComponent<Element>
|
||||
myAddNonJavaEntries = addNonJavaEntries;
|
||||
}
|
||||
|
||||
public boolean isEntryPoint(PsiModifierListOwner element) {
|
||||
public boolean isEntryPoint(@NotNull PsiModifierListOwner element) {
|
||||
return AnnotationUtil.isAnnotated(element, ADDITIONAL_ANNOTATIONS) ||
|
||||
AnnotationUtil.isAnnotated(element, getAdditionalAnnotations());
|
||||
}
|
||||
|
||||
+3
-1
@@ -74,7 +74,9 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool {
|
||||
if ((refMethod.isAbstract() || refMethod.getOwnerClass().isInterface()) && refMethod.getDerivedMethods().isEmpty()) return null;
|
||||
|
||||
if (RefUtil.isEntryPoint(refMethod)) return null;
|
||||
if (EntryPointsManagerImpl.getInstance(manager.getProject()).isEntryPoint(refMethod.getElement())) return null;
|
||||
|
||||
final PsiModifierListOwner element = refMethod.getElement();
|
||||
if (element != null && EntryPointsManagerImpl.getInstance(manager.getProject()).isEntryPoint(element)) return null;
|
||||
|
||||
if (refMethod.isAppMain()) return null;
|
||||
|
||||
|
||||
+22
-3
@@ -22,18 +22,37 @@ import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.search.UsageSearchContext;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class JavaFilterLexer extends BaseFilterLexer {
|
||||
private static final TokenSet ourSkipWordsScanSet = TokenSet.orSet(
|
||||
TokenSet.create(
|
||||
JavaTokenType.WHITE_SPACE,
|
||||
JavaTokenType.LPARENTH,
|
||||
JavaTokenType.RPARENTH,
|
||||
JavaTokenType.LBRACE,
|
||||
JavaTokenType.RBRACE,
|
||||
JavaTokenType.LBRACKET,
|
||||
JavaTokenType.RBRACKET,
|
||||
JavaTokenType.SEMICOLON,
|
||||
JavaTokenType.COMMA,
|
||||
JavaTokenType.DOT,
|
||||
JavaTokenType.ELLIPSIS,
|
||||
JavaTokenType.AT
|
||||
),
|
||||
JavaTokenType.OPERATION_BIT_SET
|
||||
);
|
||||
|
||||
public JavaFilterLexer(final Lexer originalLexer, final OccurrenceConsumer table) {
|
||||
super(originalLexer, table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void advance() {
|
||||
final IElementType tokenType = getDelegate().getTokenType();
|
||||
final IElementType tokenType = myDelegate.getTokenType();
|
||||
|
||||
if (tokenType == JavaTokenType.IDENTIFIER
|
||||
|| tokenType == JavaTokenType.LONG_LITERAL
|
||||
@@ -48,10 +67,10 @@ public class JavaFilterLexer extends BaseFilterLexer {
|
||||
scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
|
||||
advanceTodoItemCountsInToken();
|
||||
}
|
||||
else {
|
||||
else if (!ourSkipWordsScanSet.contains(tokenType)) {
|
||||
scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false);
|
||||
}
|
||||
|
||||
getDelegate().advance();
|
||||
myDelegate.advance();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-4
@@ -15,13 +15,11 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.cache.impl.idCache;
|
||||
|
||||
import com.intellij.lexer.FilterLexer;
|
||||
import com.intellij.lexer.JavaLexer;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
|
||||
import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer;
|
||||
import com.intellij.psi.impl.source.tree.StdTokenSets;
|
||||
|
||||
public class JavaIdIndexer extends LexerBasedIdIndexer {
|
||||
@Override
|
||||
@@ -31,7 +29,6 @@ public class JavaIdIndexer extends LexerBasedIdIndexer {
|
||||
|
||||
public static Lexer createIndexingLexer(OccurrenceConsumer consumer) {
|
||||
final JavaLexer javaLexer = new JavaLexer(LanguageLevel.JDK_1_3);
|
||||
final JavaFilterLexer filterLexer = new JavaFilterLexer(javaLexer, consumer);
|
||||
return new FilterLexer(filterLexer, new FilterLexer.SetFilter(StdTokenSets.WHITE_SPACE_OR_COMMENT_BIT_SET));
|
||||
return new JavaFilterLexer(javaLexer, consumer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ public class ImportHelper{
|
||||
PsiFile context) {
|
||||
String packageName = file.getPackageName();
|
||||
|
||||
final PsiElement[] roots = file.getPsiRoots();
|
||||
final List<PsiFile> roots = file.getViewProvider().getAllFiles();
|
||||
for (PsiElement root : roots) {
|
||||
addNamesToImport(names, comments, root, packageName, context);
|
||||
}
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
|
||||
}
|
||||
else {
|
||||
redundants = allImports;
|
||||
final PsiElement[] roots = file.getPsiRoots();
|
||||
final List<PsiFile> roots = file.getViewProvider().getAllFiles();
|
||||
for (PsiElement root : roots) {
|
||||
root.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class CopyClassesHandler extends CopyHandlerDelegateBase {
|
||||
@@ -310,13 +311,14 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
final PsiFile[] createdFiles = new PsiFile[fileToClasses.size()];
|
||||
final List<PsiFile> createdFiles = new ArrayList<PsiFile>(fileToClasses.size());
|
||||
int foIdx = 0;
|
||||
List<PsiFile> files = new ArrayList<PsiFile>();
|
||||
for (final Map.Entry<PsiFile, PsiClass[]> entry : fileToClasses.entrySet()) {
|
||||
final PsiFile createdFile = copy(entry.getKey(), targetDirectory, copyClassName, map == null ? null : map.get(entry.getKey()));
|
||||
final PsiClass[] sources = entry.getValue();
|
||||
|
||||
if (createdFile instanceof PsiClassOwner) {
|
||||
final PsiFile psiFile = entry.getKey();
|
||||
if (psiFile instanceof PsiClassOwner) {
|
||||
final PsiFile createdFile = copy(psiFile, targetDirectory, copyClassName, map == null ? null : map.get(psiFile));
|
||||
final PsiClass[] sources = entry.getValue();
|
||||
for (final PsiClass destination : ((PsiClassOwner)createdFile).getClasses()) {
|
||||
if (destination instanceof SyntheticElement) {
|
||||
continue;
|
||||
@@ -331,9 +333,24 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase {
|
||||
destination.delete();
|
||||
}
|
||||
}
|
||||
createdFiles.add(createdFile);
|
||||
} else {
|
||||
files.add(psiFile);
|
||||
}
|
||||
}
|
||||
|
||||
createdFiles[foIdx++] = createdFile;
|
||||
int[] choice = files.size() > 1 ? new int[]{-1} : null;
|
||||
for (PsiFile file : files) {
|
||||
try {
|
||||
final PsiFile fileCopy =
|
||||
CopyFilesOrDirectoriesHandler.copyToDirectory(file, getNewFileName(file, copyClassName), targetDirectory, choice);
|
||||
if (fileCopy != null) {
|
||||
createdFiles.add(fileCopy);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IncorrectOperationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
final Set<PsiElement> rebindExpressions = new HashSet<PsiElement>();
|
||||
@@ -354,8 +371,8 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase {
|
||||
for (PsiElement expression : rebindExpressions) {
|
||||
codeStyleManager.shortenClassReferences(expression);
|
||||
}
|
||||
new OptimizeImportsProcessor(project, createdFiles, null).run();
|
||||
return newElement != null ? newElement : createdFiles.length > 0 ? createdFiles[0] : null;
|
||||
new OptimizeImportsProcessor(project, createdFiles.toArray(new PsiFile[createdFiles.size()]), null).run();
|
||||
return newElement != null ? newElement : createdFiles.size() > 0 ? createdFiles.get(0) : null;
|
||||
}
|
||||
|
||||
private static PsiFile copy(@NotNull PsiFile file, PsiDirectory directory, String name, String relativePath) {
|
||||
|
||||
@@ -15,15 +15,14 @@
|
||||
*/
|
||||
package com.intellij.refactoring.extractInterface;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.SmartPointerManager;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.turnRefsToSuper.TurnRefsToSuperProcessor;
|
||||
import com.intellij.refactoring.ui.YesNoPreviewUsagesDialog;
|
||||
|
||||
@@ -36,7 +35,7 @@ public class ExtractClassUtil {
|
||||
final SmartPsiElementPointer interfacePointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(aSuperClass);
|
||||
final PsiElement classElement = classPointer.getElement();
|
||||
final PsiElement interfaceElement = interfacePointer.getElement();
|
||||
if (classElement instanceof PsiClass && interfaceElement instanceof PsiClass) {
|
||||
if (classElement instanceof PsiClass && classElement.isValid() && interfaceElement instanceof PsiClass && interfaceElement.isValid()) {
|
||||
final PsiClass superClass = (PsiClass) interfaceElement;
|
||||
String superClassName = superClass.getName();
|
||||
String className = ((PsiClass) classElement).getName();
|
||||
@@ -56,7 +55,7 @@ public class ExtractClassUtil {
|
||||
final boolean isPreviewUsages = dialog.isPreviewUsages();
|
||||
JavaRefactoringSettings.getInstance().EXTRACT_INTERFACE_PREVIEW_USAGES = isPreviewUsages;
|
||||
TurnRefsToSuperProcessor processor =
|
||||
new TurnRefsToSuperProcessor(project, (PsiClass) classElement, (PsiClass) interfaceElement, true);
|
||||
new TurnRefsToSuperProcessor(project, (PsiClass) classElement, superClass, true);
|
||||
processor.setPreviewUsages(isPreviewUsages);
|
||||
processor.run();
|
||||
}
|
||||
|
||||
@@ -509,6 +509,11 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
myVariableDatum[i] = myInputVariables.getInputVariables().get(i);
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void doNotPassParameter(int i) {
|
||||
myVariableDatum[i].passAsParameter = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked in command and in atomic action
|
||||
@@ -760,6 +765,7 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
|
||||
for (int i = 0, length = myVariableDatum.length; i < length; i++) {
|
||||
ParameterTablePanel.VariableData data = myVariableDatum[i];
|
||||
if (!data.passAsParameter) continue;
|
||||
final PsiVariable variable = data.variable;
|
||||
final PsiParameter psiParameter = newMethod.getParameterList().getParameters()[i];
|
||||
if (!TypeConversionUtil.isAssignable(variable.getType(), psiParameter.getType())) {
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ public abstract class JavaExtractSuperBaseDialog extends ExtractSuperBaseDialog<
|
||||
protected void preparePackage() throws OperationFailedException {
|
||||
final String targetPackageName = getTargetPackageName();
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(myProject);
|
||||
if (!psiFacade.getNameHelper().isIdentifier(targetPackageName)) {
|
||||
if (!psiFacade.getNameHelper().isQualifiedName(targetPackageName)) {
|
||||
throw new OperationFailedException("Invalid package name: " + targetPackageName);
|
||||
}
|
||||
final PsiPackage aPackage = psiFacade.findPackage(targetPackageName);
|
||||
|
||||
+2
-2
@@ -689,11 +689,11 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
InitializationPlace initializerPlace = mySettings.getInitializerPlace();
|
||||
final PsiLocalVariable localVariable = mySettings.getLocalVariable();
|
||||
final boolean deleteLocalVariable = mySettings.isDeleteLocalVariable();
|
||||
@Nullable PsiExpression initializer;
|
||||
@Nullable PsiExpression initializer = null;
|
||||
if (localVariable != null) {
|
||||
initializer = localVariable.getInitializer();
|
||||
}
|
||||
else {
|
||||
else if (!(mySelectedExpr instanceof PsiReferenceExpression && ((PsiReferenceExpression)mySelectedExpr).resolve() == null)){
|
||||
initializer = mySelectedExpr;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -45,6 +45,7 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -85,8 +86,10 @@ public class JavaVariableInplaceIntroducer extends InplaceVariableIntroducer<Psi
|
||||
myPointer = declarationStatement != null ? SmartPointerManager.getInstance(project).createSmartPsiElementPointer(declarationStatement) : null;
|
||||
editor.putUserData(ReassignVariableUtil.DECLARATION_KEY, myPointer);
|
||||
if (occurrenceMarkers != null) {
|
||||
final ArrayList<RangeMarker> rangeMarkers = new ArrayList<RangeMarker>(occurrenceMarkers);
|
||||
rangeMarkers.add(exprMarker);
|
||||
editor.putUserData(ReassignVariableUtil.OCCURRENCES_KEY,
|
||||
occurrenceMarkers.toArray(new RangeMarker[occurrenceMarkers.size()]));
|
||||
rangeMarkers.toArray(new RangeMarker[rangeMarkers.size()]));
|
||||
}
|
||||
myExpression = expression;
|
||||
final PsiType defaultType = elementToRename.getType();
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class MultipleRootsMoveDestination extends AutocreatingMoveDestination {
|
||||
|
||||
|
||||
public PsiDirectory getTargetDirectory(PsiDirectory source) throws IncorrectOperationException {
|
||||
if (JavaDirectoryService.getInstance().isSourceRoot(source)) return null;
|
||||
//if (JavaDirectoryService.getInstance().isSourceRoot(source)) return null;
|
||||
return getOrCreateDirectoryForSource(source.getVirtualFile());
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -24,6 +24,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.file.JavaDirectoryServiceImpl;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.refactoring.move.MoveCallback;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -76,9 +77,12 @@ public class JavaMoveFilesOrDirectoriesHandler extends MoveFilesOrDirectoriesHan
|
||||
@Override
|
||||
protected void run(Result<PsiElement[]> result) throws Throwable {
|
||||
final List<PsiElement> adjustedElements = new ArrayList<PsiElement>();
|
||||
for (PsiElement element : elements) {
|
||||
for (int i = 0, length = elements.length; i < length; i++) {
|
||||
PsiElement element = elements[i];
|
||||
if (element instanceof PsiClass) {
|
||||
final PsiFile containingFile = obtainContainingFile(element, elements);
|
||||
final PsiClass topLevelClass = PsiUtil.getTopLevelClass(element);
|
||||
elements[i] = topLevelClass;
|
||||
final PsiFile containingFile = obtainContainingFile(topLevelClass, elements);
|
||||
if (containingFile != null && !adjustedElements.contains(containingFile)) {
|
||||
adjustedElements.add(containingFile);
|
||||
}
|
||||
|
||||
@@ -31,10 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -45,6 +42,8 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
|
||||
private final CoreLocalFileSystem myLocalFileSystem;
|
||||
private final CoreJarFileSystem myJarFileSystem;
|
||||
private final List<File> myClasspath = new ArrayList<File>();
|
||||
private VirtualFile[] myClasspathRoots = null;
|
||||
|
||||
private final PsiManager myPsiManager;
|
||||
|
||||
public CoreJavaFileManager(PsiManager psiManager, CoreLocalFileSystem localFileSystem, CoreJarFileSystem jarFileSystem) {
|
||||
@@ -53,6 +52,35 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
|
||||
myJarFileSystem = jarFileSystem;
|
||||
}
|
||||
|
||||
private VirtualFile[] roots() {
|
||||
VirtualFile[] answer = myClasspathRoots;
|
||||
|
||||
if (answer == null) {
|
||||
ArrayList<VirtualFile> answerList = new ArrayList<VirtualFile>(myClasspath.size());
|
||||
for (File root : myClasspath) {
|
||||
VirtualFile rootVfs = calcRoot(root);
|
||||
if (rootVfs != null) {
|
||||
answerList.add(rootVfs);
|
||||
}
|
||||
}
|
||||
|
||||
answer = answerList.toArray(new VirtualFile[answerList.size()]);
|
||||
myClasspathRoots = answer;
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private VirtualFile calcRoot(File root) {
|
||||
if (root.isFile()) {
|
||||
return myJarFileSystem.findFileByPath(root.getPath() + "!/");
|
||||
}
|
||||
else {
|
||||
return myLocalFileSystem.findFileByPath(root.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiPackage findPackage(@NotNull String packageName) {
|
||||
final List<VirtualFile> files = findDirectoriesByPackageName(packageName);
|
||||
@@ -65,8 +93,8 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
|
||||
private List<VirtualFile> findDirectoriesByPackageName(String packageName) {
|
||||
List<VirtualFile> result = new ArrayList<VirtualFile>();
|
||||
String dirName = packageName.replace(".", "/");
|
||||
for (File file : myClasspath) {
|
||||
VirtualFile classDir = findUnderClasspathEntry(file, dirName);
|
||||
for (VirtualFile root : roots()) {
|
||||
VirtualFile classDir = root.findFileByRelativePath(dirName);
|
||||
if (classDir != null) {
|
||||
result.add(classDir);
|
||||
}
|
||||
@@ -85,22 +113,6 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private VirtualFile findUnderClasspathEntry(File classpathEntry, String relativeName) {
|
||||
VirtualFile root = findRootInClassPathEntry(classpathEntry);
|
||||
return root != null ? root.findFileByRelativePath(relativeName) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private VirtualFile findRootInClassPathEntry(File classpathEntry) {
|
||||
if (classpathEntry.isFile()) {
|
||||
return myJarFileSystem.findFileByPath(classpathEntry.getPath() + "!/");
|
||||
}
|
||||
else {
|
||||
return myLocalFileSystem.findFileByPath(classpathEntry.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile[] getDirectoriesByPackageName(@NotNull String packageName, boolean includeLibrarySources) {
|
||||
@@ -114,8 +126,8 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
|
||||
|
||||
@Override
|
||||
public PsiClass findClass(@NotNull String qName, @NotNull GlobalSearchScope scope) {
|
||||
for (File file : myClasspath) {
|
||||
final PsiClass psiClass = findClassInClasspathEntry(qName, file);
|
||||
for (VirtualFile root : roots()) {
|
||||
final PsiClass psiClass = findClassInClasspathRoot(qName, root, myPsiManager);
|
||||
if (psiClass != null) {
|
||||
return psiClass;
|
||||
}
|
||||
@@ -123,14 +135,6 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiClass findClassInClasspathEntry(String qName, File rootEntry) {
|
||||
VirtualFile root = findRootInClassPathEntry(rootEntry);
|
||||
if (root == null) return null;
|
||||
|
||||
return findClassInClasspathRoot(qName, root, myPsiManager);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiClass findClassInClasspathRoot(String qName, VirtualFile root, PsiManager psiManager) {
|
||||
String pathRest = qName;
|
||||
@@ -201,8 +205,8 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
|
||||
@Override
|
||||
public PsiClass[] findClasses(@NotNull String qName, @NotNull GlobalSearchScope scope) {
|
||||
List<PsiClass> result = new ArrayList<PsiClass>();
|
||||
for (File file : myClasspath) {
|
||||
final PsiClass psiClass = findClassInClasspathEntry(qName, file);
|
||||
for (VirtualFile file : roots()) {
|
||||
final PsiClass psiClass = findClassInClasspathRoot(qName, file, myPsiManager);
|
||||
if (psiClass != null) {
|
||||
result.add(psiClass);
|
||||
}
|
||||
@@ -221,5 +225,6 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
|
||||
|
||||
public void addToClasspath(File path) {
|
||||
myClasspath.add(path);
|
||||
myClasspathRoots = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class JavaLexer extends LexerBase {
|
||||
|
||||
@Override
|
||||
public final IElementType getTokenType() {
|
||||
locateToken();
|
||||
if (myTokenType == null) _locateToken();
|
||||
|
||||
return myTokenType;
|
||||
}
|
||||
@@ -208,22 +208,17 @@ public class JavaLexer extends LexerBase {
|
||||
|
||||
@Override
|
||||
public final int getTokenEnd() {
|
||||
locateToken();
|
||||
if (myTokenType == null) _locateToken();
|
||||
return myTokenEndOffset;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void advance() {
|
||||
locateToken();
|
||||
if (myTokenType == null) _locateToken();
|
||||
myTokenType = null;
|
||||
}
|
||||
|
||||
protected final void locateToken() {
|
||||
if (myTokenType != null) return;
|
||||
_locateToken();
|
||||
}
|
||||
|
||||
private void _locateToken() {
|
||||
if (myTokenEndOffset == myBufferEndOffset) {
|
||||
myTokenType = null;
|
||||
|
||||
@@ -23,10 +23,11 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.ContentBasedFileSubstitutor;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassFileViewProviderFactory implements FileViewProviderFactory{
|
||||
@Override
|
||||
public FileViewProvider createFileViewProvider(final VirtualFile file, final Language language, final PsiManager manager, final boolean physical) {
|
||||
public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final Language language, @NotNull final PsiManager manager, final boolean physical) {
|
||||
// Define language for compiled file
|
||||
final ContentBasedFileSubstitutor[] processors = Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME);
|
||||
for (ContentBasedFileSubstitutor processor : processors) {
|
||||
|
||||
@@ -350,8 +350,13 @@ public class StubBuildingVisitor<T> implements ClassVisitor {
|
||||
final String desc,
|
||||
final String signature,
|
||||
final String[] exceptions) {
|
||||
if ((access & Opcodes.ACC_SYNTHETIC) != 0) return null;
|
||||
if ((access & Opcodes.ACC_BRIDGE) != 0) return null;
|
||||
boolean isSynthetic = (access & Opcodes.ACC_SYNTHETIC) != 0;
|
||||
|
||||
// JLS 13.1 says: Any constructs introduced by the compiler that do not have a corresponding construct in the source code
|
||||
// must be marked as synthetic, except for default constructors and the class initialization method.
|
||||
// However Scala compiler erroneously generates ACC_BRIDGE instead of ACC_SYNTHETIC flag for in-trait implementation delegation. See IDEA-78649
|
||||
if (isSynthetic) return null;
|
||||
|
||||
if (SYNTHETIC_CLINIT_METHOD.equals(name)) return null;
|
||||
|
||||
boolean isDeprecated = (access & Opcodes.ACC_DEPRECATED) != 0;
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandLineWrapper {
|
||||
private static final String PREFIX = "-D";
|
||||
|
||||
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException,
|
||||
IllegalAccessException, IOException, InstantiationException {
|
||||
@@ -54,9 +55,41 @@ public class CommandLineWrapper {
|
||||
reader.close();
|
||||
}
|
||||
file.delete();
|
||||
String progClass = args[1];
|
||||
String[] progArgs = new String[args.length - 2];
|
||||
System.arraycopy(args, 2, progArgs, 0, progArgs.length);
|
||||
|
||||
int startArgsIdx = 2;
|
||||
if (args[1].equals("@vm_params")) {
|
||||
startArgsIdx = 4;
|
||||
final File vmParamsFile = new File(args[2]);
|
||||
final BufferedReader vmParamsReader = new BufferedReader(new FileReader(vmParamsFile));
|
||||
try {
|
||||
while (vmParamsReader.ready()) {
|
||||
final String vmParam = vmParamsReader.readLine().trim();
|
||||
final int eqIdx = vmParam.indexOf("=");
|
||||
String vmParamName;
|
||||
String vmParamValue;
|
||||
|
||||
if (eqIdx > -1 && eqIdx < vmParam.length() - 1) {
|
||||
vmParamName = vmParam.substring(0, eqIdx);
|
||||
vmParamValue = vmParam.substring(eqIdx + 1);
|
||||
} else {
|
||||
vmParamName = vmParam;
|
||||
vmParamValue = "";
|
||||
}
|
||||
vmParamName = vmParamName.trim();
|
||||
if (vmParamName.startsWith(PREFIX)) {
|
||||
vmParamName = vmParamName.substring(PREFIX.length());
|
||||
System.setProperty(vmParamName, vmParamValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
vmParamsReader.close();
|
||||
}
|
||||
vmParamsFile.delete();
|
||||
}
|
||||
String progClass = args[startArgsIdx - 1];
|
||||
String[] progArgs = new String[args.length - startArgsIdx];
|
||||
System.arraycopy(args, startArgsIdx, progArgs, 0, progArgs.length);
|
||||
ClassLoader loader = new URLClassLoader((URL[])urls.toArray(new URL[urls.size()]), null);
|
||||
final String classloader = System.getProperty("java.system.class.loader");
|
||||
if (classloader != null) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Fest {
|
||||
public static void main(String[] args) {
|
||||
String f = "";
|
||||
<selection>System.out.println(f);</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Fest {
|
||||
public static void main(String[] args) {
|
||||
String f = "";
|
||||
newMethod();
|
||||
}
|
||||
|
||||
private static void newMethod() {
|
||||
String f = ;
|
||||
System.out.println(f);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public final ArrayList arrayList;
|
||||
|
||||
public Test()
|
||||
{
|
||||
arrayList = new ArrayList();
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public Test()
|
||||
{
|
||||
array<caret>List = new ArrayList();
|
||||
}
|
||||
|
||||
}
|
||||
+18
-1
@@ -750,7 +750,6 @@ class Foo {
|
||||
joinCommit()
|
||||
myFixture.type 'a.'
|
||||
myFixture.checkResult(" class Foo { { int iteraaa; iteraaa.<caret> } } ")
|
||||
assert !lookup
|
||||
}
|
||||
|
||||
public void testRestartWithInvisibleLookup() {
|
||||
@@ -1216,4 +1215,22 @@ class Foo {{
|
||||
}
|
||||
}
|
||||
|
||||
public void testReturnLParen() {
|
||||
myFixture.configureByText 'a.java', 'class Foo { int foo() { <caret> }}'
|
||||
type 're('
|
||||
myFixture.checkResult 'class Foo { int foo() { re(<caret>) }}'
|
||||
}
|
||||
|
||||
public void testAmbiguousClassQualifier() {
|
||||
myFixture.addClass("package foo; public class Util { public static void foo() {} }")
|
||||
myFixture.addClass("package bar; public class Util { public static void bar() {} }")
|
||||
myFixture.configureByText 'a.java', 'class Foo {{ <caret> }}'
|
||||
type 'Util.'
|
||||
assert myFixture.lookupElementStrings == ['Util.bar', 'Util.foo']
|
||||
type 'fo\n'
|
||||
myFixture.checkResult '''import foo.Util;
|
||||
|
||||
class Foo {{ Util.foo();<caret> }}'''
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public abstract class JavaParsingTestCase extends ParsingTestCase {
|
||||
myFile = createPsiFile(name, text, parser);
|
||||
myFile.putUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY, myLanguageLevel);
|
||||
try {
|
||||
checkResult(name + ".txt", myFile);
|
||||
checkResult(name, myFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -9,6 +9,7 @@ import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.refactoring.extractMethod.ExtractMethodHandler;
|
||||
import com.intellij.refactoring.extractMethod.ExtractMethodProcessor;
|
||||
import com.intellij.refactoring.extractMethod.PrepareFailedException;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
|
||||
@@ -500,6 +501,16 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
public void testRedundantCast() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDisabledParam() throws Exception {
|
||||
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
settings.ELSE_ON_NEW_LINE = true;
|
||||
settings.CATCH_ON_NEW_LINE = myCatchOnNewLine;
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
boolean success = performExtractMethod(true, true, getEditor(), getFile(), getProject(), false, 0);
|
||||
assertTrue(success);
|
||||
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
private void doPrepareErrorTest(final String expectedMessage) throws Exception {
|
||||
String expectedError = null;
|
||||
@@ -545,6 +556,17 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
public static boolean performExtractMethod(boolean doRefactor, boolean replaceAllDuplicates, Editor editor, PsiFile file, Project project,
|
||||
final boolean extractChainedConstructor)
|
||||
throws PrepareFailedException, IncorrectOperationException {
|
||||
return performExtractMethod(doRefactor, replaceAllDuplicates, editor, file, project, extractChainedConstructor, null);
|
||||
}
|
||||
|
||||
public static boolean performExtractMethod(boolean doRefactor,
|
||||
boolean replaceAllDuplicates,
|
||||
Editor editor,
|
||||
PsiFile file,
|
||||
Project project,
|
||||
final boolean extractChainedConstructor,
|
||||
int... disabledParams)
|
||||
throws PrepareFailedException, IncorrectOperationException {
|
||||
int startOffset = editor.getSelectionModel().getSelectionStart();
|
||||
int endOffset = editor.getSelectionModel().getSelectionEnd();
|
||||
|
||||
@@ -574,7 +596,13 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
if (doRefactor) {
|
||||
processor.testRun();
|
||||
processor.testPrepare();
|
||||
if (disabledParams != null) {
|
||||
for (int param : disabledParams) {
|
||||
processor.doNotPassParameter(param);
|
||||
}
|
||||
}
|
||||
ExtractMethodHandler.run(project, editor, processor);
|
||||
}
|
||||
|
||||
if (replaceAllDuplicates) {
|
||||
|
||||
@@ -71,6 +71,12 @@ public class IntroduceFieldInSameClassTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
public void testUnresolvedReferenceToLocalVar() throws Exception {
|
||||
configureByFile("/refactoring/introduceField/beforeUnresolvedReferenceToLocalVar.java");
|
||||
performRefactoring(BaseExpressionToFieldHandler.InitializationPlace.IN_CURRENT_METHOD, false);
|
||||
checkResultByFile("/refactoring/introduceField/afterUnresolvedReferenceToLocalVar.java");
|
||||
}
|
||||
|
||||
private static void performRefactoring(final BaseExpressionToFieldHandler.InitializationPlace initializationPlace, final boolean declareStatic) {
|
||||
new MockIntroduceFieldHandler(initializationPlace, declareStatic).invoke(getProject(), myEditor, myFile, null);
|
||||
}
|
||||
|
||||
@@ -147,6 +147,11 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase {
|
||||
|
||||
@Override
|
||||
public boolean isToolEnabled(HighlightDisplayKey key, PsiElement element) {
|
||||
return isToolEnabled(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToolEnabled(HighlightDisplayKey key) {
|
||||
return key != null && myAvailableTools.containsKey(key.toString());
|
||||
}
|
||||
|
||||
|
||||
Generated
-8
@@ -1,8 +0,0 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="jps-gwt">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts</output-path>
|
||||
<root id="archive" name="jps-gwt.jar">
|
||||
<element id="module-output" name="gwt" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
Generated
-8
@@ -1,8 +0,0 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="jps-javaee">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts</output-path>
|
||||
<root id="archive" name="jps-javaee.jar">
|
||||
<element id="module-output" name="javaee" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
Generated
-8
@@ -1,8 +0,0 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="jps-jpa">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts</output-path>
|
||||
<root id="archive" name="jps-jpa.jar">
|
||||
<element id="module-output" name="jpa" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
Generated
-3
@@ -3,9 +3,6 @@
|
||||
<output-path>$PROJECT_DIR$/out/artifacts</output-path>
|
||||
<root id="archive" name="jps-sources.zip">
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/plugins/javaee/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/plugins/gwt/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/plugins/jpa/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/antLayout/src" />
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/serverFacade/src" />
|
||||
</root>
|
||||
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
protoc -I=. --java_out=../src javac_remote_proto.proto
|
||||
protoc -I=. --java_out=../src jps_remote_proto.proto
|
||||
@@ -43,6 +43,7 @@ message Message {
|
||||
optional string project_id = 2;
|
||||
repeated string module_name = 3;
|
||||
repeated string file_path = 4;
|
||||
repeated string artifact_name = 5;
|
||||
}
|
||||
|
||||
message ShutdownCommand {
|
||||
@@ -63,7 +64,9 @@ message Message {
|
||||
message GlobalLibrary {
|
||||
required string name = 1;
|
||||
optional string homePath = 2;
|
||||
repeated string path = 3;
|
||||
optional string type_name = 3;
|
||||
optional string additional_data_xml = 4;
|
||||
repeated string path = 5;
|
||||
}
|
||||
|
||||
repeated PathVariable path_variable = 1;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.jps.incremental.JavaBuilderService
|
||||
@@ -857,6 +857,18 @@ public final class JpsRemoteProto {
|
||||
return filePath_.get(index);
|
||||
}
|
||||
|
||||
// repeated string artifact_name = 5;
|
||||
public static final int ARTIFACT_NAME_FIELD_NUMBER = 5;
|
||||
private java.util.List<java.lang.String> artifactName_ =
|
||||
java.util.Collections.emptyList();
|
||||
public java.util.List<java.lang.String> getArtifactNameList() {
|
||||
return artifactName_;
|
||||
}
|
||||
public int getArtifactNameCount() { return artifactName_.size(); }
|
||||
public java.lang.String getArtifactName(int index) {
|
||||
return artifactName_.get(index);
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
commandType_ = org.jetbrains.jps.api.JpsRemoteProto.Message.Request.CompilationRequest.Type.REBUILD;
|
||||
}
|
||||
@@ -880,6 +892,9 @@ public final class JpsRemoteProto {
|
||||
for (java.lang.String element : getFilePathList()) {
|
||||
output.writeString(4, element);
|
||||
}
|
||||
for (java.lang.String element : getArtifactNameList()) {
|
||||
output.writeString(5, element);
|
||||
}
|
||||
}
|
||||
|
||||
private int memoizedSerializedSize = -1;
|
||||
@@ -914,6 +929,15 @@ public final class JpsRemoteProto {
|
||||
size += dataSize;
|
||||
size += 1 * getFilePathList().size();
|
||||
}
|
||||
{
|
||||
int dataSize = 0;
|
||||
for (java.lang.String element : getArtifactNameList()) {
|
||||
dataSize += com.google.protobuf.CodedOutputStream
|
||||
.computeStringSizeNoTag(element);
|
||||
}
|
||||
size += dataSize;
|
||||
size += 1 * getArtifactNameList().size();
|
||||
}
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
}
|
||||
@@ -1059,6 +1083,10 @@ public final class JpsRemoteProto {
|
||||
result.filePath_ =
|
||||
java.util.Collections.unmodifiableList(result.filePath_);
|
||||
}
|
||||
if (result.artifactName_ != java.util.Collections.EMPTY_LIST) {
|
||||
result.artifactName_ =
|
||||
java.util.Collections.unmodifiableList(result.artifactName_);
|
||||
}
|
||||
org.jetbrains.jps.api.JpsRemoteProto.Message.Request.CompilationRequest returnMe = result;
|
||||
result = null;
|
||||
return returnMe;
|
||||
@@ -1084,6 +1112,12 @@ public final class JpsRemoteProto {
|
||||
}
|
||||
result.filePath_.addAll(other.filePath_);
|
||||
}
|
||||
if (!other.artifactName_.isEmpty()) {
|
||||
if (result.artifactName_.isEmpty()) {
|
||||
result.artifactName_ = new java.util.ArrayList<java.lang.String>();
|
||||
}
|
||||
result.artifactName_.addAll(other.artifactName_);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1122,6 +1156,10 @@ public final class JpsRemoteProto {
|
||||
addFilePath(input.readString());
|
||||
break;
|
||||
}
|
||||
case 42: {
|
||||
addArtifactName(input.readString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1249,6 +1287,46 @@ public final class JpsRemoteProto {
|
||||
return this;
|
||||
}
|
||||
|
||||
// repeated string artifact_name = 5;
|
||||
public java.util.List<java.lang.String> getArtifactNameList() {
|
||||
return java.util.Collections.unmodifiableList(result.artifactName_);
|
||||
}
|
||||
public int getArtifactNameCount() {
|
||||
return result.getArtifactNameCount();
|
||||
}
|
||||
public java.lang.String getArtifactName(int index) {
|
||||
return result.getArtifactName(index);
|
||||
}
|
||||
public Builder setArtifactName(int index, java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
result.artifactName_.set(index, value);
|
||||
return this;
|
||||
}
|
||||
public Builder addArtifactName(java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (result.artifactName_.isEmpty()) {
|
||||
result.artifactName_ = new java.util.ArrayList<java.lang.String>();
|
||||
}
|
||||
result.artifactName_.add(value);
|
||||
return this;
|
||||
}
|
||||
public Builder addAllArtifactName(
|
||||
java.lang.Iterable<? extends java.lang.String> values) {
|
||||
if (result.artifactName_.isEmpty()) {
|
||||
result.artifactName_ = new java.util.ArrayList<java.lang.String>();
|
||||
}
|
||||
super.addAll(values, result.artifactName_);
|
||||
return this;
|
||||
}
|
||||
public Builder clearArtifactName() {
|
||||
result.artifactName_ = java.util.Collections.emptyList();
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.Request.CompilationRequest)
|
||||
}
|
||||
|
||||
@@ -1908,8 +1986,22 @@ public final class JpsRemoteProto {
|
||||
public boolean hasHomePath() { return hasHomePath; }
|
||||
public java.lang.String getHomePath() { return homePath_; }
|
||||
|
||||
// repeated string path = 3;
|
||||
public static final int PATH_FIELD_NUMBER = 3;
|
||||
// optional string type_name = 3;
|
||||
public static final int TYPE_NAME_FIELD_NUMBER = 3;
|
||||
private boolean hasTypeName;
|
||||
private java.lang.String typeName_ = "";
|
||||
public boolean hasTypeName() { return hasTypeName; }
|
||||
public java.lang.String getTypeName() { return typeName_; }
|
||||
|
||||
// optional string additional_data_xml = 4;
|
||||
public static final int ADDITIONAL_DATA_XML_FIELD_NUMBER = 4;
|
||||
private boolean hasAdditionalDataXml;
|
||||
private java.lang.String additionalDataXml_ = "";
|
||||
public boolean hasAdditionalDataXml() { return hasAdditionalDataXml; }
|
||||
public java.lang.String getAdditionalDataXml() { return additionalDataXml_; }
|
||||
|
||||
// repeated string path = 5;
|
||||
public static final int PATH_FIELD_NUMBER = 5;
|
||||
private java.util.List<java.lang.String> path_ =
|
||||
java.util.Collections.emptyList();
|
||||
public java.util.List<java.lang.String> getPathList() {
|
||||
@@ -1936,8 +2028,14 @@ public final class JpsRemoteProto {
|
||||
if (hasHomePath()) {
|
||||
output.writeString(2, getHomePath());
|
||||
}
|
||||
if (hasTypeName()) {
|
||||
output.writeString(3, getTypeName());
|
||||
}
|
||||
if (hasAdditionalDataXml()) {
|
||||
output.writeString(4, getAdditionalDataXml());
|
||||
}
|
||||
for (java.lang.String element : getPathList()) {
|
||||
output.writeString(3, element);
|
||||
output.writeString(5, element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1955,6 +2053,14 @@ public final class JpsRemoteProto {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeStringSize(2, getHomePath());
|
||||
}
|
||||
if (hasTypeName()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeStringSize(3, getTypeName());
|
||||
}
|
||||
if (hasAdditionalDataXml()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeStringSize(4, getAdditionalDataXml());
|
||||
}
|
||||
{
|
||||
int dataSize = 0;
|
||||
for (java.lang.String element : getPathList()) {
|
||||
@@ -2118,6 +2224,12 @@ public final class JpsRemoteProto {
|
||||
if (other.hasHomePath()) {
|
||||
setHomePath(other.getHomePath());
|
||||
}
|
||||
if (other.hasTypeName()) {
|
||||
setTypeName(other.getTypeName());
|
||||
}
|
||||
if (other.hasAdditionalDataXml()) {
|
||||
setAdditionalDataXml(other.getAdditionalDataXml());
|
||||
}
|
||||
if (!other.path_.isEmpty()) {
|
||||
if (result.path_.isEmpty()) {
|
||||
result.path_ = new java.util.ArrayList<java.lang.String>();
|
||||
@@ -2151,6 +2263,14 @@ public final class JpsRemoteProto {
|
||||
break;
|
||||
}
|
||||
case 26: {
|
||||
setTypeName(input.readString());
|
||||
break;
|
||||
}
|
||||
case 34: {
|
||||
setAdditionalDataXml(input.readString());
|
||||
break;
|
||||
}
|
||||
case 42: {
|
||||
addPath(input.readString());
|
||||
break;
|
||||
}
|
||||
@@ -2201,7 +2321,49 @@ public final class JpsRemoteProto {
|
||||
return this;
|
||||
}
|
||||
|
||||
// repeated string path = 3;
|
||||
// optional string type_name = 3;
|
||||
public boolean hasTypeName() {
|
||||
return result.hasTypeName();
|
||||
}
|
||||
public java.lang.String getTypeName() {
|
||||
return result.getTypeName();
|
||||
}
|
||||
public Builder setTypeName(java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
result.hasTypeName = true;
|
||||
result.typeName_ = value;
|
||||
return this;
|
||||
}
|
||||
public Builder clearTypeName() {
|
||||
result.hasTypeName = false;
|
||||
result.typeName_ = getDefaultInstance().getTypeName();
|
||||
return this;
|
||||
}
|
||||
|
||||
// optional string additional_data_xml = 4;
|
||||
public boolean hasAdditionalDataXml() {
|
||||
return result.hasAdditionalDataXml();
|
||||
}
|
||||
public java.lang.String getAdditionalDataXml() {
|
||||
return result.getAdditionalDataXml();
|
||||
}
|
||||
public Builder setAdditionalDataXml(java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
result.hasAdditionalDataXml = true;
|
||||
result.additionalDataXml_ = value;
|
||||
return this;
|
||||
}
|
||||
public Builder clearAdditionalDataXml() {
|
||||
result.hasAdditionalDataXml = false;
|
||||
result.additionalDataXml_ = getDefaultInstance().getAdditionalDataXml();
|
||||
return this;
|
||||
}
|
||||
|
||||
// repeated string path = 5;
|
||||
public java.util.List<java.lang.String> getPathList() {
|
||||
return java.util.Collections.unmodifiableList(result.path_);
|
||||
}
|
||||
|
||||
@@ -28,20 +28,23 @@ public class ProtoUtil {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createMakeRequest(String project, Collection<String> modules) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.MAKE, project, modules, Collections.<String>emptyList());
|
||||
public static JpsRemoteProto.Message.Request createMakeRequest(String project, Collection<String> modules, Collection<String> artifacts) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.MAKE, project, modules, artifacts, Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createForceCompileRequest(String project, Collection<String> modules, Collection<String> paths) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.FORCED_COMPILATION, project, modules, paths);
|
||||
public static JpsRemoteProto.Message.Request createForceCompileRequest(String project,
|
||||
Collection<String> modules,
|
||||
Collection<String> artifacts, Collection<String> paths) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.FORCED_COMPILATION, project, modules, artifacts, paths);
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createRebuildRequest(String project) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.REBUILD, project, Collections.<String>emptyList(), Collections.<String>emptyList());
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.REBUILD, project, Collections.<String>emptyList(),
|
||||
Collections.<String>emptyList(), Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createCleanRequest(String project, Collection<String> modules) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.CLEAN, project, modules, Collections.<String>emptyList());
|
||||
public static JpsRemoteProto.Message.Request createCleanRequest(String project, Collection<String> modules, Collection<String> artifacts) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.CLEAN, project, modules, artifacts, Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createCancelRequest(UUID compileSessionId) {
|
||||
@@ -50,13 +53,17 @@ public class ProtoUtil {
|
||||
return JpsRemoteProto.Message.Request.newBuilder().setRequestType(JpsRemoteProto.Message.Request.Type.CANCEL_BUILD_COMMAND).setCancelBuildCommand(builder.build()).build();
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createCompileRequest(final JpsRemoteProto.Message.Request.CompilationRequest.Type command, String project, Collection<String> modules, Collection<String> paths) {
|
||||
public static JpsRemoteProto.Message.Request createCompileRequest(final JpsRemoteProto.Message.Request.CompilationRequest.Type command, String project, Collection<String> modules,
|
||||
Collection<String> artifacts, Collection<String> paths) {
|
||||
final JpsRemoteProto.Message.Request.CompilationRequest.Builder builder = JpsRemoteProto.Message.Request.CompilationRequest.newBuilder().setCommandType(
|
||||
command);
|
||||
builder.setProjectId(project);
|
||||
if (modules.size() > 0) {
|
||||
builder.addAllModuleName(modules);
|
||||
}
|
||||
if (artifacts.size() > 0) {
|
||||
builder.addAllArtifactName(artifacts);
|
||||
}
|
||||
if (paths.size() > 0) {
|
||||
builder.addAllFilePath(paths);
|
||||
}
|
||||
@@ -107,7 +114,13 @@ public class ProtoUtil {
|
||||
JpsRemoteProto.Message.Request.SetupCommand.GlobalLibrary.newBuilder();
|
||||
libBuilder.setName(lib.getName()).addAllPath(lib.getPaths());
|
||||
if (lib instanceof SdkLibrary) {
|
||||
libBuilder.setHomePath(((SdkLibrary)lib).getHomePath());
|
||||
final SdkLibrary sdk = (SdkLibrary)lib;
|
||||
libBuilder.setHomePath(sdk.getHomePath());
|
||||
libBuilder.setTypeName(sdk.getTypeName());
|
||||
final String additional = sdk.getAdditionalDataXml();
|
||||
if (additional != null) {
|
||||
libBuilder.setAdditionalDataXml(additional);
|
||||
}
|
||||
}
|
||||
cmdBuilder.addGlobalLibrary(libBuilder.build());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.jetbrains.jps.api;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -8,14 +10,32 @@ import java.util.List;
|
||||
*/
|
||||
public class SdkLibrary extends GlobalLibrary {
|
||||
|
||||
private final String myTypeName;
|
||||
private final String myHomePath;
|
||||
@Nullable
|
||||
private final String myAdditionalDataXml;
|
||||
|
||||
public SdkLibrary(String name, String homePath, List<String> paths) {
|
||||
public SdkLibrary(String name, final String typeName, String homePath, List<String> paths) {
|
||||
this(name, typeName, homePath, paths, null);
|
||||
}
|
||||
|
||||
public SdkLibrary(String name, String typeName, String homePath, List<String> paths, @Nullable String additionalDataXml) {
|
||||
super(name, paths);
|
||||
myTypeName = typeName;
|
||||
myHomePath = homePath;
|
||||
myAdditionalDataXml = additionalDataXml;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return myTypeName;
|
||||
}
|
||||
|
||||
public String getHomePath() {
|
||||
return myHomePath;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAdditionalDataXml() {
|
||||
return myAdditionalDataXml;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,12 @@ public class CompileServerClient extends SimpleProtobufClient<JpsServerResponseH
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RequestFuture sendCompileRequest(boolean isMake, String projectId, Collection<String> modules, Collection<String> paths, JpsServerResponseHandler handler) throws Exception{
|
||||
public RequestFuture sendCompileRequest(boolean isMake, String projectId, Collection<String> modules, final Collection<String> artifacts,
|
||||
Collection<String> paths, JpsServerResponseHandler handler) throws Exception{
|
||||
checkConnected();
|
||||
final JpsRemoteProto.Message.Request request = isMake?
|
||||
ProtoUtil.createMakeRequest(projectId, modules) :
|
||||
ProtoUtil.createForceCompileRequest(projectId, modules, paths);
|
||||
ProtoUtil.createMakeRequest(projectId, modules, artifacts) :
|
||||
ProtoUtil.createForceCompileRequest(projectId, modules, artifacts, paths);
|
||||
return sendRequest(request, handler);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
/**
|
||||
* @see ModuleLevelBuilder
|
||||
* @see ProjectLevelBuilder
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class Builder {
|
||||
public abstract String getName();
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
public static enum ExitCode {
|
||||
OK, ABORT, ADDITIONAL_PASS_REQUIRED
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import org.jetbrains.jps.idea.OwnServiceLoader;
|
||||
import org.jetbrains.jps.incremental.groovy.GroovyBuilder;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilder;
|
||||
import org.jetbrains.jps.incremental.resources.ResourcesBuilder;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -37,18 +34,15 @@ public class BuilderRegistry {
|
||||
}
|
||||
});
|
||||
|
||||
final OwnServiceLoader<ProjectLevelBuilderService> loader = OwnServiceLoader.load(ProjectLevelBuilderService.class);
|
||||
final OwnServiceLoader<BuilderService> loader = OwnServiceLoader.load(BuilderService.class);
|
||||
|
||||
for (ProjectLevelBuilderService service : loader) {
|
||||
myProjectLevelBuilders.add(service.createBuilder());
|
||||
for (BuilderService service : loader) {
|
||||
myProjectLevelBuilders.addAll(service.createProjectLevelBuilders());
|
||||
final List<? extends ModuleLevelBuilder> moduleLevelBuilders = service.createModuleLevelBuilders(myTasksExecutor);
|
||||
for (ModuleLevelBuilder builder : moduleLevelBuilders) {
|
||||
myModuleLevelBuilders.get(builder.getCategory()).add(builder);
|
||||
}
|
||||
}
|
||||
// todo: some builder registration mechanism for plugins needed
|
||||
|
||||
myModuleLevelBuilders.get(BuilderCategory.TRANSLATOR).add(new GroovyBuilder(true));
|
||||
myModuleLevelBuilders.get(BuilderCategory.TRANSLATOR).add(new JavaBuilder(myTasksExecutor));
|
||||
myModuleLevelBuilders.get(BuilderCategory.TRANSLATOR).add(new ResourcesBuilder());
|
||||
myModuleLevelBuilders.get(BuilderCategory.TRANSLATOR).add(new GroovyBuilder(false));
|
||||
|
||||
}
|
||||
|
||||
public int getModuleLevelBuilderCount() {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class BuilderService {
|
||||
@NotNull
|
||||
public List<? extends ModuleLevelBuilder> createModuleLevelBuilders(ExecutorService executorService) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<? extends ProjectLevelBuilder> createProjectLevelBuilders() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.storage.TimestampStorage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -80,14 +81,14 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
return myIsProjectRebuild;
|
||||
}
|
||||
|
||||
public void markDirty(final File file) throws Exception {
|
||||
public void markDirty(final File file) throws IOException {
|
||||
final RootDescriptor descriptor = getModuleAndRoot(file);
|
||||
if (descriptor != null) {
|
||||
myFsState.markDirty(file, descriptor, myTsStorage);
|
||||
}
|
||||
}
|
||||
|
||||
public void markDirty(final ModuleChunk chunk) throws Exception {
|
||||
public void markDirty(final ModuleChunk chunk) throws IOException {
|
||||
myFsState.clearContextRoundData();
|
||||
final Set<Module> modules = chunk.getModules();
|
||||
for (Module module : modules) {
|
||||
@@ -95,7 +96,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
}
|
||||
}
|
||||
|
||||
public void markDirtyRecursively(ModuleChunk chunk) throws Exception {
|
||||
public void markDirtyRecursively(ModuleChunk chunk) throws IOException {
|
||||
final Set<Module> modules = chunk.getModules();
|
||||
final Set<Module> dirtyModules = new HashSet<Module>(modules);
|
||||
|
||||
@@ -170,7 +171,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
myFsState.beforeNextRoundStart();
|
||||
}
|
||||
|
||||
void onChunkBuildComplete(@NotNull ModuleChunk chunk) throws Exception {
|
||||
void onChunkBuildComplete(@NotNull ModuleChunk chunk) throws IOException {
|
||||
myDataManager.flush(true);
|
||||
|
||||
try {
|
||||
@@ -225,13 +226,13 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
myDelegateMessageHandler.processMessage(msg);
|
||||
}
|
||||
|
||||
public void processFilesToRecompile(ModuleChunk chunk, FileProcessor processor) throws Exception {
|
||||
public void processFilesToRecompile(ModuleChunk chunk, FileProcessor processor) throws IOException {
|
||||
for (Module module : chunk.getModules()) {
|
||||
myFsState.processFilesToRecompile(this, module, processor);
|
||||
}
|
||||
}
|
||||
|
||||
final void ensureFSStateInitialized(ModuleChunk chunk) throws Exception {
|
||||
final void ensureFSStateInitialized(ModuleChunk chunk) throws IOException {
|
||||
for (Module module : chunk.getModules()) {
|
||||
if (isProjectRebuild()) {
|
||||
markDirtyFiles(module, myTsStorage, true, isCompilingTests() ? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, null);
|
||||
@@ -252,7 +253,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void initModuleFSState(Module module) throws Exception {
|
||||
private void initModuleFSState(Module module) throws IOException {
|
||||
final HashSet<File> currentFiles = new HashSet<File>();
|
||||
markDirtyFiles(module, myTsStorage, false, isCompilingTests() ? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, currentFiles);
|
||||
|
||||
@@ -296,7 +297,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
PRODUCTION, TESTS, BOTH
|
||||
}
|
||||
|
||||
private void markDirtyFiles(Module module, final TimestampStorage tsStorage, final boolean forceMarkDirty, @NotNull final DirtyMarkScope scope, @Nullable final Set<File> currentFiles) throws Exception {
|
||||
private void markDirtyFiles(Module module, final TimestampStorage tsStorage, final boolean forceMarkDirty, @NotNull final DirtyMarkScope scope, @Nullable final Set<File> currentFiles) throws IOException {
|
||||
final Set<File> excludes = new HashSet<File>();
|
||||
for (String excludePath : module.getExcludes()) {
|
||||
excludes.add(new File(excludePath));
|
||||
@@ -323,7 +324,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void traverseRecursively(final RootDescriptor rd, final File file, Set<File> excludes, @NotNull final TimestampStorage tsStorage, final boolean forceDirty, @Nullable Set<File> currentFiles) throws Exception {
|
||||
private void traverseRecursively(final RootDescriptor rd, final File file, Set<File> excludes, @NotNull final TimestampStorage tsStorage, final boolean forceDirty, @Nullable Set<File> currentFiles) throws IOException {
|
||||
if (file.isDirectory()) {
|
||||
if (!PathUtil.isUnder(excludes, file)) {
|
||||
final File[] children = file.listFiles();
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.incremental.storage.TimestampStorage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -66,7 +67,7 @@ public class FSState {
|
||||
getDelta(rd.module).clearRecompile(rd.root, rd.isTestRoot);
|
||||
}
|
||||
|
||||
public void markDirty(final File file, final RootDescriptor rd, final @Nullable TimestampStorage tsStorage) throws Exception {
|
||||
public void markDirty(final File file, final RootDescriptor rd, final @Nullable TimestampStorage tsStorage) throws IOException {
|
||||
final FilesDelta roundDelta = myCurrentRoundDelta;
|
||||
if (roundDelta != null) {
|
||||
if (myContextModules.contains(rd.module)) {
|
||||
@@ -83,7 +84,7 @@ public class FSState {
|
||||
/**
|
||||
* @return true if marked something, false otherwise
|
||||
*/
|
||||
public boolean markAllUpToDate(CompileScope scope, final RootDescriptor rd, final TimestampStorage tsStorage, final long compilationStartStamp) throws Exception {
|
||||
public boolean markAllUpToDate(CompileScope scope, final RootDescriptor rd, final TimestampStorage tsStorage, final long compilationStartStamp) throws IOException {
|
||||
boolean marked = false;
|
||||
final FilesDelta delta = getDelta(rd.module);
|
||||
final Set<File> files = delta.clearRecompile(rd.root, rd.isTestRoot);
|
||||
@@ -115,7 +116,7 @@ public class FSState {
|
||||
return marked;
|
||||
}
|
||||
|
||||
public boolean processFilesToRecompile(CompileContext context, final Module module, final FileProcessor processor) throws Exception {
|
||||
public boolean processFilesToRecompile(CompileContext context, final Module module, final FileProcessor processor) throws IOException {
|
||||
final FilesDelta lastRoundDelta = myLastRoundDelta;
|
||||
final FilesDelta delta = lastRoundDelta != null? lastRoundDelta : getDelta(module);
|
||||
final Map<File, Set<File>> data = delta.getSourcesToRecompile(context.isCompilingTests());
|
||||
@@ -140,7 +141,7 @@ public class FSState {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void registerDeleted(final Module module, final File file, final boolean isTest, @Nullable TimestampStorage tsStorage) throws Exception {
|
||||
public void registerDeleted(final Module module, final File file, final boolean isTest, @Nullable TimestampStorage tsStorage) throws IOException {
|
||||
getDelta(module).addDeleted(file, isTest);
|
||||
if (tsStorage != null) {
|
||||
tsStorage.remove(file);
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.jetbrains.jps.incremental;
|
||||
import org.jetbrains.jps.Module;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -12,5 +13,5 @@ public interface FileProcessor {
|
||||
/**
|
||||
* @return true if processing should continue, false if should stop
|
||||
*/
|
||||
boolean apply(Module module, File file, String sourceRoot) throws Exception;
|
||||
boolean apply(Module module, File file, String sourceRoot) throws IOException;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.jetbrains.jps.Module;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class FilesCollector implements FileProcessor{
|
||||
return myContainer;
|
||||
}
|
||||
|
||||
public boolean apply(Module module, File file, String sourceRoot) throws Exception {
|
||||
public boolean apply(Module module, File file, String sourceRoot) throws IOException {
|
||||
if (myFilter.accept(file)) {
|
||||
myContainer.add(file);
|
||||
}
|
||||
|
||||
@@ -77,11 +77,13 @@ public class IncProjectBuilder {
|
||||
}
|
||||
catch (ProjectBuildException e) {
|
||||
final Throwable cause = e.getCause();
|
||||
if (cause instanceof PersistentEnumerator.CorruptedException || cause instanceof MappingFailedException) {
|
||||
if (cause instanceof PersistentEnumerator.CorruptedException || cause instanceof MappingFailedException || cause instanceof IOException) {
|
||||
// force rebuild
|
||||
myMessageDispatcher.processMessage(new CompilerMessage(COMPILE_SERVER_NAME, BuildMessage.Kind.INFO,
|
||||
"Internal caches are corrupted or have outdated format, forcing project rebuild: " +
|
||||
e.getMessage()));
|
||||
myMessageDispatcher.processMessage(new CompilerMessage(
|
||||
COMPILE_SERVER_NAME, BuildMessage.Kind.INFO,
|
||||
"Internal caches are corrupted or have outdated format, forcing project rebuild: " +
|
||||
e.getMessage())
|
||||
);
|
||||
flushContext(context);
|
||||
context = createContext(new AllProjectScope(scope.getProject(), Collections.<Artifact>emptySet(), true), false, true);
|
||||
runBuild(context);
|
||||
@@ -460,7 +462,7 @@ public class IncProjectBuilder {
|
||||
private final Map<Module, SourceToOutputMapping> storageMap = new HashMap<Module, SourceToOutputMapping>();
|
||||
|
||||
@Override
|
||||
public boolean apply(Module module, File file, String sourceRoot) throws Exception {
|
||||
public boolean apply(Module module, File file, String sourceRoot) throws IOException {
|
||||
SourceToOutputMapping srcToOut = storageMap.get(module);
|
||||
if (srcToOut == null) {
|
||||
srcToOut = dataManager.getSourceToOutputMap(module.getName().toLowerCase(Locale.US), compilingTests);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.incremental.groovy.GroovyBuilder;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilder;
|
||||
import org.jetbrains.jps.incremental.resources.ResourcesBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JavaBuilderService extends BuilderService {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends ModuleLevelBuilder> createModuleLevelBuilders(ExecutorService executorService) {
|
||||
return Arrays.asList(new GroovyBuilder(true),
|
||||
new JavaBuilder(executorService),
|
||||
new ResourcesBuilder(),
|
||||
new GroovyBuilder(false));
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Use {@link BuilderService} to register implementations of this class
|
||||
*
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 9/17/11
|
||||
*/
|
||||
@@ -23,12 +25,22 @@ public abstract class ModuleLevelBuilder extends Builder {
|
||||
private static final Key<Set<File>> ALL_AFFECTED_FILES_KEY = Key.create("_all_affected_files_");
|
||||
private static final Key<Set<File>> ALL_COMPILED_FILES_KEY = Key.create("_all_compiled_files_");
|
||||
|
||||
private final BuilderCategory myCategory;
|
||||
|
||||
protected ModuleLevelBuilder(BuilderCategory category) {
|
||||
myCategory = category;
|
||||
}
|
||||
|
||||
public static enum ExitCode {
|
||||
OK, ABORT, ADDITIONAL_PASS_REQUIRED, CHUNK_REBUILD_REQUIRED
|
||||
}
|
||||
|
||||
public abstract ExitCode build(CompileContext context, ModuleChunk chunk) throws ProjectBuildException;
|
||||
|
||||
public final BuilderCategory getCategory() {
|
||||
return myCategory;
|
||||
}
|
||||
|
||||
public void cleanupResources(CompileContext context, ModuleChunk chunk) {
|
||||
ALL_AFFECTED_FILES_KEY.set(context, null);
|
||||
ALL_COMPILED_FILES_KEY.set(context, null);
|
||||
@@ -43,7 +55,7 @@ public abstract class ModuleLevelBuilder extends Builder {
|
||||
* @return true if additional compilation pass is required, false otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
public final boolean updateMappings(CompileContext context, final Mappings delta, ModuleChunk chunk, Collection<File> filesToCompile, Collection<File> successfullyCompiled) throws Exception {
|
||||
public final boolean updateMappings(CompileContext context, final Mappings delta, ModuleChunk chunk, Collection<File> filesToCompile, Collection<File> successfullyCompiled) throws IOException {
|
||||
try {
|
||||
boolean additionalPassRequired = false;
|
||||
|
||||
@@ -115,7 +127,7 @@ public abstract class ModuleLevelBuilder extends Builder {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean chunkContainsAffectedFiles(CompileContext context, ModuleChunk chunk, final Set<File> affected) throws Exception {
|
||||
private static boolean chunkContainsAffectedFiles(CompileContext context, ModuleChunk chunk, final Set<File> affected) throws IOException {
|
||||
final Set<Module> chunkModules = new HashSet<Module>(chunk.getModules());
|
||||
if (!chunkModules.isEmpty()) {
|
||||
for (File file : affected) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
/**
|
||||
* Use {@link BuilderService} to register implementations of this class
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class ProjectLevelBuilder extends Builder {
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class ProjectLevelBuilderService {
|
||||
@NotNull
|
||||
public abstract ProjectLevelBuilder createBuilder();
|
||||
}
|
||||
+7
-4
@@ -1,16 +1,19 @@
|
||||
package org.jetbrains.jps.incremental.artifacts;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.incremental.BuilderService;
|
||||
import org.jetbrains.jps.incremental.ProjectLevelBuilder;
|
||||
import org.jetbrains.jps.incremental.ProjectLevelBuilderService;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ArtifactBuilderService extends ProjectLevelBuilderService {
|
||||
public class ArtifactBuilderService extends BuilderService {
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectLevelBuilder createBuilder() {
|
||||
return new IncArtifactBuilder();
|
||||
public List<? extends ProjectLevelBuilder> createProjectLevelBuilders() {
|
||||
return Collections.singletonList(new IncArtifactBuilder());
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user