mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
Generated
-1
@@ -4,7 +4,6 @@
|
||||
<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>
|
||||
|
||||
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
-1
@@ -60,7 +60,6 @@
|
||||
<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" />
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -595,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));
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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())) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.jps.incremental.JavaBuilderService
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ public class IncArtifactBuilder extends ProjectLevelBuilder {
|
||||
}
|
||||
context.processMessage(UptoDateFilesSavedEvent.INSTANCE);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (IOException e) {
|
||||
throw new ProjectBuildException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
private final String myBuilderName;
|
||||
|
||||
public GroovyBuilder(boolean forStubs) {
|
||||
super(BuilderCategory.TRANSLATOR);
|
||||
myForStubs = forStubs;
|
||||
myBuilderName = BUILDER_NAME + (forStubs ? "-stubs" : "-classes");
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
private final List<ClassPostProcessor> myClassProcessors = new ArrayList<ClassPostProcessor>();
|
||||
|
||||
public JavaBuilder(ExecutorService tasksExecutor) {
|
||||
super(BuilderCategory.TRANSLATOR);
|
||||
myTaskRunner = tasksExecutor;
|
||||
//add here class processors in the sequence they should be executed
|
||||
myClassProcessors.add(new ClassPostProcessor() {
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.jetbrains.jps.incremental.resources;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.jps.CompilerConfiguration;
|
||||
import org.jetbrains.jps.Module;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
@@ -24,6 +23,7 @@ public class ResourcesBuilder extends ModuleLevelBuilder {
|
||||
public static final String BUILDER_NAME = "resources";
|
||||
|
||||
public ResourcesBuilder() {
|
||||
super(BuilderCategory.TRANSLATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,16 +32,6 @@ public class ResourcesBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
public ExitCode build(final CompileContext context, ModuleChunk chunk) throws ProjectBuildException {
|
||||
CompilerConfiguration config = null;
|
||||
for (Module module : chunk.getModules()) {
|
||||
config = module.getProject().getCompilerConfiguration();
|
||||
break;
|
||||
}
|
||||
|
||||
if (config == null) {
|
||||
return ExitCode.OK;
|
||||
}
|
||||
|
||||
ResourcePatterns patterns = ResourcePatterns.KEY.get(context);
|
||||
if (patterns == null) {
|
||||
ResourcePatterns.KEY.set(context, patterns = new ResourcePatterns(context.getProject()));
|
||||
|
||||
@@ -82,11 +82,7 @@ public class ClasspathBootstrap {
|
||||
cp.add(getResourcePath(FileMonitor.class)); // jna-utils.jar
|
||||
cp.add(getResourcePath(ClassWriter.class)); // asm
|
||||
cp.add(getResourcePath(org.objectweb.asm.commons.EmptyVisitor.class)); // asm-commons
|
||||
final File jpsModel = getResourcePath(MacroExpander.class);
|
||||
cp.add(jpsModel); // jps-model
|
||||
cp.add(new File(jpsModel.getParentFile(), "jps-javaee"));
|
||||
cp.add(new File(jpsModel.getParentFile(), "jps-gwt"));
|
||||
cp.add(new File(jpsModel.getParentFile(), "jps-jpa"));
|
||||
cp.add(getResourcePath(MacroExpander.class)); // jps-model
|
||||
cp.add(getResourcePath(AlienFormFileException.class)); // forms-compiler
|
||||
cp.add(getResourcePath(GroovyException.class)); // groovy
|
||||
cp.add(getResourcePath(org.jdom.input.SAXBuilder.class)); // jdom
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="jps" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="jps-javaee" />
|
||||
<orderEntry type="library" name="JUnit4" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="jps" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
org.jetbrains.jps.javaee.JavaeeFacetResourcesElementType
|
||||
org.jetbrains.jps.javaee.JavaeeFacetClassesElementType
|
||||
@@ -1,3 +0,0 @@
|
||||
org.jetbrains.jps.javaee.WebFacetType
|
||||
org.jetbrains.jps.javaee.EjbFacetType
|
||||
org.jetbrains.jps.javaee.JavaeeAppFacetType
|
||||
@@ -1,10 +0,0 @@
|
||||
package org.jetbrains.jps.javaee
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class EjbFacetType extends JavaeeFacetTypeBase {
|
||||
EjbFacetType() {
|
||||
super("ejb")
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package org.jetbrains.jps.javaee
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JavaeeAppFacetType extends JavaeeFacetTypeBase {
|
||||
JavaeeAppFacetType() {
|
||||
super("javaeeApplication")
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.jetbrains.jps.javaee
|
||||
|
||||
import org.jetbrains.jps.idea.Facet
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class JavaeeFacet extends Facet {
|
||||
final List<Map<String, String>> descriptors = []
|
||||
final List<Map<String, String>> webRoots = []
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.jetbrains.jps.javaee;
|
||||
|
||||
|
||||
import org.jetbrains.jps.MacroExpander
|
||||
import org.jetbrains.jps.Project
|
||||
import org.jetbrains.jps.artifacts.LayoutElement
|
||||
import org.jetbrains.jps.artifacts.LayoutElementTypeService
|
||||
import org.jetbrains.jps.artifacts.ModuleOutputElement
|
||||
import org.jetbrains.jps.idea.ProjectLoadingErrorReporter
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class JavaeeFacetClassesElementType extends LayoutElementTypeService {
|
||||
JavaeeFacetClassesElementType() {
|
||||
super("javaee-facet-classes")
|
||||
}
|
||||
|
||||
@Override
|
||||
LayoutElement createElement(Project project, Node tag, MacroExpander macroExpander, ProjectLoadingErrorReporter errorReporter) {
|
||||
String facetId = tag."@facet"
|
||||
return new ModuleOutputElement(moduleName: facetId.substring(0, facetId.indexOf('/')))
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package org.jetbrains.jps.javaee
|
||||
|
||||
import org.jetbrains.jps.Project
|
||||
import org.jetbrains.jps.idea.Facet
|
||||
import org.jetbrains.jps.idea.IdeaProjectLoadingUtil
|
||||
import org.jetbrains.jps.idea.ProjectLoadingErrorReporter
|
||||
import org.jetbrains.jps.artifacts.*
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class JavaeeFacetResourcesElement extends ComplexLayoutElement {
|
||||
String facetId
|
||||
ProjectLoadingErrorReporter errorReporter
|
||||
|
||||
List<LayoutElement> getSubstitution(Project project) {
|
||||
Facet facet = IdeaProjectLoadingUtil.findFacetByIdWithAssertion(project, facetId, errorReporter)
|
||||
|
||||
if (!(facet instanceof JavaeeFacet)) {
|
||||
errorReporter.error("$facetId facet is not JavaEE facet")
|
||||
}
|
||||
|
||||
List<LayoutElement> result = []
|
||||
facet.descriptors.each {Map<String, String> descriptor ->
|
||||
result << LayoutElementFactory.createParentDirectories(descriptor.outputPath, new FileCopyElement(filePath: descriptor.path))
|
||||
}
|
||||
facet.webRoots.each {Map<String, String> webRoot ->
|
||||
result << LayoutElementFactory.createParentDirectories(webRoot.outputPath, new DirectoryCopyElement(dirPath: webRoot.path))
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package org.jetbrains.jps.javaee
|
||||
|
||||
import org.jetbrains.jps.MacroExpander
|
||||
import org.jetbrains.jps.Project
|
||||
import org.jetbrains.jps.artifacts.LayoutElement
|
||||
import org.jetbrains.jps.artifacts.LayoutElementTypeService
|
||||
import org.jetbrains.jps.idea.ProjectLoadingErrorReporter
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class JavaeeFacetResourcesElementType extends LayoutElementTypeService {
|
||||
JavaeeFacetResourcesElementType() {
|
||||
super("javaee-facet-resources")
|
||||
}
|
||||
|
||||
@Override
|
||||
LayoutElement createElement(Project project, Node tag, MacroExpander macroExpander, ProjectLoadingErrorReporter errorReporter) {
|
||||
return new JavaeeFacetResourcesElement(facetId: tag."@facet", errorReporter: errorReporter)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package org.jetbrains.jps.javaee
|
||||
|
||||
import org.jetbrains.jps.MacroExpander
|
||||
import org.jetbrains.jps.Module
|
||||
import org.jetbrains.jps.idea.Facet
|
||||
import org.jetbrains.jps.idea.FacetTypeService
|
||||
|
||||
import org.jetbrains.jps.idea.IdeaProjectLoadingUtil
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JavaeeFacetTypeBase extends FacetTypeService {
|
||||
protected JavaeeFacetTypeBase(String typeId) {
|
||||
super(typeId)
|
||||
}
|
||||
|
||||
protected String getDescriptorOutputPath(String descriptorId) {
|
||||
return "META-INF"
|
||||
}
|
||||
|
||||
@Override
|
||||
public Facet createFacet(Module module, String name, Node facetConfiguration, MacroExpander macroExpander) {
|
||||
def facet = new JavaeeFacet(name: name)
|
||||
facetConfiguration?.descriptors?.deploymentDescriptor?.each {Node tag ->
|
||||
def outputPath = getDescriptorOutputPath(tag."@name")
|
||||
String path = urlToPath(tag."@url", macroExpander)
|
||||
facet.descriptors << [path: path, outputPath: outputPath]
|
||||
}
|
||||
facetConfiguration?.webroots?.root?.each {Node tag ->
|
||||
String path = urlToPath(tag."@url", macroExpander)
|
||||
facet.webRoots << [path: path, outputPath: tag."@relative"]
|
||||
}
|
||||
return facet
|
||||
}
|
||||
|
||||
def urlToPath(String url, MacroExpander macroExpander) {
|
||||
return macroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(url))
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.jetbrains.jps.javaee
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class WebFacetType extends JavaeeFacetTypeBase {
|
||||
public WebFacetType() {
|
||||
super("web");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDescriptorOutputPath(String descriptorId) {
|
||||
if (descriptorId == "context.xml") return "META-INF"
|
||||
return "WEB-INF"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -83,10 +83,12 @@ public class CoreEnvironment {
|
||||
myEncodingRegistry = new CoreEncodingRegistry();
|
||||
|
||||
myApplication = new MockApplication(parentDisposable);
|
||||
ApplicationManager.setApplication(myApplication,
|
||||
new StaticGetter<FileTypeRegistry>(myFileTypeRegistry),
|
||||
new StaticGetter<EncodingRegistry>(myEncodingRegistry),
|
||||
parentDisposable);
|
||||
if (ApplicationManager.getApplication() == null) {
|
||||
ApplicationManager.setApplication(myApplication,
|
||||
new StaticGetter<FileTypeRegistry>(myFileTypeRegistry),
|
||||
new StaticGetter<EncodingRegistry>(myEncodingRegistry),
|
||||
parentDisposable);
|
||||
}
|
||||
myLocalFileSystem = new CoreLocalFileSystem();
|
||||
myJarFileSystem = new CoreJarFileSystem();
|
||||
|
||||
|
||||
@@ -20,11 +20,9 @@ import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.codeInsight.hint.HintUtil;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.find.FindManager;
|
||||
import com.intellij.find.findUsages.AbstractFindUsagesDialog;
|
||||
import com.intellij.find.findUsages.FindUsagesHandler;
|
||||
import com.intellij.find.findUsages.FindUsagesManager;
|
||||
import com.intellij.find.findUsages.PsiElement2UsageTargetAdapter;
|
||||
import com.intellij.find.findUsages.*;
|
||||
import com.intellij.find.impl.FindManagerImpl;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
|
||||
@@ -225,14 +223,15 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
}
|
||||
};
|
||||
FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(handler.getProject())).getFindUsagesManager();
|
||||
presentation = findUsagesManager.processUsages(handler, collect);
|
||||
FindUsagesOptions options = handler.getFindUsagesOptions(DataManager.getInstance().getDataContext());
|
||||
presentation = findUsagesManager.processUsages(handler, collect, options);
|
||||
if (presentation == null) {
|
||||
Disposer.dispose(usageView);
|
||||
return;
|
||||
}
|
||||
final String title = presentation.getTabText();
|
||||
|
||||
JBPopup popup = createUsagePopup(usages, visibleNodes, title, handler, editor, popupPosition, maxUsages, usageView);
|
||||
JBPopup popup = createUsagePopup(usages, visibleNodes, title, handler, editor, popupPosition, maxUsages, usageView, options);
|
||||
if (popup == null) {
|
||||
Disposer.dispose(usageView);
|
||||
}
|
||||
@@ -301,9 +300,9 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
}
|
||||
}
|
||||
|
||||
private static String searchScopePresentableName(final FindUsagesHandler handler) {
|
||||
SearchScope searchScope = FindUsagesManager.getCurrentSearchScope(handler);
|
||||
if (searchScope == null) searchScope = ProjectScope.getAllScope(handler.getProject());
|
||||
private static String searchScopePresentableName(FindUsagesOptions options, Project project) {
|
||||
SearchScope searchScope = options.searchScope;
|
||||
if (searchScope == null) searchScope = ProjectScope.getAllScope(project);
|
||||
return searchScope.getDisplayName();
|
||||
}
|
||||
|
||||
@@ -314,14 +313,15 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
final Editor editor,
|
||||
final RelativePoint popupPosition,
|
||||
final int maxUsages,
|
||||
final UsageViewImpl usageView) {
|
||||
final UsageViewImpl usageView, FindUsagesOptions options) {
|
||||
boolean hasMore = visibleNodes.remove(UsageViewImpl.NULL_NODE);
|
||||
|
||||
final Project project = handler.getProject();
|
||||
|
||||
if (visibleNodes.isEmpty()) {
|
||||
if (usages.isEmpty()) {
|
||||
String text = UsageViewBundle.message("no.usages.found.in", searchScopePresentableName(handler));
|
||||
String text = UsageViewBundle.message("no.usages.found.in", searchScopePresentableName(options,
|
||||
project));
|
||||
showHint(text, editor, popupPosition, handler, maxUsages);
|
||||
return null;
|
||||
}
|
||||
@@ -332,7 +332,8 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
if (visibleNodes.size() == 1 && usages.size() == 1) {
|
||||
//the only usage
|
||||
Usage usage = visibleNodes.iterator().next().getUsage();
|
||||
navigateAndHint(usage, UsageViewBundle.message("show.usages.only.usage", searchScopePresentableName(handler)), handler, popupPosition,
|
||||
navigateAndHint(usage, UsageViewBundle.message("show.usages.only.usage",
|
||||
searchScopePresentableName(options, project)), handler, popupPosition,
|
||||
maxUsages);
|
||||
return null;
|
||||
}
|
||||
@@ -340,7 +341,8 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
// usage view can filter usages down to one
|
||||
Usage usage = visibleNodes.iterator().next().getUsage();
|
||||
if (areAllUsagesInThisLine(usage, usages)) {
|
||||
String hint = UsageViewBundle.message("all.usages.are.in.this.line", usages.size(), searchScopePresentableName(handler));
|
||||
String hint = UsageViewBundle.message("all.usages.are.in.this.line", usages.size(),
|
||||
searchScopePresentableName(options, project));
|
||||
navigateAndHint(usage, hint, handler, popupPosition, maxUsages);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.codeInsight.hint.HintManagerImpl;
|
||||
import com.intellij.codeInsight.hint.HintUtil;
|
||||
import com.intellij.find.FindBundle;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.lang.findUsages.LanguageFindUsages;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
@@ -273,13 +272,6 @@ public class FindUsagesManager implements JDOMExternalizable {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SearchScope getCurrentSearchScope(FindUsagesHandler handler) {
|
||||
if (handler == null) return null;
|
||||
FindUsagesOptions findUsagesOptions = handler.getFindUsagesOptions();
|
||||
return findUsagesOptions.searchScope;
|
||||
}
|
||||
|
||||
public boolean isUsed(@NotNull PsiElement element, @NotNull FindUsagesOptions findUsagesOptions) {
|
||||
FindUsagesHandler handler = getFindUsagesHandler(element, true);
|
||||
if (handler == null) return false;
|
||||
@@ -298,11 +290,10 @@ public class FindUsagesManager implements JDOMExternalizable {
|
||||
|
||||
// return null on failure or cancel
|
||||
@Nullable
|
||||
public UsageViewPresentation processUsages(FindUsagesHandler handler, @NotNull final Processor<Usage> processor) {
|
||||
public UsageViewPresentation processUsages(FindUsagesHandler handler,
|
||||
@NotNull final Processor<Usage> processor, FindUsagesOptions findUsagesOptions) {
|
||||
if (handler == null) return null;
|
||||
|
||||
FindUsagesOptions findUsagesOptions = handler.getFindUsagesOptions(DataManager.getInstance().getDataContext());
|
||||
|
||||
PsiElement element = handler.getPsiElement();
|
||||
LOG.assertTrue(element.isValid());
|
||||
final UsageInfoToUsageConverter.TargetElementsDescriptor descriptor =
|
||||
|
||||
@@ -386,7 +386,7 @@ public class FindInProjectUtil {
|
||||
public boolean processFile(VirtualFile virtualFile) {
|
||||
if (!virtualFile.isDirectory() &&
|
||||
(fileMaskRegExp == null || fileMaskRegExp.matcher(virtualFile.getName()).matches()) &&
|
||||
(customScope == null || customScope.contains(virtualFile))) {
|
||||
customScope.contains(virtualFile)) {
|
||||
final PsiFile psiFile = psiManager.findFile(virtualFile);
|
||||
if (psiFile != null && !filesForFastWordSearch.contains(psiFile)) {
|
||||
myFiles.add(psiFile);
|
||||
@@ -403,10 +403,10 @@ public class FindInProjectUtil {
|
||||
|
||||
if (psiDirectory == null) {
|
||||
boolean success = fileIndex.iterateContent(iterator);
|
||||
if (success && customScope instanceof GlobalSearchScope && ((GlobalSearchScope)customScope).isSearchInLibraries()) {
|
||||
if (success && customScope.isSearchInLibraries()) {
|
||||
OrderEnumerator enumerator = module == null ? OrderEnumerator.orderEntries(project) : OrderEnumerator.orderEntries(module);
|
||||
final VirtualFile[] librarySources = enumerator.withoutModuleSourceEntries().withoutDepModules().getSourceRoots();
|
||||
iterateAll(librarySources, (GlobalSearchScope)customScope, iterator);
|
||||
iterateAll(librarySources, customScope, iterator);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -440,11 +440,14 @@ public class FindInProjectUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
private static GlobalSearchScope toGlobal(Project project, @Nullable SearchScope scope) {
|
||||
if (scope instanceof GlobalSearchScope || scope == null) {
|
||||
if (scope instanceof GlobalSearchScope) {
|
||||
return (GlobalSearchScope)scope;
|
||||
}
|
||||
if (scope == null) {
|
||||
return GlobalSearchScope.projectScope(project);
|
||||
}
|
||||
Set<VirtualFile> files = new HashSet<VirtualFile>();
|
||||
for (PsiElement element : ((LocalSearchScope)scope).getScope()) {
|
||||
PsiFile file = element.getContainingFile();
|
||||
@@ -472,7 +475,7 @@ public class FindInProjectUtil {
|
||||
? moduleContentScope(module)
|
||||
: customScope instanceof GlobalSearchScope
|
||||
? (GlobalSearchScope)customScope
|
||||
: GlobalSearchScope.projectScope(project);
|
||||
: toGlobal(project, customScope);
|
||||
|
||||
Set<Integer> keys = new THashSet<Integer>(30);
|
||||
Set<PsiFile> resultFiles = new THashSet<PsiFile>();
|
||||
|
||||
@@ -316,6 +316,7 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
private static boolean isWholeWord(CharSequence text, int startOffset, int endOffset) {
|
||||
boolean isWordStart = startOffset == 0 ||
|
||||
!Character.isJavaIdentifierPart(text.charAt(startOffset - 1)) ||
|
||||
!Character.isJavaIdentifierPart(text.charAt(startOffset)) ||
|
||||
startOffset > 1 && text.charAt(startOffset - 2) == '\\';
|
||||
|
||||
boolean isWordEnd = endOffset == text.length() ||
|
||||
|
||||
@@ -906,7 +906,7 @@ public class Messages {
|
||||
for (int i = 0; i < myOptions.length; i++) {
|
||||
String option = myOptions[i];
|
||||
final int exitCode = i;
|
||||
actions[i] = new AbstractAction(option) {
|
||||
actions[i] = new AbstractAction(UIUtil.replaceMnemonicAmpersand(option)) {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
close(exitCode, true);
|
||||
}
|
||||
|
||||
@@ -491,6 +491,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
private Dimension myInitialSize;
|
||||
private String myDimensionServiceKey;
|
||||
private boolean myOpened = false;
|
||||
private boolean myActivated = false;
|
||||
|
||||
private FocusTrackback myFocusTrackback;
|
||||
private MyDialog.MyWindowListener myWindowListener;
|
||||
@@ -896,7 +897,10 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (myActivated) {
|
||||
return;
|
||||
}
|
||||
myActivated = true;
|
||||
JComponent toFocus = wrapper == null ? null : wrapper.getPreferredFocusedComponent();
|
||||
if (toFocus == null) {
|
||||
toFocus = getRootPane().getDefaultButton();
|
||||
|
||||
@@ -92,7 +92,7 @@ action.name.checkin.directory={0} Directory
|
||||
action.name.checkin.file={0} File
|
||||
action.name.checkin.directories={0} Directories
|
||||
action.name.checkin.files={0} Files
|
||||
action.name.commit.project=Comm_it Changes
|
||||
action.name.commit.project=Comm&it Changes
|
||||
column.name.revision.list.author=Author
|
||||
column.name.revisions.list.filter=Date
|
||||
column.name.revisions.list.branch=Branch
|
||||
@@ -269,7 +269,7 @@ changes.newchangelist.warning.already.exists.title=Wrong Changelist Name
|
||||
commit.dialog.no.changes.detected.text=No changes detected
|
||||
commit.dialog.no.changes.detected.title=Nothing to commit
|
||||
commit.dialog.title=Commit Changes
|
||||
commit.dialog.default.commit.operation.name=Comm_it
|
||||
commit.dialog.default.commit.operation.name=Comm&it
|
||||
commit.dialog.include.action.name=Include into commit
|
||||
commit.dialog.failed.commit.template=Failed commit: {0}
|
||||
commit.dialog.completed.successfully=Completed successfully
|
||||
|
||||
+27
-13
@@ -18,7 +18,7 @@ package org.jetbrains.plugins.groovy.lang.folding;
|
||||
|
||||
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.folding.FoldingBuilder;
|
||||
import com.intellij.lang.folding.CustomFoldingBuilder;
|
||||
import com.intellij.lang.folding.FoldingDescriptor;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.FoldingGroup;
|
||||
@@ -33,6 +33,7 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.containers.hash.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
@@ -43,23 +44,23 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefini
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
public class GroovyFoldingBuilder implements FoldingBuilder, GroovyElementTypes, DumbAware {
|
||||
public class GroovyFoldingBuilder extends CustomFoldingBuilder implements GroovyElementTypes, DumbAware {
|
||||
|
||||
@NotNull
|
||||
public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode node, @NotNull Document document) {
|
||||
List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();
|
||||
appendDescriptors(node.getPsi(), descriptors, new HashSet<PsiElement>());
|
||||
return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
|
||||
@Override
|
||||
protected void buildLanguageFoldRegions(@NotNull List<FoldingDescriptor> descriptors,
|
||||
@NotNull PsiElement root,
|
||||
@NotNull Document document,
|
||||
boolean quick) {
|
||||
appendDescriptors(root, descriptors, new HashSet<PsiElement>());
|
||||
}
|
||||
|
||||
private static void appendDescriptors(PsiElement element, List<FoldingDescriptor> descriptors, Set<PsiElement> usedComments) {
|
||||
private void appendDescriptors(PsiElement element, List<FoldingDescriptor> descriptors, Set<PsiElement> usedComments) {
|
||||
ASTNode node = element.getNode();
|
||||
if (node == null) return;
|
||||
IElementType type = node.getElementType();
|
||||
@@ -70,13 +71,13 @@ public class GroovyFoldingBuilder implements FoldingBuilder, GroovyElementTypes,
|
||||
}
|
||||
}
|
||||
// comments
|
||||
if ((type.equals(mML_COMMENT) || type.equals(GROOVY_DOC_COMMENT)) &&
|
||||
if (((type.equals(mML_COMMENT) && !isCustomRegionStart(node)) || type.equals(GROOVY_DOC_COMMENT)) &&
|
||||
isMultiline(element) &&
|
||||
isWellEndedComment(element)) {
|
||||
descriptors.add(new FoldingDescriptor(node, node.getTextRange()));
|
||||
}
|
||||
|
||||
if (type.equals(mSL_COMMENT) && !usedComments.contains(element)) {
|
||||
if (type.equals(mSL_COMMENT) && !isCustomRegionStart(node) && !usedComments.contains(element)) {
|
||||
usedComments.add(element);
|
||||
PsiElement end = null;
|
||||
for (PsiElement current = element.getNextSibling(); current != null; current = current.getNextSibling()) {
|
||||
@@ -214,7 +215,8 @@ public class GroovyFoldingBuilder implements FoldingBuilder, GroovyElementTypes,
|
||||
return text.contains("\n") || text.contains("\r") || text.contains("\r\n");
|
||||
}
|
||||
|
||||
public String getPlaceholderText(@NotNull ASTNode node) {
|
||||
@Override
|
||||
protected String getLanguagePlaceholderText(@NotNull ASTNode node, @NotNull TextRange range) {
|
||||
final IElementType elemType = node.getElementType();
|
||||
if (BLOCK_SET.contains(elemType) || elemType == CLOSABLE_BLOCK) {
|
||||
return "{...}";
|
||||
@@ -236,7 +238,8 @@ public class GroovyFoldingBuilder implements FoldingBuilder, GroovyElementTypes,
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCollapsedByDefault(@NotNull ASTNode node) {
|
||||
@Override
|
||||
protected boolean isRegionCollapsedByDefault(@NotNull ASTNode node) {
|
||||
final JavaCodeFoldingSettings settings = JavaCodeFoldingSettings.getInstance();
|
||||
if ( node.getElementType() == IMPORT_STATEMENT ){
|
||||
return settings.isCollapseImports();
|
||||
@@ -280,4 +283,15 @@ public class GroovyFoldingBuilder implements FoldingBuilder, GroovyElementTypes,
|
||||
isMultiline(node.getPsi()) &&
|
||||
GrStringUtil.isWellEndedString(node.getPsi());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCustomFoldingCandidate(ASTNode node) {
|
||||
return node.getElementType() == GroovyTokenTypes.mSL_COMMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCustomFoldingRoot(ASTNode node) {
|
||||
IElementType nodeType = node.getElementType();
|
||||
return nodeType == GroovyElementTypes.CLASS_DEFINITION || nodeType == GroovyElementTypes.OPEN_BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
<extensionPoint name="compiler" area="IDEA_PROJECT" interface="com.intellij.openapi.compiler.Compiler"/>
|
||||
<extensionPoint name="compilerFactory" area="IDEA_PROJECT" interface="com.intellij.openapi.compiler.CompilerFactory"/>
|
||||
<extensionPoint name="compilerSettingsFactory" area="IDEA_PROJECT" interface="com.intellij.compiler.CompilerSettingsFactory"/>
|
||||
<extensionPoint name="compileServer.plugin" beanClass="com.intellij.compiler.server.CompileServerPlugin"/>
|
||||
|
||||
|
||||
<extensionPoint name="paletteItemProvider" area="IDEA_PROJECT" interface="com.intellij.ide.palette.PaletteItemProvider"/>
|
||||
|
||||
Reference in New Issue
Block a user