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:
@@ -8,7 +8,7 @@
|
||||
OS_TYPE="`uname -s`"
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Locate a JDK installation directory which will be used to ruin the IDE.
|
||||
# Locate a JDK installation directory which will be used to run the IDE.
|
||||
# Try (in order): @@product_uc@@_JDK, JDK_HOME, JAVA_HOME, "java" in PATH.
|
||||
# ---------------------------------------------------------------------
|
||||
if [ -n "$@@product_uc@@_JDK" -a -x "$@@product_uc@@_JDK/bin/java" ]; then
|
||||
|
||||
@@ -5,15 +5,21 @@
|
||||
::----------------------------------------------------------------------
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: Locate a JDK installation directory which will be used to ruin the IDE.
|
||||
:: Try (in order): @@product_uc@@_JDK, JDK_HOME, JAVA_HOME.
|
||||
:: Locate a JDK installation directory which will be used to run the IDE.
|
||||
:: Try (in order): @@product_uc@@_JDK, ..\jre, JDK_HOME, JAVA_HOME.
|
||||
:: ---------------------------------------------------------------------
|
||||
SET JDK=%@@product_uc@@_JDK%
|
||||
IF "%JDK%" == "" SET JDK=%JDK_HOME%
|
||||
IF "%JDK%" == "" SET JDK=%JAVA_HOME%
|
||||
IF EXIST "%@@product_uc@@_JDK%" SET JDK=%@@product_uc@@_JDK%
|
||||
IF NOT "%JDK%" == "" GOTO jdk
|
||||
IF EXIST "%~dp0\..\jre" SET JDK=%~dp0\..\jre
|
||||
IF NOT "%JDK%" == "" GOTO jdk
|
||||
IF EXIST "%JDK_HOME%" SET JDK=%JDK_HOME%
|
||||
IF NOT "%JDK%" == "" GOTO jdk
|
||||
IF EXIST "%JAVA_HOME%" SET JDK=%JAVA_HOME%
|
||||
IF "%JDK%" == "" GOTO error
|
||||
|
||||
:jdk
|
||||
SET JAVA_EXE=%JDK%\bin\java.exe
|
||||
IF NOT EXIST "%JAVA_EXE%" SET JAVA_EXE=%JDK%\jre\bin\java.exe
|
||||
IF NOT EXIST "%JAVA_EXE%" GOTO error
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
|
||||
@@ -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.
|
||||
@@ -191,6 +191,14 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
sendNotification(paths, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getProjectPath(final Project project) {
|
||||
final String path = project.getPresentableUrl();
|
||||
if (path == null) return path;
|
||||
final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(path);
|
||||
return vFile != null ? vFile.getPath() : null;
|
||||
}
|
||||
|
||||
public void sendReloadRequest(final Project project) {
|
||||
if (!project.isDefault() && project.isOpen()) {
|
||||
myTaskExecutor.submit(new Runnable() {
|
||||
@@ -200,7 +208,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
if (!project.isDisposed()) {
|
||||
final CompileServerClient client = ensureServerRunningAndClientConnected(false);
|
||||
if (client != null) {
|
||||
client.sendProjectReloadRequest(Collections.singletonList(project.getLocation()));
|
||||
client.sendProjectReloadRequest(Collections.singletonList(getProjectPath(project)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,7 +259,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
}
|
||||
for (Project project : openProjects) {
|
||||
try {
|
||||
client.sendFSEvent(project.getLocation(), changed, deleted);
|
||||
client.sendFSEvent(getProjectPath(project), changed, deleted);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.info(e);
|
||||
@@ -317,7 +325,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
final Collection<String> modules, final Collection<String> artifacts,
|
||||
final Collection<String> paths,
|
||||
final Map<String, String> userData, final JpsServerResponseHandler handler) {
|
||||
final String projectId = project.getLocation();
|
||||
final String projectId = getProjectPath(project);
|
||||
final Ref<RequestFuture> futureRef = new Ref<RequestFuture>(null);
|
||||
final RunnableFuture future = myTaskExecutor.submit(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
@@ -431,23 +431,22 @@ public class CompileDriver {
|
||||
final MessageBus messageBus = myProject.getMessageBus();
|
||||
csManager.cancelAutoMakeTasks(myProject);
|
||||
final CompileScope scope = compileContext.getCompileScope();
|
||||
final Map<String, String> userData;
|
||||
// need to pass scope's user data to server
|
||||
if (scope instanceof UserDataHolderBase) { // hack
|
||||
userData = new HashMap<String, String>();
|
||||
((UserDataHolderBase)scope).copyUserDataTo(new UserDataHolderBase() {
|
||||
@Override
|
||||
public <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
|
||||
final String _key = key.toString();
|
||||
final String _value = value != null? value.toString() : "";
|
||||
userData.put(_key, _value);
|
||||
}
|
||||
});
|
||||
final Map<Key, Object> exported = scope.exportUserData();
|
||||
final Map<String, String> builderParams;
|
||||
if (!exported.isEmpty()) {
|
||||
builderParams = new HashMap<String, String>();
|
||||
for (Map.Entry<Key, Object> entry : exported.entrySet()) {
|
||||
final String _key = entry.getKey().toString();
|
||||
final String _value = entry.getValue().toString();
|
||||
builderParams.put(_key, _value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
userData = Collections.emptyMap();
|
||||
builderParams = Collections.emptyMap();
|
||||
}
|
||||
return csManager.submitCompilationTask(myProject, compileContext.isRebuild(), compileContext.isMake(), moduleNames, artifactNames, paths, userData, new JpsServerResponseHandler() {
|
||||
return csManager.submitCompilationTask(myProject, compileContext.isRebuild(), compileContext.isMake(), moduleNames, artifactNames, paths,
|
||||
builderParams, new JpsServerResponseHandler() {
|
||||
|
||||
@Override
|
||||
public void handleCompileMessage(JpsRemoteProto.Message.Response.CompileMessage compilerMessage) {
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
package com.intellij.compiler.impl;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.ExportableUserDataHolderBase;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CompositeScope extends UserDataHolderBase implements CompileScope{
|
||||
public class CompositeScope extends ExportableUserDataHolderBase implements CompileScope{
|
||||
private final List<CompileScope> myScopes = new ArrayList<CompileScope>();
|
||||
|
||||
public CompositeScope(CompileScope scope1, CompileScope scope2) {
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
package com.intellij.compiler.impl;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.ExportableUserDataHolderBase;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.roots.FileIndex;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,7 +30,7 @@ import java.util.List;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Dec 18, 2003
|
||||
*/
|
||||
public abstract class FileIndexCompileScope extends UserDataHolderBase implements CompileScope {
|
||||
public abstract class FileIndexCompileScope extends ExportableUserDataHolderBase implements CompileScope {
|
||||
|
||||
protected abstract FileIndex[] getFileIndices();
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ package com.intellij.compiler.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.ExportableUserDataHolderBase;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class FileSetCompileScope extends UserDataHolderBase implements CompileScope {
|
||||
public class FileSetCompileScope extends ExportableUserDataHolderBase implements CompileScope {
|
||||
private final Set<VirtualFile> myRootFiles = new HashSet<VirtualFile>();
|
||||
private final Set<String> myDirectoryUrls = new HashSet<String>();
|
||||
private Set<String> myUrls = null; // urls caching
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.compiler.impl;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.ExportableUserDataHolderBase;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -24,7 +25,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ContentIterator;
|
||||
import com.intellij.openapi.roots.FileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OneProjectItemCompileScope extends UserDataHolderBase implements CompileScope{
|
||||
public class OneProjectItemCompileScope extends ExportableUserDataHolderBase implements CompileScope{
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.OneProjectItemCompileScope");
|
||||
private final Project myProject;
|
||||
private final VirtualFile myFile;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.intellij.compiler.options;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.Compiler;
|
||||
import com.intellij.openapi.compiler.options.ExcludedEntriesConfiguration;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
@State(
|
||||
name = "ValidationConfiguration",
|
||||
storages = {
|
||||
@Storage( file = "$WORKSPACE_FILE$"),
|
||||
@Storage( file = "$PROJECT_CONFIG_DIR$/validation.xml", scheme = StorageScheme.DIRECTORY_BASED)
|
||||
}
|
||||
)
|
||||
public class ValidationConfiguration implements PersistentStateComponent<ValidationConfiguration> {
|
||||
|
||||
public boolean VALIDATE_ON_BUILD = false;
|
||||
public Map<String, Boolean> VALIDATORS = new HashMap<String, Boolean>();
|
||||
|
||||
public static boolean shouldValidate(Compiler validator, CompileContext context) {
|
||||
ValidationConfiguration configuration = getInstance(context.getProject());
|
||||
return (configuration.VALIDATE_ON_BUILD) && configuration.isSelected(validator);
|
||||
}
|
||||
|
||||
public boolean isSelected(Compiler validator) {
|
||||
return isSelected(validator.getDescription());
|
||||
}
|
||||
|
||||
public boolean isSelected(String validatorDescription) {
|
||||
final Boolean selected = VALIDATORS.get(validatorDescription);
|
||||
return selected == null || selected.booleanValue();
|
||||
}
|
||||
|
||||
public void setSelected(Compiler validator, boolean selected) {
|
||||
setSelected(validator.getDescription(), selected);
|
||||
}
|
||||
|
||||
public void setSelected(String validatorDescription, boolean selected) {
|
||||
VALIDATORS.put(validatorDescription, selected);
|
||||
}
|
||||
|
||||
public static ValidationConfiguration getInstance(Project project) {
|
||||
return ServiceManager.getService(project, ValidationConfiguration.class);
|
||||
}
|
||||
|
||||
public static ExcludedEntriesConfiguration getExcludedEntriesConfiguration(Project project) {
|
||||
return ServiceManager.getService(project, ExcludedFromValidationConfiguration.class);
|
||||
}
|
||||
|
||||
public ValidationConfiguration getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void loadState(final ValidationConfiguration state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
|
||||
@State(
|
||||
name = "ExcludeFromValidation",
|
||||
storages = {
|
||||
@Storage( file = "$PROJECT_FILE$"),
|
||||
@Storage( file = "$PROJECT_CONFIG_DIR$/excludeFromValidation.xml", scheme = StorageScheme.DIRECTORY_BASED)
|
||||
}
|
||||
)
|
||||
public static class ExcludedFromValidationConfiguration extends ExcludedEntriesConfiguration {}
|
||||
}
|
||||
+337
@@ -0,0 +1,337 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
|
||||
*/
|
||||
package com.intellij.openapi.compiler.util;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.actions.CleanupInspectionIntention;
|
||||
import com.intellij.compiler.options.ValidationConfiguration;
|
||||
import com.intellij.lang.ExternalLanguageAnnotators;
|
||||
import com.intellij.lang.StdLanguages;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationSession;
|
||||
import com.intellij.lang.annotation.ExternalAnnotator;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.ReadActionProcessor;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.compiler.*;
|
||||
import com.intellij.openapi.compiler.options.ExcludedEntriesConfiguration;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.hash.LinkedHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class InspectionValidatorWrapper implements Validator {
|
||||
private final InspectionValidator myValidator;
|
||||
private final PsiManager myPsiManager;
|
||||
private final CompilerManager myCompilerManager;
|
||||
private final InspectionManager myInspectionManager;
|
||||
private final InspectionProjectProfileManager myProfileManager;
|
||||
private final PsiDocumentManager myPsiDocumentManager;
|
||||
private static final ThreadLocal<Boolean> ourCompilationThreads = new ThreadLocal<Boolean>() {
|
||||
protected Boolean initialValue() {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
public InspectionValidatorWrapper(final CompilerManager compilerManager, final InspectionManager inspectionManager,
|
||||
final InspectionProjectProfileManager profileManager, final PsiDocumentManager psiDocumentManager,
|
||||
final PsiManager psiManager, final InspectionValidator validator) {
|
||||
myCompilerManager = compilerManager;
|
||||
myInspectionManager = inspectionManager;
|
||||
myProfileManager = profileManager;
|
||||
myPsiDocumentManager = psiDocumentManager;
|
||||
myPsiManager = psiManager;
|
||||
myValidator = validator;
|
||||
}
|
||||
|
||||
public static boolean isCompilationThread() {
|
||||
return ourCompilationThreads.get().booleanValue();
|
||||
}
|
||||
|
||||
private class MyValidatorProcessingItem implements ProcessingItem {
|
||||
private final VirtualFile myVirtualFile;
|
||||
private final PsiFile myPsiFile;
|
||||
private PsiElementsValidityState myValidityState;
|
||||
|
||||
public MyValidatorProcessingItem(@NotNull final PsiFile psiFile) {
|
||||
myPsiFile = psiFile;
|
||||
myVirtualFile = psiFile.getVirtualFile();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public VirtualFile getFile() {
|
||||
return myVirtualFile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ValidityState getValidityState() {
|
||||
if (myValidityState == null) {
|
||||
myValidityState = computeValidityState();
|
||||
}
|
||||
return myValidityState;
|
||||
}
|
||||
|
||||
private PsiElementsValidityState computeValidityState() {
|
||||
final PsiElementsValidityState state = new PsiElementsValidityState();
|
||||
for (PsiElement psiElement : myValidator.getDependencies(myPsiFile)) {
|
||||
state.addDependency(psiElement);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public PsiFile getPsiFile() {
|
||||
return myPsiFile;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ProcessingItem[] getProcessingItems(final CompileContext context) {
|
||||
final Project project = context.getProject();
|
||||
if (!ValidationConfiguration.shouldValidate(this, context)) {
|
||||
return ProcessingItem.EMPTY_ARRAY;
|
||||
}
|
||||
final ExcludedEntriesConfiguration excludedEntriesConfiguration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
|
||||
final List<ProcessingItem> items = new ReadAction<List<ProcessingItem>>() {
|
||||
protected void run(final Result<List<ProcessingItem>> result) {
|
||||
final CompileScope compileScope = context.getCompileScope();
|
||||
if (!myValidator.isAvailableOnScope(compileScope)) return;
|
||||
|
||||
final ArrayList<ProcessingItem> items = new ArrayList<ProcessingItem>();
|
||||
|
||||
final Processor<VirtualFile> processor = new ReadActionProcessor<VirtualFile>() {
|
||||
@Override
|
||||
public boolean processInReadAction(VirtualFile file) {
|
||||
if (!file.isValid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (myCompilerManager.isExcludedFromCompilation(file) ||
|
||||
excludedEntriesConfiguration.isExcluded(file)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Module module = context.getModuleByFile(file);
|
||||
if (module != null) {
|
||||
final PsiFile psiFile = myPsiManager.findFile(file);
|
||||
if (psiFile != null) {
|
||||
items.add(new MyValidatorProcessingItem(psiFile));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
ContainerUtil.process(myValidator.getFilesToProcess(myPsiManager.getProject(), context), processor);
|
||||
|
||||
result.setResult(items);
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
if (items == null) return ProcessingItem.EMPTY_ARRAY;
|
||||
|
||||
return items.toArray(new ProcessingItem[items.size()]);
|
||||
}
|
||||
|
||||
public ProcessingItem[] process(final CompileContext context, final ProcessingItem[] items) {
|
||||
context.getProgressIndicator().setText(myValidator.getProgressIndicatorText());
|
||||
|
||||
final List<ProcessingItem> processedItems = new ArrayList<ProcessingItem>();
|
||||
final List<LocalInspectionTool> inspections = new ArrayList<LocalInspectionTool>();
|
||||
for (final Class aClass : myValidator.getInspectionToolClasses(context)) {
|
||||
try {
|
||||
inspections.add((LocalInspectionTool)aClass.newInstance());
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
final MyValidatorProcessingItem item = (MyValidatorProcessingItem)items[i];
|
||||
context.getProgressIndicator().checkCanceled();
|
||||
context.getProgressIndicator().setFraction((double)i / items.length);
|
||||
|
||||
try {
|
||||
ourCompilationThreads.set(Boolean.TRUE);
|
||||
|
||||
if (checkFile(inspections, item.getPsiFile(), context)) {
|
||||
processedItems.add(item);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
ourCompilationThreads.set(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return processedItems.toArray(new ProcessingItem[processedItems.size()]);
|
||||
}
|
||||
|
||||
private boolean checkFile(List<LocalInspectionTool> inspections, final PsiFile file, CompileContext context) {
|
||||
if (!checkUnderReadAction(file, context, new Computable<Map<ProblemDescriptor, HighlightDisplayLevel>>() {
|
||||
@Override
|
||||
public Map<ProblemDescriptor, HighlightDisplayLevel> compute() {
|
||||
return myValidator.checkAdditionally(file);
|
||||
}
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checkUnderReadAction(file, context, new Computable<Map<ProblemDescriptor, HighlightDisplayLevel>>() {
|
||||
@Override
|
||||
public Map<ProblemDescriptor, HighlightDisplayLevel> compute() {
|
||||
if (file instanceof XmlFile) {
|
||||
return runXmlFileSchemaValidation((XmlFile)file);
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
})) return false;
|
||||
|
||||
|
||||
final InspectionProfile inspectionProfile = myProfileManager.getInspectionProfile();
|
||||
for (final LocalInspectionTool inspectionTool : inspections) {
|
||||
if (!checkUnderReadAction(file, context, new Computable<Map<ProblemDescriptor, HighlightDisplayLevel>>() {
|
||||
@Override
|
||||
public Map<ProblemDescriptor, HighlightDisplayLevel> compute() {
|
||||
if (getHighlightDisplayLevel(inspectionTool, inspectionProfile, file) != HighlightDisplayLevel.DO_NOT_SHOW) {
|
||||
return runInspectionTool(file, inspectionTool, getHighlightDisplayLevel(inspectionTool, inspectionProfile, file));
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
})) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkUnderReadAction(PsiFile file, CompileContext context, Computable<Map<ProblemDescriptor, HighlightDisplayLevel>> runnable) {
|
||||
AccessToken token = ReadAction.start();
|
||||
try {
|
||||
if (!file.isValid()) return false;
|
||||
|
||||
final Document document = myPsiDocumentManager.getCachedDocument(file);
|
||||
if (document != null && myPsiDocumentManager.isUncommited(document)) {
|
||||
final String url = file.getViewProvider().getVirtualFile().getUrl();
|
||||
context.addMessage(CompilerMessageCategory.WARNING, CompilerBundle.message("warning.text.file.has.been.changed"), url, -1, -1);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reportProblems(context, runnable.compute())) return false;
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean reportProblems(CompileContext context, Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap) {
|
||||
if (problemsMap.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Map.Entry<ProblemDescriptor, HighlightDisplayLevel> entry : problemsMap.entrySet()) {
|
||||
ProblemDescriptor problemDescriptor = entry.getKey();
|
||||
final PsiElement element = problemDescriptor.getPsiElement();
|
||||
final PsiFile psiFile = element.getContainingFile();
|
||||
if (psiFile == null) continue;
|
||||
|
||||
final VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
if (virtualFile == null) continue;
|
||||
|
||||
final CompilerMessageCategory category = myValidator.getCategoryByHighlightDisplayLevel(entry.getValue(), virtualFile, context);
|
||||
final Document document = myPsiDocumentManager.getDocument(psiFile);
|
||||
|
||||
final int offset = problemDescriptor.getStartElement().getTextOffset();
|
||||
assert document != null;
|
||||
final int line = document.getLineNumber(offset);
|
||||
final int column = offset - document.getLineStartOffset(line);
|
||||
context.addMessage(category, problemDescriptor.getDescriptionTemplate(), virtualFile.getUrl(), line + 1, column + 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Map<ProblemDescriptor, HighlightDisplayLevel> runInspectionTool(final PsiFile file,
|
||||
final LocalInspectionTool inspectionTool,
|
||||
final HighlightDisplayLevel level) {
|
||||
Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap = new LinkedHashMap<ProblemDescriptor, HighlightDisplayLevel>();
|
||||
for (CommonProblemDescriptor descriptor : CleanupInspectionIntention.runInspectionOnFile(file, inspectionTool)) {
|
||||
if (descriptor instanceof ProblemDescriptor) {
|
||||
problemsMap.put((ProblemDescriptor)descriptor, level);
|
||||
}
|
||||
}
|
||||
return problemsMap;
|
||||
}
|
||||
|
||||
private static HighlightDisplayLevel getHighlightDisplayLevel(final LocalInspectionTool inspectionTool,
|
||||
final InspectionProfile inspectionProfile, PsiElement file) {
|
||||
final HighlightDisplayKey key = HighlightDisplayKey.find(inspectionTool.getShortName());
|
||||
return inspectionProfile.isToolEnabled(key, file) ? inspectionProfile.getErrorLevel(key, file) : HighlightDisplayLevel.DO_NOT_SHOW;
|
||||
}
|
||||
|
||||
private Map<ProblemDescriptor, HighlightDisplayLevel> runXmlFileSchemaValidation(@NotNull XmlFile xmlFile) {
|
||||
final AnnotationHolderImpl holder = new AnnotationHolderImpl(new AnnotationSession(xmlFile));
|
||||
|
||||
final List<ExternalAnnotator> annotators = ExternalLanguageAnnotators.allForFile(StdLanguages.XML, xmlFile);
|
||||
for (ExternalAnnotator annotator : annotators) {
|
||||
annotator.annotate(xmlFile, holder);
|
||||
}
|
||||
|
||||
if (!holder.hasAnnotations()) return Collections.emptyMap();
|
||||
|
||||
Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap = new LinkedHashMap<ProblemDescriptor, HighlightDisplayLevel>();
|
||||
for (final Annotation annotation : holder) {
|
||||
final HighlightInfo info = HighlightInfo.fromAnnotation(annotation);
|
||||
if (info.getSeverity() == HighlightSeverity.INFORMATION) continue;
|
||||
|
||||
final PsiElement startElement = xmlFile.findElementAt(info.startOffset);
|
||||
final PsiElement endElement = info.startOffset == info.endOffset ? startElement : xmlFile.findElementAt(info.endOffset - 1);
|
||||
if (startElement == null || endElement == null) continue;
|
||||
|
||||
final ProblemDescriptor descriptor =
|
||||
myInspectionManager.createProblemDescriptor(startElement, endElement, info.description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
false);
|
||||
final HighlightDisplayLevel level = info.getSeverity() == HighlightSeverity.ERROR? HighlightDisplayLevel.ERROR: HighlightDisplayLevel.WARNING;
|
||||
problemsMap.put(descriptor, level);
|
||||
}
|
||||
return problemsMap;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public String getDescription() {
|
||||
return myValidator.getDescription();
|
||||
}
|
||||
|
||||
public boolean validateConfiguration(final CompileScope scope) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ValidityState createValidityState(final DataInput in) throws IOException {
|
||||
return PsiElementsValidityState.load(in);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,6 @@ package com.intellij.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -28,7 +27,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*
|
||||
* @see CompilerManager#compile(CompileScope, CompileStatusNotification)
|
||||
*/
|
||||
public interface CompileScope extends UserDataHolder {
|
||||
public interface CompileScope extends ExportableUserDataHolder {
|
||||
CompileScope[] EMPTY_ARRAY = new CompileScope[0];
|
||||
/**
|
||||
* Returns the list of files within the scope.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -96,13 +96,17 @@ public class CompilerPaths {
|
||||
return new File(getCompilerSystemDirectory(), projectName + "." + project.getLocationHash());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getPresentableName(final Project project) {
|
||||
if (project.isDefault()) {
|
||||
return project.getName();
|
||||
}
|
||||
|
||||
String location = project.getLocation();
|
||||
if (location == null) return null;
|
||||
String location = project.getPresentableUrl();
|
||||
if (location == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String projectName = FileUtil.toSystemIndependentName(location);
|
||||
if (projectName.endsWith("/")) {
|
||||
projectName = projectName.substring(0, projectName.length() - 1);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.compiler;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 2/21/12
|
||||
*/
|
||||
public interface ExportableUserDataHolder extends UserDataHolder{
|
||||
|
||||
@NotNull
|
||||
Map<Key, Object> exportUserData();
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.compiler;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ExportableUserDataHolderBase extends UserDataHolderBase implements ExportableUserDataHolder{
|
||||
private final Set<Key> myKeys = Collections.synchronizedSet(new HashSet<Key>());
|
||||
|
||||
@NotNull
|
||||
public final Map<Key, Object> exportUserData() {
|
||||
final Map<Key, Object> result = new HashMap<Key, Object>();
|
||||
synchronized (myKeys) {
|
||||
for (Key<?> k : myKeys) {
|
||||
final Object data = getUserData(k);
|
||||
if (data != null) {
|
||||
result.put(k, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
|
||||
if (value != null) {
|
||||
myKeys.add(key);
|
||||
}
|
||||
else {
|
||||
myKeys.remove(key);
|
||||
}
|
||||
super.putUserData(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public abstract class UpdatableDebuggerView extends JPanel implements DebuggerVi
|
||||
private final DebuggerStateManager myStateManager;
|
||||
private volatile boolean myRefreshNeeded = true;
|
||||
private final java.util.List<Disposable> myDisposables = new ArrayList<Disposable>();
|
||||
private boolean myUpdateEnabled;
|
||||
private volatile boolean myUpdateEnabled;
|
||||
|
||||
protected UpdatableDebuggerView(final Project project, final DebuggerStateManager stateManager) {
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
+37
-25
@@ -27,10 +27,12 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author gregsh
|
||||
@@ -62,38 +64,48 @@ public class ExceptionExFilterFactory implements ExceptionFilterFactory {
|
||||
final int startOffset,
|
||||
int startLineNumber,
|
||||
final Consumer<AdditionalHighlight> consumer) {
|
||||
Map<String, Trinity<TextRange, TextRange, TextRange>> visited = new THashMap<String, Trinity<TextRange, TextRange, TextRange>>();
|
||||
final Trinity<TextRange, TextRange, TextRange> emptyInfo = Trinity.create(null, null, null);
|
||||
|
||||
final ExceptionWorker worker = new ExceptionWorker(myScope.getProject(), myScope);
|
||||
for (int i = 0; i < copiedFragment.getLineCount(); i++) {
|
||||
final int lineStartOffset = copiedFragment.getLineStartOffset(i);
|
||||
final int lineEndOffset = copiedFragment.getLineEndOffset(i);
|
||||
final ExceptionWorker worker = new ExceptionWorker(myScope.getProject(), myScope);
|
||||
Result result = null;
|
||||
AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
|
||||
try {
|
||||
String text = copiedFragment.getText(new TextRange(lineStartOffset, lineEndOffset));
|
||||
worker.execute(text, lineEndOffset);
|
||||
result = worker.getResult();
|
||||
if (result == null) continue;
|
||||
int offset = result.hyperlinkInfo instanceof OpenFileHyperlinkInfo
|
||||
? ((OpenFileHyperlinkInfo)result.hyperlinkInfo).getDescriptor().getOffset()
|
||||
: -1;
|
||||
PsiFile psiFile = worker.getFile();
|
||||
if (offset <= 0 || psiFile == null) continue;
|
||||
PsiElement element = psiFile.findElementAt(offset);
|
||||
PsiTryStatement parent = PsiTreeUtil.getParentOfType(element, PsiTryStatement.class, true, PsiClass.class);
|
||||
PsiCodeBlock tryBlock = parent != null? parent.getTryBlock() : null;
|
||||
if (tryBlock == null || !tryBlock.getTextRange().contains(offset)) continue;
|
||||
|
||||
String text = copiedFragment.getText(new TextRange(lineStartOffset, lineEndOffset));
|
||||
if (!text.contains(".java:")) continue;
|
||||
Trinity<TextRange, TextRange, TextRange> info = visited.get(text);
|
||||
if (info == emptyInfo) continue;
|
||||
|
||||
if (info == null) {
|
||||
info = emptyInfo;
|
||||
AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
|
||||
try {
|
||||
worker.execute(text, lineEndOffset);
|
||||
Result result = worker.getResult();
|
||||
if (result == null) continue;
|
||||
int offset = result.hyperlinkInfo instanceof OpenFileHyperlinkInfo
|
||||
? ((OpenFileHyperlinkInfo)result.hyperlinkInfo).getDescriptor().getOffset()
|
||||
: -1;
|
||||
PsiFile psiFile = worker.getFile();
|
||||
if (offset <= 0 || psiFile == null) continue;
|
||||
PsiElement element = psiFile.findElementAt(offset);
|
||||
PsiTryStatement parent = PsiTreeUtil.getParentOfType(element, PsiTryStatement.class, true, PsiClass.class);
|
||||
PsiCodeBlock tryBlock = parent != null? parent.getTryBlock() : null;
|
||||
if (tryBlock == null || !tryBlock.getTextRange().contains(offset)) continue;
|
||||
info = worker.getInfo();
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
visited.put(text, info);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
Trinity<TextRange,TextRange,TextRange> info = worker.getInfo();
|
||||
int off = startOffset + lineStartOffset;
|
||||
final TextAttributes attributes = result.highlightAttributes;
|
||||
attributes.setEffectColor(UIUtil.getInactiveTextColor());
|
||||
final Color color = UIUtil.getInactiveTextColor();
|
||||
consumer.consume(new AdditionalHighlight(off + info.first.getStartOffset(), off + info.second.getEndOffset()) {
|
||||
@Override
|
||||
public TextAttributes getTextAttributes(@Nullable TextAttributes source) {
|
||||
return new TextAttributes(null, null, attributes.getEffectColor(), EffectType.BOLD_DOTTED_LINE, Font.PLAIN);
|
||||
return new TextAttributes(null, null, color, EffectType.BOLD_DOTTED_LINE, Font.PLAIN);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -101,7 +113,7 @@ public class ExceptionExFilterFactory implements ExceptionFilterFactory {
|
||||
|
||||
@Override
|
||||
public String getUpdateMessage() {
|
||||
return "Checking try/finally blocks";
|
||||
return "Highlighting try blocks";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -23,8 +23,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@State(
|
||||
name = "RecentProjectsManager",
|
||||
roamingType = RoamingType.DISABLED,
|
||||
@@ -39,8 +37,7 @@ public class RecentProjectsManager extends RecentProjectsManagerBase {
|
||||
}
|
||||
|
||||
protected String getProjectPath(Project project) {
|
||||
final String location = project.getLocation();
|
||||
return location == null ? null : location.replace('/', File.separatorChar);
|
||||
return project.getPresentableUrl();
|
||||
}
|
||||
|
||||
protected void doOpenProject(final String projectPath, Project projectToClose, final boolean forceOpenInNewFrame) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -20,12 +20,14 @@ import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.impl.PlatformFrameTitleBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class IdeaFrameTitleBuilder extends PlatformFrameTitleBuilder {
|
||||
public String getFileTitle(final Project project, final VirtualFile file) {
|
||||
@Override
|
||||
public String getFileTitle(@NotNull final Project project, @NotNull final VirtualFile file) {
|
||||
return ProjectUtil.calcRelativeToProjectPath(file, project, !SystemInfo.isMac);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -85,6 +87,14 @@ public class ImportChooserStep extends ProjectImportWizardStep {
|
||||
}
|
||||
}
|
||||
}
|
||||
myList.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
||||
context.requestNextStep();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static List<ProjectImportProvider> sorted(ProjectImportProvider[] providers) {
|
||||
|
||||
@@ -18,11 +18,9 @@ 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.*;
|
||||
import com.intellij.psi.filters.ElementFilter;
|
||||
import com.intellij.psi.search.PsiShortNamesCache;
|
||||
import com.intellij.util.CollectConsumer;
|
||||
import com.intellij.util.Consumer;
|
||||
|
||||
@@ -92,6 +90,11 @@ public class JavaNoVariantsDelegator extends NoVariantsDelegator {
|
||||
PrefixMatcher qMatcher = new CamelHumpMatcher(referenceName);
|
||||
Set<LookupElement> plainVariants =
|
||||
JavaSmartCompletionContributor.completeReference(qualifier, qualifier, filter, true, true, parameters, qMatcher);
|
||||
|
||||
for (PsiClass aClass : PsiShortNamesCache.getInstance(qualifier.getProject()).getClassesByName(referenceName, qualifier.getResolveScope())) {
|
||||
plainVariants.add(JavaClassNameCompletionContributor.createClassLookupItem(aClass, true));
|
||||
}
|
||||
|
||||
if (!plainVariants.isEmpty()) {
|
||||
return plainVariants;
|
||||
}
|
||||
|
||||
+31
-20
@@ -178,11 +178,27 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction, HighP
|
||||
|
||||
final PsiMethod method = SuperMethodWarningUtil.checkSuperMethod(myTargetMethod, RefactoringBundle.message("to.refactor"));
|
||||
if (method == null) return;
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(method.getContainingFile())) return;
|
||||
myNewParametersInfo = getNewParametersInfo(myExpressions, myTargetMethod, mySubstitutor);
|
||||
|
||||
final List<ParameterInfoImpl> parameterInfos =
|
||||
performChange(project, editor, file, method, myMinUsagesNumberToShowDialog, myNewParametersInfo, myChangeAllUsages, false);
|
||||
if (parameterInfos != null) {
|
||||
myNewParametersInfo = parameterInfos.toArray(new ParameterInfoImpl[parameterInfos.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ParameterInfoImpl> performChange(final Project project,
|
||||
final Editor editor,
|
||||
final PsiFile file,
|
||||
final PsiMethod method,
|
||||
final int minUsagesNumber,
|
||||
final ParameterInfoImpl[] newParametersInfo,
|
||||
final boolean changeAllUsages,
|
||||
final boolean allowDelegation) {
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(method.getContainingFile())) return null;
|
||||
final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(project)).getFindUsagesManager();
|
||||
final FindUsagesHandler handler = findUsagesManager.getFindUsagesHandler(method, false);
|
||||
if (handler == null) return; //on failure or cancel (e.g. cancel of super methods dialog)
|
||||
if (handler == null) return null;//on failure or cancel (e.g. cancel of super methods dialog)
|
||||
|
||||
final JavaMethodFindUsagesOptions options = new JavaMethodFindUsagesOptions(project);
|
||||
options.isImplementingMethods = true;
|
||||
@@ -196,7 +212,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction, HighP
|
||||
Processor<UsageInfo> processor = new Processor<UsageInfo>() {
|
||||
@Override
|
||||
public boolean process(final UsageInfo t) {
|
||||
return ++usagesFound[0] < myMinUsagesNumberToShowDialog;
|
||||
return ++usagesFound[0] < minUsagesNumber;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -204,21 +220,20 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction, HighP
|
||||
}
|
||||
};
|
||||
String progressTitle = QuickFixBundle.message("searching.for.usages.progress.title");
|
||||
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, progressTitle, true, project)) return;
|
||||
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, progressTitle, true, project)) return null;
|
||||
|
||||
myNewParametersInfo = getNewParametersInfo(myExpressions, myTargetMethod, mySubstitutor);
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() || usagesFound[0] < myMinUsagesNumberToShowDialog) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() || usagesFound[0] < minUsagesNumber) {
|
||||
ChangeSignatureProcessor processor = new ChangeSignatureProcessor(
|
||||
project,
|
||||
method,
|
||||
false, null,
|
||||
method.getName(),
|
||||
method.getReturnType(),
|
||||
myNewParametersInfo){
|
||||
newParametersInfo){
|
||||
@Override
|
||||
@NotNull
|
||||
protected UsageInfo[] findUsages() {
|
||||
return myChangeAllUsages ? super.findUsages() : UsageInfo.EMPTY_ARRAY;
|
||||
return changeAllUsages ? super.findUsages() : UsageInfo.EMPTY_ARRAY;
|
||||
}
|
||||
};
|
||||
processor.run();
|
||||
@@ -230,25 +245,21 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction, HighP
|
||||
});
|
||||
}
|
||||
else {
|
||||
List<ParameterInfoImpl> parameterInfos = myNewParametersInfo != null
|
||||
? new ArrayList<ParameterInfoImpl>(Arrays.asList(myNewParametersInfo))
|
||||
List<ParameterInfoImpl> parameterInfos = newParametersInfo != null
|
||||
? new ArrayList<ParameterInfoImpl>(Arrays.asList(newParametersInfo))
|
||||
: new ArrayList<ParameterInfoImpl>();
|
||||
final PsiReferenceExpression refExpr = TargetElementUtil.findReferenceExpression(editor);
|
||||
JavaChangeSignatureDialog dialog = new JavaChangeSignatureDialog(project, method, allowDelegate(), refExpr);
|
||||
JavaChangeSignatureDialog dialog = new JavaChangeSignatureDialog(project, method, allowDelegation, refExpr);
|
||||
dialog.setParameterInfos(parameterInfos);
|
||||
dialog.show();
|
||||
List<ParameterInfoImpl> parameters = dialog.getParameters();
|
||||
myNewParametersInfo = parameters.toArray(new ParameterInfoImpl[parameters.size()]);
|
||||
return dialog.getParameters();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean allowDelegate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getNewParameterNameByOldIndex(int oldIndex) {
|
||||
if (myNewParametersInfo == null) return null;
|
||||
for (ParameterInfoImpl info : myNewParametersInfo) {
|
||||
public static String getNewParameterNameByOldIndex(int oldIndex, final ParameterInfoImpl[] parametersInfo) {
|
||||
if (parametersInfo == null) return null;
|
||||
for (ParameterInfoImpl info : parametersInfo) {
|
||||
if (info.oldParameterIndex == oldIndex) {
|
||||
return info.getName();
|
||||
}
|
||||
|
||||
+138
-47
@@ -19,28 +19,33 @@ import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
|
||||
import com.intellij.codeInsight.generation.PsiElementClassMember;
|
||||
import com.intellij.codeInsight.generation.PsiFieldMember;
|
||||
import com.intellij.codeInsight.generation.PsiMethodMember;
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.impl.AssignFieldFromParameterAction;
|
||||
import com.intellij.codeInsight.intention.impl.CreateFieldFromParameterAction;
|
||||
import com.intellij.ide.util.MemberChooser;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.SuggestedNameInfo;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.impl.source.jsp.jspJava.JspClass;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ConcurrentWeakHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -143,25 +148,40 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
|
||||
|
||||
} else if (!constrs.isEmpty()) {
|
||||
final Collection<SmartPsiElementPointer<PsiField>> fieldsToFix = getFieldsToFix();
|
||||
final PsiMethod constructor = constrs.get(0);
|
||||
final List<PsiField> fields = new ArrayList<PsiField>();
|
||||
for (SmartPsiElementPointer<PsiField> elementPointer : fieldsToFix) {
|
||||
final PsiField field = elementPointer.getElement();
|
||||
if (field != null && isAvailable(field) && filterConstructorsIfFieldAlreadyAssigned(new PsiMethod[]{constructor}, field).contains(constructor)) {
|
||||
fields.add(field);
|
||||
try {
|
||||
final PsiMethod constructor = constrs.get(0);
|
||||
final List<PsiField> fields = new ArrayList<PsiField>();
|
||||
for (SmartPsiElementPointer<PsiField> elementPointer : fieldsToFix) {
|
||||
final PsiField field = elementPointer.getElement();
|
||||
if (field != null && isAvailable(field) && filterConstructorsIfFieldAlreadyAssigned(new PsiMethod[]{constructor}, field).contains(constructor)) {
|
||||
fields.add(field);
|
||||
}
|
||||
}
|
||||
if (constrs.size() == constructors.length && fields.size() > 1 && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
PsiFieldMember[] members = new PsiFieldMember[fields.size()];
|
||||
int i = 0;
|
||||
for (PsiField field : fields) {
|
||||
members[i++] = new PsiFieldMember(field);
|
||||
}
|
||||
MemberChooser<PsiElementClassMember> chooser = new MemberChooser<PsiElementClassMember>(members, false, true, project);
|
||||
chooser.setTitle("Choose Fields to Generate Constructor Parameters for");
|
||||
chooser.show();
|
||||
if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) return;
|
||||
final List<PsiElementClassMember> selectedElements = chooser.getSelectedElements();
|
||||
if (selectedElements == null) return;
|
||||
fields.clear();
|
||||
for (PsiElementClassMember member : selectedElements) {
|
||||
fields.add((PsiField)member.getElement());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(fields, new Comparator<PsiField>() {
|
||||
@Override
|
||||
public int compare(PsiField o1, PsiField o2) {
|
||||
return o1.getTextOffset() - o2.getTextOffset();
|
||||
}
|
||||
});
|
||||
addParameterToConstructor(project, file, editor, constructor, constrs.size() == constructors.length
|
||||
? fields.toArray(new PsiField[fields.size()])
|
||||
: new PsiField[]{getField()});
|
||||
fieldsToFix.clear();
|
||||
addParameterToConstructor(project, file, editor, constructor, constrs.size() == constructors.length
|
||||
? fields.toArray(new PsiField[fields.size()])
|
||||
: new PsiField[]{getField()});
|
||||
}
|
||||
finally {
|
||||
fieldsToFix.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,45 +231,81 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
|
||||
final Editor editor,
|
||||
final PsiMethod constructor,
|
||||
final PsiField[] fields) throws IncorrectOperationException {
|
||||
final PsiParameter[] parameters = constructor.getParameterList().getParameters();
|
||||
PsiExpression[] expressions = new PsiExpression[parameters.length+fields.length];
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(file.getProject()).getElementFactory();
|
||||
final PsiParameterList parameterList = constructor.getParameterList();
|
||||
final PsiParameter[] parameters = parameterList.getParameters();
|
||||
ParameterInfoImpl[] newParamInfos = new ParameterInfoImpl[parameters.length + fields.length];
|
||||
final List<PsiVariable> params = new ArrayList<PsiVariable>(Arrays.asList(parameters));
|
||||
Collections.addAll(params, fields);
|
||||
Collections.sort(params, new FieldParameterComparator(parameterList));
|
||||
|
||||
int i = 0;
|
||||
for (; i < parameters.length; i++) {
|
||||
PsiParameter parameter = parameters[i];
|
||||
String value = PsiTypesUtil.getDefaultValueOfType(parameter.getType());
|
||||
expressions[i] = factory.createExpressionFromText(value, parameter);
|
||||
}
|
||||
for (PsiField field : fields) {
|
||||
expressions[i++] = factory.createExpressionFromText(field.getName(), constructor);
|
||||
}
|
||||
if (constructor.isVarArgs()) {
|
||||
ArrayUtil.rotateLeft(expressions, parameters.length - 1, expressions.length - 1);
|
||||
for (PsiVariable param : params) {
|
||||
final PsiType paramType = param.getType();
|
||||
if (param instanceof PsiParameter) {
|
||||
newParamInfos[i++] = new ParameterInfoImpl(parameterList.getParameterIndex((PsiParameter)param), param.getName(), paramType, param.getName());
|
||||
} else {
|
||||
final String uniqueParameterName = getUniqueParameterName(parameters, param);
|
||||
newParamInfos[i++] = new ParameterInfoImpl(-1, uniqueParameterName, paramType, uniqueParameterName);
|
||||
}
|
||||
}
|
||||
final SmartPointerManager manager = SmartPointerManager.getInstance(project);
|
||||
final SmartPsiElementPointer constructorPointer = manager.createSmartPsiElementPointer(constructor);
|
||||
|
||||
final ChangeMethodSignatureFromUsageFix addParamFix = new ChangeMethodSignatureFromUsageFix(constructor, expressions, PsiSubstitutor.EMPTY, constructor, true, 1){
|
||||
@Override
|
||||
protected boolean allowDelegate() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if (addParamFix.isAvailable(project, editor, file)) {
|
||||
addParamFix.invoke(project, editor, file);
|
||||
} else if (addParamFix.isMethodSignatureExists() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
HintManager.getInstance().showErrorHint(editor, "Constructor with corresponding signature already exist");
|
||||
}
|
||||
final PsiMethod fromText = JavaPsiFacade.getElementFactory(project).createMethodFromText(createDummyMethod(constructor, newParamInfos),
|
||||
constructor);
|
||||
final PsiClass containingClass = constructor.getContainingClass();
|
||||
if (containingClass == null) return false;
|
||||
final int minUsagesNumber = containingClass.findMethodsBySignature(fromText, false).length > 0 ? 0 : 1;
|
||||
final List<ParameterInfoImpl> parameterInfos =
|
||||
ChangeMethodSignatureFromUsageFix.performChange(project, editor, file, constructor, minUsagesNumber, newParamInfos, true, true);
|
||||
|
||||
final ParameterInfoImpl[] resultParams = parameterInfos != null ? parameterInfos.toArray(new ParameterInfoImpl[parameterInfos.size()]) :
|
||||
newParamInfos;
|
||||
return ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
return doCreate(project, editor, parameters, constructorPointer, addParamFix, fields);
|
||||
return doCreate(project, editor, parameters, constructorPointer, resultParams, fields);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static String createDummyMethod(PsiMethod constructor, ParameterInfoImpl[] newParamInfos) {
|
||||
return constructor.getName() + "(" + StringUtil.join(newParamInfos, new Function<ParameterInfoImpl, String>() {
|
||||
@Override
|
||||
public String fun(ParameterInfoImpl info) {
|
||||
return info.getTypeText() + " " + info.getName();
|
||||
}
|
||||
}, ", ") + "){}";
|
||||
}
|
||||
|
||||
private static String getUniqueParameterName(PsiParameter[] parameters, PsiVariable variable) {
|
||||
final JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(variable.getProject());
|
||||
final SuggestedNameInfo nameInfo = styleManager
|
||||
.suggestVariableName(VariableKind.PARAMETER,
|
||||
styleManager.variableNameToPropertyName(variable.getName(), VariableKind.FIELD),
|
||||
null, variable.getType());
|
||||
String newName = nameInfo.names[0];
|
||||
int n = 1;
|
||||
while (true) {
|
||||
if (isUnique(parameters, newName)) {
|
||||
break;
|
||||
}
|
||||
newName = nameInfo.names[0] + n++;
|
||||
}
|
||||
return newName;
|
||||
}
|
||||
|
||||
private static boolean isUnique(PsiParameter[] params, String newName) {
|
||||
for (PsiParameter parameter : params) {
|
||||
if (Comparing.strEqual(parameter.getName(), newName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean doCreate(Project project, Editor editor, PsiParameter[] parameters, SmartPsiElementPointer constructorPointer,
|
||||
ChangeMethodSignatureFromUsageFix addParamFix, PsiField[] fields) {
|
||||
ParameterInfoImpl[] parameterInfos, PsiField[] fields) {
|
||||
PsiMethod constructor = (PsiMethod)constructorPointer.getElement();
|
||||
assert constructor != null;
|
||||
PsiParameter[] newParameters = constructor.getParameterList().getParameters();
|
||||
@@ -265,7 +321,7 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
|
||||
field.getType()).names[0];
|
||||
PsiParameter parameter = findParamByName(defaultParamName, newParameters);
|
||||
if (parameter == null) {
|
||||
parameter = fields.length == 1 ? findParamByName(addParamFix.getNewParameterNameByOldIndex(-1), newParameters) : null;
|
||||
parameter = fields.length == 1 ? findParamByName(ChangeMethodSignatureFromUsageFix.getNewParameterNameByOldIndex(-1, parameterInfos), newParameters) : null;
|
||||
if (parameter == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -306,4 +362,39 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class FieldParameterComparator implements Comparator<PsiVariable> {
|
||||
private final PsiParameterList myParameterList;
|
||||
|
||||
public FieldParameterComparator(PsiParameterList parameterList) {
|
||||
myParameterList = parameterList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(PsiVariable o1, PsiVariable o2) {
|
||||
|
||||
if (o1 instanceof PsiParameter && ((PsiParameter)o1).isVarArgs()) return 1;
|
||||
if (o2 instanceof PsiParameter && ((PsiParameter)o2).isVarArgs()) return -1;
|
||||
|
||||
if (o1 instanceof PsiField && o2 instanceof PsiField) {
|
||||
return o1.getTextOffset() - o2.getTextOffset();
|
||||
}
|
||||
if (o1 instanceof PsiParameter && o2 instanceof PsiParameter) {
|
||||
return myParameterList.getParameterIndex((PsiParameter)o1) - myParameterList.getParameterIndex((PsiParameter)o2);
|
||||
}
|
||||
|
||||
if (o1 instanceof PsiField && o2 instanceof PsiParameter) {
|
||||
final PsiField field = CreateFieldFromParameterAction.getParameterAssignedToField((PsiParameter)o2);
|
||||
if (field == null) return 1;
|
||||
return o1.getTextOffset() - field.getTextOffset();
|
||||
}
|
||||
if (o1 instanceof PsiParameter && o2 instanceof PsiField) {
|
||||
final PsiField field = CreateFieldFromParameterAction.getParameterAssignedToField((PsiParameter)o1);
|
||||
if (field == null) return -1;
|
||||
return field.getTextOffset() - o2.getTextOffset();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class CreateFieldFromUsageFix extends CreateVarFromUsageFix {
|
||||
|
||||
@Override
|
||||
protected boolean canBeTargetClass(PsiClass psiClass) {
|
||||
return super.canBeTargetClass(psiClass) && !psiClass.isInterface() && !psiClass.isAnnotationType();
|
||||
return psiClass.getManager().isInProject(psiClass) && !psiClass.isInterface() && !psiClass.isAnnotationType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethodCallExpression;
|
||||
import com.intellij.psi.PsiReferenceExpression;
|
||||
@@ -41,6 +42,11 @@ public abstract class CreateVarFromUsageFix extends CreateFromUsageBaseFix {
|
||||
return CreateFromUsageUtils.isValidReference(expression, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canBeTargetClass(PsiClass psiClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement getElement() {
|
||||
if (!myReferenceExpression.isValid() || !myReferenceExpression.getManager().isInProject(myReferenceExpression)) return null;
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class AssignFieldFromParameterAction extends BaseIntentionAction {
|
||||
|| !type.isValid()
|
||||
|| targetClass == null
|
||||
|| targetClass.isInterface()
|
||||
|| CreateFieldFromParameterAction.isParameterAssignedToField(myParameter)) {
|
||||
|| CreateFieldFromParameterAction.getParameterAssignedToField(myParameter) != null) {
|
||||
return false;
|
||||
}
|
||||
PsiField field = findFieldToAssign(myParameter);
|
||||
|
||||
+151
-20
@@ -18,13 +18,17 @@ package com.intellij.codeInsight.intention.impl;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.codeInsight.generation.*;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.ide.util.MemberChooser;
|
||||
import com.intellij.lang.StdLanguages;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -39,17 +43,24 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.speedSearch.SpeedSearchUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ConcurrentWeakHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.CreateFieldFromParameterAction");
|
||||
private static final Key<Map<SmartPsiElementPointer<PsiParameter>, Boolean>> PARAMS = Key.create("FIELDS_FROM_PARAMS");
|
||||
|
||||
private String myName = "";
|
||||
|
||||
@Nullable
|
||||
@@ -85,30 +96,74 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
|
||||
@NotNull
|
||||
public String getText() {
|
||||
if (myName == null) return CodeInsightBundle.message("intention.create.fields.from.parameters.text");
|
||||
return CodeInsightBundle.message("intention.create.field.from.parameter.text", myName);
|
||||
}
|
||||
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
PsiParameter myParameter = findParameterAtCursor(file, editor);
|
||||
if (myParameter == null) return false;
|
||||
myName = myParameter.getName();
|
||||
final PsiType[] types = getTypes(myParameter);
|
||||
PsiClass targetClass = PsiTreeUtil.getParentOfType(myParameter, PsiClass.class);
|
||||
return
|
||||
myParameter.isValid()
|
||||
&& myParameter.getLanguage().isKindOf(StdLanguages.JAVA)
|
||||
&& myParameter.getDeclarationScope() instanceof PsiMethod
|
||||
&& ((PsiMethod)myParameter.getDeclarationScope()).getBody() != null
|
||||
&& myParameter.getManager().isInProject(myParameter)
|
||||
&& types != null
|
||||
&& types[0].isValid()
|
||||
&& !isParameterAssignedToField(myParameter)
|
||||
&& targetClass != null
|
||||
&& !targetClass.isInterface()
|
||||
PsiParameter psiParameter = findParameterAtCursor(file, editor);
|
||||
if (psiParameter == null) return false;
|
||||
final Collection<SmartPsiElementPointer<PsiParameter>> params = getUnboundedParams(psiParameter);
|
||||
params.clear();
|
||||
final PsiParameter[] parameters = ((PsiMethod)psiParameter.getDeclarationScope()).getParameterList().getParameters();
|
||||
for (PsiParameter parameter : parameters) {
|
||||
params.add(SmartPointerManager.getInstance(project).createSmartPsiElementPointer(parameter));
|
||||
}
|
||||
myName = params.size() > 1 && !ApplicationManager.getApplication().isUnitTestMode() ? null : psiParameter.getName();
|
||||
return isAvailable(psiParameter);
|
||||
}
|
||||
|
||||
private static boolean isAvailable(PsiParameter psiParameter) {
|
||||
final PsiType[] types = getTypes(psiParameter);
|
||||
PsiClass targetClass = PsiTreeUtil.getParentOfType(psiParameter, PsiClass.class);
|
||||
return psiParameter.isValid()
|
||||
&& psiParameter.getLanguage().isKindOf(StdLanguages.JAVA)
|
||||
&& psiParameter.getDeclarationScope() instanceof PsiMethod
|
||||
&& ((PsiMethod)psiParameter.getDeclarationScope()).getBody() != null
|
||||
&& psiParameter.getManager().isInProject(psiParameter)
|
||||
&& types != null
|
||||
&& types[0].isValid()
|
||||
&& getParameterAssignedToField(psiParameter) == null
|
||||
&& targetClass != null
|
||||
&& !targetClass.isInterface()
|
||||
;
|
||||
}
|
||||
|
||||
static boolean isParameterAssignedToField(final PsiParameter parameter) {
|
||||
@NotNull
|
||||
private static Collection<SmartPsiElementPointer<PsiParameter>> getUnboundedParams(PsiParameter parameter) {
|
||||
final PsiElement psiElement = parameter.getDeclarationScope();
|
||||
if (!(psiElement instanceof PsiMethod)) return Collections.emptyList();
|
||||
final PsiMethod psiMethod = (PsiMethod)psiElement;
|
||||
Map<SmartPsiElementPointer<PsiParameter>, Boolean> params = psiMethod.getUserData(PARAMS);
|
||||
if (params == null) psiMethod.putUserData(PARAMS, params = new ConcurrentWeakHashMap<SmartPsiElementPointer<PsiParameter>, Boolean>(1));
|
||||
final Map<SmartPsiElementPointer<PsiParameter>, Boolean> finalParams = params;
|
||||
return new AbstractCollection<SmartPsiElementPointer<PsiParameter>>() {
|
||||
@Override
|
||||
public boolean add(SmartPsiElementPointer<PsiParameter> psiVariable) {
|
||||
PsiParameter psiParameter = psiVariable.getElement();
|
||||
if (psiParameter == null || !isAvailable(psiParameter)) return false;
|
||||
return finalParams.put(psiVariable, Boolean.TRUE) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<SmartPsiElementPointer<PsiParameter>> iterator() {
|
||||
return finalParams.keySet().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return finalParams.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
finalParams.clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiField getParameterAssignedToField(final PsiParameter parameter) {
|
||||
for (PsiReference reference : ReferencesSearch.search(parameter, new LocalSearchScope(parameter.getDeclarationScope()), false)) {
|
||||
if (!(reference instanceof PsiReferenceExpression)) continue;
|
||||
final PsiReferenceExpression expression = (PsiReferenceExpression)reference;
|
||||
@@ -118,10 +173,9 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
final PsiExpression lExpression = assignmentExpression.getLExpression();
|
||||
if (!(lExpression instanceof PsiReferenceExpression)) continue;
|
||||
final PsiElement element = ((PsiReferenceExpression)lExpression).resolve();
|
||||
if (!(element instanceof PsiField)) continue;
|
||||
return true;
|
||||
if (element instanceof PsiField) return (PsiField)element;
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -149,7 +203,56 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
private static void invoke(final Project project, Editor editor, PsiFile file, boolean isInteractive) {
|
||||
final PsiParameter myParameter = findParameterAtCursor(file, editor);
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(myParameter.getContainingFile())) return;
|
||||
final Collection<SmartPsiElementPointer<PsiParameter>> unboundedParams = getUnboundedParams(myParameter);
|
||||
if (unboundedParams.size() > 1 && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
ClassMember[] members = new ClassMember[unboundedParams.size()];
|
||||
ClassMember selection = null;
|
||||
int i = 0;
|
||||
for (SmartPsiElementPointer<PsiParameter> pointer : unboundedParams) {
|
||||
final PsiParameter parameter = pointer.getElement();
|
||||
final ParameterClassMember classMember = new ParameterClassMember(parameter);
|
||||
members[i++] = classMember;
|
||||
if (parameter == myParameter) {
|
||||
selection = classMember;
|
||||
}
|
||||
}
|
||||
final PsiParameterList parameterList = ((PsiMethod)myParameter.getDeclarationScope()).getParameterList();
|
||||
Arrays.sort(members, new Comparator<ClassMember>() {
|
||||
@Override
|
||||
public int compare(ClassMember o1, ClassMember o2) {
|
||||
return parameterList.getParameterIndex(((ParameterClassMember)o1).getParameter()) -
|
||||
parameterList.getParameterIndex(((ParameterClassMember)o2).getParameter());
|
||||
}
|
||||
});
|
||||
|
||||
final MemberChooser<ClassMember> chooser = new MemberChooser<ClassMember>(members, false, true, project);
|
||||
if (selection != null) {
|
||||
chooser.selectElements(new ClassMember[] {selection});
|
||||
}
|
||||
chooser.setTitle("Choose Constructor Parameters to Generate Fields");
|
||||
chooser.setCopyJavadocVisible(false);
|
||||
chooser.show();
|
||||
if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) return;
|
||||
final List<ClassMember> selectedElements = chooser.getSelectedElements();
|
||||
if (selectedElements == null) return;
|
||||
if (selectedElements.size() == 1) {
|
||||
processParameter(project, ((ParameterClassMember)selectedElements.get(0)).getParameter(), isInteractive);
|
||||
} else {
|
||||
//do not ask for names in batch
|
||||
for (ClassMember selectedElement : selectedElements) {
|
||||
processParameter(project, ((ParameterClassMember)selectedElement).getParameter(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
processParameter(project, myParameter, isInteractive);
|
||||
}
|
||||
unboundedParams.clear();
|
||||
}
|
||||
|
||||
private static void processParameter(final Project project,
|
||||
final PsiParameter myParameter,
|
||||
boolean isInteractive) {
|
||||
IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace();
|
||||
final PsiType[] types = getTypes(myParameter);
|
||||
final JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project);
|
||||
@@ -344,4 +447,32 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class ParameterClassMember implements ClassMember {
|
||||
private PsiParameter myParameter;
|
||||
|
||||
private ParameterClassMember(PsiParameter parameter) {
|
||||
myParameter = parameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberChooserObject getParentNodeDelegate() {
|
||||
return new PsiMethodMember((PsiMethod)myParameter.getDeclarationScope());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTreeNode(SimpleColoredComponent component, JTree tree) {
|
||||
SpeedSearchUtil.appendFragmentsForSpeedSearch(tree, getText(), SimpleTextAttributes.REGULAR_ATTRIBUTES, false, component);
|
||||
component.setIcon(myParameter.getIcon(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return myParameter.getName();
|
||||
}
|
||||
|
||||
public PsiParameter getParameter() {
|
||||
return myParameter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
{
|
||||
Assert.<caret>
|
||||
}
|
||||
}
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// "Change 'new TTT[0][]' to 'new TTT[]'" "true"
|
||||
public class TTT {
|
||||
void f() {
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// "Change 'new X[42]' to 'new long[]'" "true"
|
||||
|
||||
class X {
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// "Change 'new X[42]' to 'new long[]'" "true"
|
||||
|
||||
class X {
|
||||
|
||||
+3
-3
@@ -4,11 +4,11 @@ class A {
|
||||
private int j;
|
||||
|
||||
A(int field) {
|
||||
this(0, field);
|
||||
this(field, 0);
|
||||
}
|
||||
|
||||
A(int j, int field) {
|
||||
this.j = j;
|
||||
A(int field, int j) {
|
||||
this.field = field;
|
||||
this.j = j;
|
||||
}
|
||||
}
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// "Override method 'foo'" "true"
|
||||
class Test {
|
||||
protected void foo(){}
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// "Override method 'foo'" "false"
|
||||
class Test {
|
||||
private void f<caret>oo(){}
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// "Override method 'foo'" "true"
|
||||
class Test {
|
||||
protected void f<caret>oo(){}
|
||||
|
||||
+1
-1
@@ -989,7 +989,7 @@ class Foo {
|
||||
myFixture.configureByText "a.java", "class Foo {{ <caret> }}"
|
||||
type 'Arrays.'
|
||||
myFixture.checkResult "class Foo {{ Arrays.<caret> }}"
|
||||
assert !lookup
|
||||
assert 'Arrays.asList' in myFixture.lookupElementStrings
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
@@ -1290,4 +1290,11 @@ public class ListUtils {
|
||||
checkResult()
|
||||
}
|
||||
|
||||
public void testAllAssertClassesMethods() {
|
||||
myFixture.addClass 'package foo; public class Assert { public static void foo() {} }'
|
||||
myFixture.addClass 'package bar; public class Assert { public static void bar() {} }'
|
||||
configure()
|
||||
assert myFixture.lookupElementStrings == ['Assert.bar', 'Assert.foo']
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.psi.search;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -139,7 +154,8 @@ public class UpdateCacheTest extends PsiTestCase{
|
||||
checkUsages(objectClass, new String[]{});
|
||||
FileBasedIndex.getInstance().getContainingFiles(TodoIndex.NAME, new TodoIndexEntry("todo", true), GlobalSearchScope.allScope(getProject()));
|
||||
|
||||
final String projectLocation = myProject.getLocation();
|
||||
final String projectLocation = myProject.getPresentableUrl();
|
||||
assert projectLocation != null : myProject;
|
||||
myProject.save();
|
||||
final VirtualFile content = ModuleRootManager.getInstance(getModule()).getContentRoots()[0];
|
||||
ProjectUtil.closeAndDispose(myProject);
|
||||
|
||||
@@ -393,7 +393,7 @@ public class PsiFormatUtil extends PsiFormatUtilBase {
|
||||
return builder.toString();
|
||||
}
|
||||
final PsiClass psiClass = PsiTreeUtil.getParentOfType(owner, PsiClass.class, false);
|
||||
assert psiClass != null;
|
||||
if (psiClass == null) return null;
|
||||
ClassUtil.formatClassName(psiClass, builder);
|
||||
if (owner instanceof PsiMethod) {
|
||||
builder.append(" ");
|
||||
@@ -406,24 +406,22 @@ public class PsiFormatUtil extends PsiFormatUtilBase {
|
||||
}
|
||||
else if (owner instanceof PsiParameter) {
|
||||
final PsiElement declarationScope = ((PsiParameter)owner).getDeclarationScope();
|
||||
if (declarationScope instanceof PsiMethod) {
|
||||
final PsiMethod psiMethod = (PsiMethod)declarationScope;
|
||||
if (!(declarationScope instanceof PsiMethod)) {
|
||||
return null;
|
||||
}
|
||||
final PsiMethod psiMethod = (PsiMethod)declarationScope;
|
||||
|
||||
builder.append(" ");
|
||||
formatMethod(psiMethod, PsiSubstitutor.EMPTY,
|
||||
SHOW_NAME | SHOW_FQ_NAME | SHOW_TYPE | SHOW_PARAMETERS | SHOW_FQ_CLASS_NAMES,
|
||||
showParamName ? SHOW_NAME | SHOW_TYPE | SHOW_FQ_CLASS_NAMES : SHOW_TYPE | SHOW_FQ_CLASS_NAMES, maxParamsToShow, builder);
|
||||
builder.append(" ");
|
||||
builder.append(" ");
|
||||
formatMethod(psiMethod, PsiSubstitutor.EMPTY,
|
||||
SHOW_NAME | SHOW_FQ_NAME | SHOW_TYPE | SHOW_PARAMETERS | SHOW_FQ_CLASS_NAMES,
|
||||
showParamName ? SHOW_NAME | SHOW_TYPE | SHOW_FQ_CLASS_NAMES : SHOW_TYPE | SHOW_FQ_CLASS_NAMES, maxParamsToShow, builder);
|
||||
builder.append(" ");
|
||||
|
||||
if (showParamName) {
|
||||
formatVariable((PsiVariable)owner, SHOW_NAME, PsiSubstitutor.EMPTY, builder);
|
||||
}
|
||||
else {
|
||||
builder.append(psiMethod.getParameterList().getParameterIndex((PsiParameter)owner));
|
||||
}
|
||||
if (showParamName) {
|
||||
formatVariable((PsiVariable)owner, SHOW_NAME, PsiSubstitutor.EMPTY, builder);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
builder.append(psiMethod.getParameterList().getParameterIndex((PsiParameter)owner));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -63,6 +63,23 @@ public class ModuleRootsIndex {
|
||||
return myRootToModuleMap.get(root);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RootDescriptor associateRoot(File root, Module module, boolean isTestRoot) {
|
||||
final RootDescriptor d = myRootToModuleMap.get(root);
|
||||
if (d != null) {
|
||||
return d;
|
||||
}
|
||||
List<RootDescriptor> moduleRoots = myModuleToRootsMap.get(module);
|
||||
if (moduleRoots == null) {
|
||||
moduleRoots = new ArrayList<RootDescriptor>();
|
||||
myModuleToRootsMap.put(module, moduleRoots);
|
||||
}
|
||||
final RootDescriptor descriptor = new RootDescriptor(module, root, false);
|
||||
myRootToModuleMap.put(root, descriptor);
|
||||
moduleRoots.add(descriptor);
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RootDescriptor getModuleAndRoot(File file) {
|
||||
File current = file;
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.*;
|
||||
* Date: 1/21/12
|
||||
*/
|
||||
public class JavacMain {
|
||||
private static final boolean IS_VM_6_VERSION = System.getProperty("java.version", "1.6").contains("1.6");
|
||||
private static final Set<String> FILTERED_OPTIONS = new HashSet<String>(Arrays.<String>asList(
|
||||
"-d", "-classpath", "-cp", "-bootclasspath"
|
||||
));
|
||||
@@ -69,8 +70,13 @@ public class JavacMain {
|
||||
final JavaCompiler.CompilationTask task = compiler.getTask(
|
||||
out, fileManager, outConsumer, _options, null, fileManager.toJavaFileObjects(sources)
|
||||
);
|
||||
final JavacASTAnalyser analyzer = new JavacASTAnalyser(outConsumer, shouldSuppressAnnotationProcessing(options));
|
||||
task.setProcessors(Collections.singleton(analyzer));
|
||||
|
||||
if (!IS_VM_6_VERSION) {
|
||||
// Do not add the processor for JDK 1.6 because of the bugs in javac
|
||||
// The processor's presence may lead to NPE and resolve bugs in compiler
|
||||
final JavacASTAnalyser analyzer = new JavacASTAnalyser(outConsumer, shouldSuppressAnnotationProcessing(options));
|
||||
task.setProcessors(Collections.singleton(analyzer));
|
||||
}
|
||||
return task.call();
|
||||
}
|
||||
catch(IllegalArgumentException e) {
|
||||
|
||||
@@ -1605,7 +1605,7 @@ public class Mappings {
|
||||
}
|
||||
}
|
||||
|
||||
if (delta.isDifferentiated()) {
|
||||
if (delta.isDifferentiated() && false) {
|
||||
for (DependencyContext.S c : delta.getChangedClasses()) {
|
||||
myClassToSubclasses.remove(c);
|
||||
|
||||
@@ -1651,9 +1651,9 @@ public class Mappings {
|
||||
}
|
||||
}
|
||||
else {
|
||||
mySourceFileToClasses.putAll(delta.mySourceFileToClasses);
|
||||
mySourceFileToUsages.putAll(delta.mySourceFileToUsages);
|
||||
mySourceFileToAnnotationUsages.putAll(delta.mySourceFileToAnnotationUsages);
|
||||
mySourceFileToClasses.replaceAll(delta.mySourceFileToClasses);
|
||||
mySourceFileToUsages.replaceAll(delta.mySourceFileToUsages);
|
||||
mySourceFileToAnnotationUsages.replaceAll(delta.mySourceFileToAnnotationUsages);
|
||||
}
|
||||
|
||||
final Collection<DependencyContext.S> compiledSet = new HashSet<DependencyContext.S>(compiled.size());
|
||||
|
||||
@@ -30,7 +30,8 @@ interface MultiMaplet<K, V> {
|
||||
Collection<V> get(final K key);
|
||||
void put(final K key, final V value);
|
||||
void put(final K key, final Collection<V> value);
|
||||
void putAll(MultiMaplet<K, V> m);
|
||||
void putAll(MultiMaplet<K,V> m);
|
||||
void replaceAll(MultiMaplet<K, V> m);
|
||||
void remove(final K key);
|
||||
void removeFrom(final K key, final V value);
|
||||
void removeAll(final K key, final Collection<V> value);
|
||||
|
||||
@@ -141,6 +141,13 @@ class PersistentMultiMaplet<K, V> implements MultiMaplet<K, V> {
|
||||
|
||||
@Override
|
||||
public void putAll(MultiMaplet<K, V> m) {
|
||||
for (Map.Entry<K, Collection<V>> entry : m.entrySet()) {
|
||||
put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceAll(MultiMaplet<K, V> m) {
|
||||
for (Map.Entry<K, Collection<V>> entry : m.entrySet()) {
|
||||
final K key = entry.getKey();
|
||||
remove(key);
|
||||
|
||||
@@ -54,6 +54,13 @@ class TransientMultiMaplet<K, V> implements MultiMaplet<K, V> {
|
||||
return myMap.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(final MultiMaplet<K, V> m) {
|
||||
for (Map.Entry<K, Collection<V>> e : m.entrySet()) {
|
||||
put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(final K key, final Collection<V> value) {
|
||||
final Collection<V> x = myMap.get(key);
|
||||
@@ -102,7 +109,7 @@ class TransientMultiMaplet<K, V> implements MultiMaplet<K, V> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(MultiMaplet<K, V> m) {
|
||||
public void replaceAll(MultiMaplet<K, V> m) {
|
||||
for (Map.Entry<K, Collection<V>> e : m.entrySet()) {
|
||||
remove(e.getKey());
|
||||
put(e.getKey(), e.getValue());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -22,38 +22,101 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Project interface class.
|
||||
*/
|
||||
public interface Project extends ComponentManager, AreaInstance {
|
||||
@NonNls String DIRECTORY_STORE_FOLDER = ".idea";
|
||||
|
||||
@Nullable
|
||||
VirtualFile getProjectFile();
|
||||
|
||||
@Nullable
|
||||
VirtualFile getWorkspaceFile();
|
||||
|
||||
@NotNull
|
||||
String getProjectFilePath();
|
||||
|
||||
@Nullable
|
||||
VirtualFile getBaseDir();
|
||||
|
||||
/**
|
||||
* Returns a name ot the project. For a directory-based project it's an arbitrary string specified by user at project creation
|
||||
* or later in a project settings. For a file-based project it's a name of a project file without extension.
|
||||
*
|
||||
* @return project name
|
||||
*/
|
||||
@NotNull
|
||||
@NonNls
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* <p>Returns a project base directory - a parent directory of a <code>.ipr</code> file or <code>.idea</code> directory.<br/>
|
||||
* Returns <code>null</code> for default project.</p>
|
||||
*
|
||||
* <p>Please note that returned file is always de-referenced, so you have to use use {@linkplain #getBasePath()}
|
||||
* if it's desired to keep symlinks in original path.</p>
|
||||
*
|
||||
* @return project base directory, or null for default project
|
||||
*/
|
||||
@Nullable
|
||||
VirtualFile getBaseDir();
|
||||
|
||||
/**
|
||||
* Returns a system-dependent path to a project base directory (see {@linkplain #getBaseDir()}).<br/>
|
||||
* Returns <code>null</code> for default project.
|
||||
*
|
||||
* @return a path to a project base directory, or empty string for default project
|
||||
*/
|
||||
@Nullable
|
||||
@NonNls
|
||||
String getBasePath();
|
||||
|
||||
/**
|
||||
* <p>Returns project descriptor file:
|
||||
* <ul>
|
||||
* <li><code>path/to/project/project.ipr</code> - for file-based projects</li>
|
||||
* <li><code>path/to/project/.idea/misc.xml</code> - for directory-based projects</li>
|
||||
* </ul>
|
||||
* Returns <code>null</code> for default project.</p>
|
||||
*
|
||||
* <p>Please note that returned file is always de-referenced, so you have to use use {@linkplain #getProjectFilePath()}
|
||||
* if it's desired to keep symlinks in original path.</p>
|
||||
*
|
||||
* @return project descriptor file, or null for default project
|
||||
*/
|
||||
@Nullable
|
||||
VirtualFile getProjectFile();
|
||||
|
||||
/**
|
||||
* Returns a system-dependent path to project descriptor file (see {@linkplain #getProjectFile()}).<br/>
|
||||
* Returns empty string (<code>""</code>) for default project.
|
||||
*
|
||||
* @return project descriptor file, or empty string for default project
|
||||
*/
|
||||
@NotNull
|
||||
@NonNls
|
||||
String getProjectFilePath();
|
||||
|
||||
/**
|
||||
* Returns presentable project path:
|
||||
* {@linkplain #getProjectFilePath()} for file-based projects, {@linkplain #getBasePath()} for directory-based ones.<br/>
|
||||
* <b>Note:</b> the word "presentable" here implies file system presentation, not a UI one.
|
||||
*
|
||||
* @return presentable project path
|
||||
*/
|
||||
@Nullable
|
||||
@NonNls
|
||||
String getPresentableUrl();
|
||||
|
||||
/**
|
||||
* <p>Returns a workspace file:
|
||||
* <ul>
|
||||
* <li><code>path/to/project/project.iws</code> - for file-based projects</li>
|
||||
* <li><code>path/to/project/.idea/workspace.xml</code> - for directory-based ones</li>
|
||||
* </ul>
|
||||
* Returns <code>null</code> for default project.
|
||||
*
|
||||
* @return workspace file, or null for default project
|
||||
*/
|
||||
@Nullable
|
||||
VirtualFile getWorkspaceFile();
|
||||
|
||||
@NotNull
|
||||
@NonNls
|
||||
String getLocationHash();
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated please use {@linkplain #getPresentableUrl()} or {@linkplain #getBasePath()} (to remove in IDEA 13).
|
||||
*/
|
||||
@Nullable
|
||||
@NonNls
|
||||
String getLocation();
|
||||
|
||||
@@ -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.
|
||||
@@ -117,6 +117,11 @@ public class MockProject extends MockComponentManager implements Project {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -429,15 +429,13 @@ public class AnalysisScope {
|
||||
return AnalysisScopeBundle.message("scope.module.list", modules, Integer.valueOf(myModules.size()));
|
||||
|
||||
case PROJECT:
|
||||
return AnalysisScopeBundle.message("scope.project", pathToName(myProject.getPresentableUrl()));
|
||||
return AnalysisScopeBundle.message("scope.project", myProject.getName());
|
||||
|
||||
case FILE:
|
||||
final VirtualFile virtualFile = ((PsiFileSystemItem)myElement).getVirtualFile();
|
||||
LOG.assertTrue(virtualFile != null);
|
||||
return AnalysisScopeBundle.message("scope.file", virtualFile.getPresentableUrl());
|
||||
return AnalysisScopeBundle.message("scope.file", getPresentableUrl((PsiFileSystemItem)myElement));
|
||||
|
||||
case DIRECTORY:
|
||||
return AnalysisScopeBundle.message("scope.directory", ((PsiFileSystemItem)myElement).getVirtualFile().getPresentableUrl());
|
||||
return AnalysisScopeBundle.message("scope.directory", getPresentableUrl((PsiFileSystemItem)myElement));
|
||||
|
||||
case VIRTUAL_FILES:
|
||||
return AnalysisScopeBundle.message("scope.virtual.files");
|
||||
@@ -446,6 +444,12 @@ public class AnalysisScope {
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String getPresentableUrl(final PsiFileSystemItem element) {
|
||||
final VirtualFile virtualFile = element.getVirtualFile();
|
||||
assert virtualFile != null : element;
|
||||
return virtualFile.getPresentableUrl();
|
||||
}
|
||||
|
||||
public String getShortenName(){
|
||||
switch (myType) {
|
||||
case CUSTOM:
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public interface FilterMixin {
|
||||
boolean shouldRunHeavy();
|
||||
@Nullable
|
||||
void applyHeavyFilter(Document copiedFragment, int startOffset, int startLineNumber, Consumer<AdditionalHighlight> consumer);
|
||||
|
||||
String getUpdateMessage();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -13,10 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.openapi.project;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
@@ -40,24 +36,29 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ProjectUtil {
|
||||
@NonNls public static final String DIRECTORY_BASED_PROJECT_DIR = ".idea";
|
||||
|
||||
private ProjectUtil() {
|
||||
}
|
||||
private ProjectUtil() { }
|
||||
|
||||
@Nullable
|
||||
public static String getProjectLocationString(@NotNull final Project project) {
|
||||
String projectPath = project.getLocation();
|
||||
return FileUtil.getLocationRelativeToUserHome(projectPath);
|
||||
return FileUtil.getLocationRelativeToUserHome(project.getBasePath());
|
||||
}
|
||||
|
||||
public static String calcRelativeToProjectPath(final VirtualFile file, final Project project, final boolean includeFilePath) {
|
||||
@NotNull
|
||||
public static String calcRelativeToProjectPath(@NotNull final VirtualFile file,
|
||||
@Nullable final Project project,
|
||||
final boolean includeFilePath) {
|
||||
return calcRelativeToProjectPath(file, project, includeFilePath, false);
|
||||
}
|
||||
|
||||
public static String calcRelativeToProjectPath(final VirtualFile file,
|
||||
final Project project,
|
||||
@NotNull
|
||||
public static String calcRelativeToProjectPath(@NotNull final VirtualFile file,
|
||||
@Nullable final Project project,
|
||||
final boolean includeFilePath,
|
||||
final boolean keepModuleAlwaysOnTheLeft) {
|
||||
if (file instanceof VirtualFilePathWrapper) {
|
||||
|
||||
+2
-2
@@ -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.
|
||||
@@ -389,7 +389,7 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
private static Set<VirtualFile> getIgnoreRoots(@NotNull Project project) {
|
||||
Set<VirtualFile> result = new HashSet<VirtualFile>();
|
||||
|
||||
String location = project.getLocation();
|
||||
String location = project.getBasePath();
|
||||
if (location != null) {
|
||||
File projectDir = new File(location, Project.DIRECTORY_STORE_FOLDER);
|
||||
if (projectDir.isDirectory()) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.actionSystem.ex.AnActionListener;
|
||||
import com.intellij.openapi.application.ApplicationAdapter;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.actionSystem.TypedAction;
|
||||
import com.intellij.openapi.editor.event.*;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
|
||||
@@ -284,7 +285,6 @@ public abstract class CompletionPhase implements Disposable {
|
||||
private final CaretListener caretListener;
|
||||
private final DocumentAdapter documentListener;
|
||||
private final PropertyChangeListener lookupListener;
|
||||
private boolean changeGuard = false;
|
||||
private final SelectionListener selectionListener;
|
||||
|
||||
public EmptyAutoPopup(CompletionProgressIndicator indicator) {
|
||||
@@ -309,7 +309,7 @@ public abstract class CompletionPhase implements Disposable {
|
||||
caretListener = new CaretListener() {
|
||||
@Override
|
||||
public void caretPositionChanged(CaretEvent e) {
|
||||
if (!changeGuard) {
|
||||
if (!TypedAction.isTypedActionInProgress()) {
|
||||
stopAutoPopup();
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,7 @@ public abstract class CompletionPhase implements Disposable {
|
||||
documentListener = new DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent e) {
|
||||
if (!changeGuard) {
|
||||
if (!TypedAction.isTypedActionInProgress()) {
|
||||
stopAutoPopup();
|
||||
}
|
||||
}
|
||||
@@ -351,16 +351,6 @@ public abstract class CompletionPhase implements Disposable {
|
||||
LookupManager.getInstance(project).removePropertyChangeListener(lookupListener);
|
||||
}
|
||||
|
||||
public void handleTyping(char c) {
|
||||
changeGuard = true;
|
||||
try {
|
||||
EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, String.valueOf(c), true);
|
||||
}
|
||||
finally {
|
||||
changeGuard = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void stopAutoPopup() {
|
||||
CompletionServiceImpl.setCompletionPhase(NoCompletion);
|
||||
}
|
||||
|
||||
-20
@@ -27,7 +27,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
@@ -42,25 +41,6 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.CompletionAutoPopupHandler");
|
||||
public static volatile boolean ourTestingAutopopup = false;
|
||||
|
||||
@Override
|
||||
public Result beforeCharTyped(char c,
|
||||
Project project,
|
||||
Editor editor,
|
||||
PsiFile file,
|
||||
FileType fileType) {
|
||||
CompletionPhase phase = CompletionServiceImpl.getCompletionPhase();
|
||||
/*
|
||||
if (phase instanceof CompletionPhase.EmptyAutoPopup) {
|
||||
long modificationStampBeforeTyping = editor.getDocument().getModificationStamp();
|
||||
((CompletionPhase.EmptyAutoPopup)phase).handleTyping(c);
|
||||
AutoHardWrapHandler.getInstance().wrapLineIfNecessary(editor, DataManager.getInstance().getDataContext(editor.getContentComponent()), modificationStampBeforeTyping);
|
||||
return Result.STOP;
|
||||
}
|
||||
*/
|
||||
|
||||
return Result.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result checkAutoPopup(char charTyped, final Project project, final Editor editor, final PsiFile file) {
|
||||
CompletionPhase oldPhase = CompletionServiceImpl.getCompletionPhase();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -295,7 +295,9 @@ public class ConversionServiceImpl extends ConversionService {
|
||||
@NotNull
|
||||
public ConversionResult convertModule(@NotNull final Project project, @NotNull final File moduleFile) {
|
||||
final IProjectStore stateStore = ((ProjectImpl)project).getStateStore();
|
||||
String projectPath = FileUtil.toSystemDependentName(stateStore.getLocation());
|
||||
final String url = stateStore.getPresentableUrl();
|
||||
assert url != null : project;
|
||||
final String projectPath = FileUtil.toSystemDependentName(url);
|
||||
|
||||
if (!isConversionNeeded(projectPath, moduleFile)) {
|
||||
return ConversionResultImpl.CONVERSION_NOT_NEEDED;
|
||||
@@ -322,7 +324,7 @@ public class ConversionServiceImpl extends ConversionService {
|
||||
}
|
||||
}
|
||||
context.saveFiles(Collections.singletonList(moduleFile));
|
||||
Messages.showInfoMessage(project, IdeBundle.message("message.your.module.was.succesfully.converted.br.old.version.was.saved.to.0", backupFile.getAbsolutePath()),
|
||||
Messages.showInfoMessage(project, IdeBundle.message("message.your.module.was.successfully.converted.br.old.version.was.saved.to.0", backupFile.getAbsolutePath()),
|
||||
IdeBundle.message("dialog.title.convert.module"));
|
||||
return new ConversionResultImpl(runners);
|
||||
}
|
||||
|
||||
@@ -20,78 +20,60 @@
|
||||
*/
|
||||
package com.intellij.execution;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
|
||||
public class TerminateRemoteProcessDialog extends DialogWrapper {
|
||||
private static final int ICON_TEXT_GAP = 7;
|
||||
private JCheckBox myTerminateCheckBox;
|
||||
private final String mySessionName;
|
||||
private final boolean myDetachIsDefault;
|
||||
private final boolean myAlwaysUseDefault;
|
||||
|
||||
public TerminateRemoteProcessDialog(final Project project,
|
||||
final String configurationName,
|
||||
final boolean detachIsDefault,
|
||||
boolean alwaysUseDefault) {
|
||||
super(project, true);
|
||||
mySessionName = configurationName;
|
||||
myDetachIsDefault = detachIsDefault;
|
||||
myAlwaysUseDefault = alwaysUseDefault;
|
||||
setTitle(ExecutionBundle.message("process.is.running.dialog.title", mySessionName));
|
||||
setOKButtonText(alwaysUseDefault && !detachIsDefault ? ExecutionBundle.message("button.terminate")
|
||||
: ExecutionBundle.message("button.disconnect"));
|
||||
setButtonsAlignment(SwingUtilities.CENTER);
|
||||
this.init();
|
||||
public class TerminateRemoteProcessDialog {
|
||||
public static int show(final Project project,
|
||||
final String sessionName,
|
||||
final TerminateOption option) {
|
||||
final String message = option.myAlwaysUseDefault && !option.myDetachIsDefault ?
|
||||
ExecutionBundle.message("terminate.process.confirmation.text", sessionName) :
|
||||
ExecutionBundle.message("disconnect.process.confirmation.text", sessionName);
|
||||
final String okButtonText = option.myAlwaysUseDefault && !option.myDetachIsDefault ?
|
||||
ExecutionBundle.message("button.terminate") :
|
||||
ExecutionBundle.message("button.disconnect");
|
||||
final String[] options = new String[] {okButtonText, CommonBundle.getCancelButtonText()};
|
||||
return Messages.showDialog(project, message, ExecutionBundle.message("process.is.running.dialog.title", sessionName),
|
||||
options, 0, Messages.getWarningIcon(),
|
||||
option);
|
||||
}
|
||||
|
||||
protected Action[] createActions(){
|
||||
return new Action[]{getOKAction(), getCancelAction()};
|
||||
}
|
||||
public static class TerminateOption implements DialogWrapper.DoNotAskOption {
|
||||
private final boolean myDetachIsDefault;
|
||||
private final boolean myAlwaysUseDefault;
|
||||
private boolean myDontTerminate = false;
|
||||
|
||||
protected JComponent createNorthPanel() {
|
||||
final String message = myAlwaysUseDefault && !myDetachIsDefault ?
|
||||
ExecutionBundle.message("terminate.process.confirmation.text", mySessionName) :
|
||||
ExecutionBundle.message("disconnect.process.confirmation.text", mySessionName);
|
||||
final JLabel label = new JLabel(message);
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(label, BorderLayout.CENTER);
|
||||
final Icon icon = UIUtil.getOptionPanelWarningIcon();
|
||||
if (icon != null) {
|
||||
label.setIcon(icon);
|
||||
label.setIconTextGap(ICON_TEXT_GAP);
|
||||
public TerminateOption(boolean detachIsDefault, boolean alwaysUseDefault) {
|
||||
myDetachIsDefault = detachIsDefault;
|
||||
myAlwaysUseDefault = alwaysUseDefault;
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected JComponent createCenterPanel() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
if (!myAlwaysUseDefault) {
|
||||
myTerminateCheckBox = new JCheckBox(ExecutionBundle.message("terminate.after.disconnect.checkbox"));
|
||||
myTerminateCheckBox.setSelected(!myDetachIsDefault);
|
||||
final Icon icon = UIUtil.getOptionPanelWarningIcon();
|
||||
if (icon != null) {
|
||||
final Border border = myTerminateCheckBox.getBorder();
|
||||
if (border != null) {
|
||||
final Insets insets = border.getBorderInsets(myTerminateCheckBox);
|
||||
final Border emptyBorder = BorderFactory.createEmptyBorder(0, icon.getIconWidth()+ICON_TEXT_GAP-insets.left, 0, 0);
|
||||
myTerminateCheckBox.setBorder(BorderFactory.createCompoundBorder(emptyBorder, border));
|
||||
}
|
||||
else {
|
||||
myTerminateCheckBox.setBorder(BorderFactory.createEmptyBorder(0, icon.getIconWidth()+ICON_TEXT_GAP, 0, 0));
|
||||
}
|
||||
}
|
||||
panel.add(myTerminateCheckBox, BorderLayout.WEST);
|
||||
@Override
|
||||
public boolean isToBeShown() {
|
||||
return myAlwaysUseDefault ? !myDetachIsDefault : myDontTerminate;
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
public boolean forceTermination() {
|
||||
return myAlwaysUseDefault ? !myDetachIsDefault : myTerminateCheckBox.isSelected();
|
||||
@Override
|
||||
public void setToBeShown(boolean value, int exitCode) {
|
||||
myDontTerminate = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
return !myAlwaysUseDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSaveOptionsOnCancel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDoNotShowMessage() {
|
||||
return ExecutionBundle.message("terminate.after.disconnect.checkbox");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -75,7 +75,7 @@ public class ConsoleHistoryController {
|
||||
@NotNull final LanguageConsoleImpl console,
|
||||
@NotNull final ConsoleHistoryModel model) {
|
||||
myType = type;
|
||||
myId = StringUtil.isEmpty(persistenceId)? console.getProject().getLocation() : persistenceId;
|
||||
myId = StringUtil.isEmpty(persistenceId)? console.getProject().getPresentableUrl() : persistenceId;
|
||||
myConsole = console;
|
||||
myModel = model;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
|
||||
import com.intellij.openapi.editor.impl.EditorFactoryImpl;
|
||||
import com.intellij.openapi.editor.impl.EditorHeaderComponent;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
import com.intellij.openapi.editor.markup.*;
|
||||
import com.intellij.openapi.fileEditor.*;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
@@ -551,7 +553,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
@Override
|
||||
public void fileClosed(FileEditorManager source, VirtualFile file) {
|
||||
if (file != myFile.getVirtualFile()) return;
|
||||
if (myUiUpdateRunnable != null) {
|
||||
if (myUiUpdateRunnable != null && !Boolean.TRUE.equals(file.getUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN))) {
|
||||
ApplicationManager.getApplication().runReadAction(myUiUpdateRunnable);
|
||||
}
|
||||
}
|
||||
@@ -600,10 +602,13 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
|
||||
private void configureFullEditor(final Editor editor) {
|
||||
if (editor == null || myFullEditorActions == null || editor == myConsoleEditor) return;
|
||||
final JPanel header = new JPanel(new BorderLayout());
|
||||
final JPanel header = new EditorHeaderComponent();
|
||||
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, myFullEditorActions, true);
|
||||
actionToolbar.setTargetComponent(editor.getContentComponent());
|
||||
header.add(actionToolbar.getComponent(), BorderLayout.EAST);
|
||||
JComponent component = actionToolbar.getComponent();
|
||||
component.setOpaque(false);
|
||||
header.add(component, BorderLayout.EAST);
|
||||
editor.putUserData(EditorImpl.PERMANENT_HEADER, header);
|
||||
editor.setHeaderComponent(header);
|
||||
editor.getSettings().setLineMarkerAreaShown(false);
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
flushDeferredUserInput();
|
||||
}
|
||||
}
|
||||
if (myFlushAlarm.getActiveRequestCount() == 0 && myEditor != null && !myFlushAlarm.isDisposed()) {
|
||||
if (myEditor != null && !myFlushAlarm.isDisposed()) {
|
||||
final boolean shouldFlushNow = myBuffer.isUseCyclicBuffer() && myBuffer.getLength() >= myBuffer.getCyclicBufferSize();
|
||||
myFlushAlarm.addRequest(myFlushDeferredRunnable, shouldFlushNow ? 0 : FLUSH_DELAY, getStateForUpdate());
|
||||
}
|
||||
@@ -541,6 +541,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
myEditor.getMarkupModel().removeAllHighlighters();
|
||||
document = myEditor.getDocument();
|
||||
myFoldingAlarm.cancelAllRequests();
|
||||
cancelHeavyAlarm();
|
||||
}
|
||||
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
|
||||
public void run() {
|
||||
@@ -862,21 +863,25 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
@Override
|
||||
public void run() {
|
||||
if (! myPredefinedMessageFilter.shouldRunHeavy()) return;
|
||||
myPredefinedMessageFilter.applyHeavyFilter(documentCopy, startOffset, startLine, new Consumer<FilterMixin.AdditionalHighlight>() {
|
||||
@Override
|
||||
public void consume(final FilterMixin.AdditionalHighlight additionalHighlight) {
|
||||
if (myFlushAlarm.isDisposed()) return;
|
||||
myFlushAlarm.addRequest(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myHeavyUpdateTicket != currentValue) return;
|
||||
myHyperlinks.adjustHighlighters(Collections.singletonList(additionalHighlight));
|
||||
}
|
||||
}, 0, getStateForUpdate());
|
||||
try {
|
||||
myPredefinedMessageFilter.applyHeavyFilter(documentCopy, startOffset, startLine, new Consumer<FilterMixin.AdditionalHighlight>() {
|
||||
@Override
|
||||
public void consume(final FilterMixin.AdditionalHighlight additionalHighlight) {
|
||||
if (myFlushAlarm.isDisposed()) return;
|
||||
myFlushAlarm.addRequest(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myHeavyUpdateTicket != currentValue) return;
|
||||
myHyperlinks.adjustHighlighters(Collections.singletonList(additionalHighlight));
|
||||
}
|
||||
}, 0, getStateForUpdate());
|
||||
}
|
||||
});
|
||||
}
|
||||
finally {
|
||||
if (myHeavyAlarm.getActiveRequestCount() == 0) {
|
||||
SwingUtilities.invokeLater(myFinishProgress);
|
||||
}
|
||||
});
|
||||
if (myHeavyAlarm.getActiveRequestCount() == 0) {
|
||||
SwingUtilities.invokeLater(myFinishProgress);
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
|
||||
@@ -48,7 +48,6 @@ import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerAdapter;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
||||
import com.intellij.ui.content.*;
|
||||
import com.intellij.ui.content.impl.ContentImpl;
|
||||
import com.intellij.ui.docking.DockManager;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -616,12 +615,10 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
|
||||
else {
|
||||
//todo[nik] this is a temporary solution for the following problem: some configurations should not allow user to choose between 'terminating' and 'detaching'
|
||||
final boolean useDefault = Boolean.TRUE.equals(processHandler.getUserData(ALWAYS_USE_DEFAULT_STOPPING_BEHAVIOUR_KEY));
|
||||
final TerminateRemoteProcessDialog terminateDialog = new TerminateRemoteProcessDialog(myProject, descriptor.getDisplayName(),
|
||||
processHandler.detachIsDefault(),
|
||||
useDefault);
|
||||
terminateDialog.show();
|
||||
if (terminateDialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) return false;
|
||||
destroyProcess = terminateDialog.forceTermination();
|
||||
final TerminateRemoteProcessDialog.TerminateOption option = new TerminateRemoteProcessDialog.TerminateOption(processHandler.detachIsDefault(), useDefault);
|
||||
final int rc = TerminateRemoteProcessDialog.show(myProject, descriptor.getDisplayName(), option);
|
||||
if (rc != DialogWrapper.OK_EXIT_CODE) return false;
|
||||
destroyProcess = !option.isToBeShown();
|
||||
}
|
||||
if (destroyProcess) {
|
||||
processHandler.destroyProcess();
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.editor.event.SelectionEvent;
|
||||
import com.intellij.openapi.editor.event.SelectionListener;
|
||||
import com.intellij.openapi.editor.impl.EditorHeaderComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -38,7 +39,6 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.LightColors;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
@@ -61,7 +61,7 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* @author max, andrey.zaytsev
|
||||
*/
|
||||
public class EditorSearchComponent extends JPanel implements DataProvider, SelectionListener, SearchResults.SearchResultsListener,
|
||||
public class EditorSearchComponent extends EditorHeaderComponent implements DataProvider, SelectionListener, SearchResults.SearchResultsListener,
|
||||
LivePreviewControllerBase.ReplaceListener {
|
||||
private static final int MATCHES_LIMIT = 10000;
|
||||
|
||||
@@ -104,10 +104,6 @@ public class EditorSearchComponent extends JPanel implements DataProvider, Selec
|
||||
private JButton myReplaceAllButton;
|
||||
private JButton myExcludeButton;
|
||||
|
||||
private final Color GRADIENT_C1;
|
||||
private final Color GRADIENT_C2;
|
||||
|
||||
private static final Color BORDER_COLOR = Gray._135;
|
||||
public static final Color COMPLETION_BACKGROUND_COLOR = new Color(235, 244, 254);
|
||||
private static final Color FOCUS_CATCHER_COLOR = new Color(0x9999ff);
|
||||
|
||||
@@ -222,12 +218,8 @@ public class EditorSearchComponent extends JPanel implements DataProvider, Selec
|
||||
public void editorChanged(SearchResults sr, Editor oldEditor) { }
|
||||
|
||||
public EditorSearchComponent(final Editor editor, final Project project, FindModel findModel) {
|
||||
super(new BorderLayout(0, 0));
|
||||
myFindModel = findModel;
|
||||
|
||||
GRADIENT_C1 = getBackground();
|
||||
GRADIENT_C2 = new Color(Math.max(0, GRADIENT_C1.getRed() - 0x18), Math.max(0, GRADIENT_C1.getGreen() - 0x18), Math.max(0, GRADIENT_C1.getBlue() - 0x18));
|
||||
|
||||
myProject = project;
|
||||
myEditor = editor;
|
||||
|
||||
@@ -876,21 +868,6 @@ public class EditorSearchComponent extends JPanel implements DataProvider, Selec
|
||||
return insets;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
final Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
if (!UIUtil.isUnderGTKLookAndFeel()) {
|
||||
g2d.setPaint(new GradientPaint(0, 0, GRADIENT_C1, 0, getHeight(), GRADIENT_C2));
|
||||
g2d.fillRect(1, 1, getWidth(), getHeight() - 1);
|
||||
g2d.setPaint(null);
|
||||
}
|
||||
|
||||
g.setColor(BORDER_COLOR);
|
||||
g.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
|
||||
}
|
||||
|
||||
private class MyLivePreviewController extends LivePreviewControllerBase {
|
||||
public MyLivePreviewController() {
|
||||
super(EditorSearchComponent.this.mySearchResults, EditorSearchComponent.this.myLivePreview);
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorLocation;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
@@ -468,23 +469,23 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
|
||||
KeyboardShortcut shortcut = getSettingsShortcut();
|
||||
if (shortcut != null) {
|
||||
builder.registerKeyboardAction(shortcut.getFirstKeyStroke(), new ActionListener() {
|
||||
new DumbAwareAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
popup[0].cancel();
|
||||
showDialogAndFindUsages(handler, popupPosition, editor, maxUsages);
|
||||
}
|
||||
});
|
||||
}.registerCustomShortcutSet(new CustomShortcutSet(shortcut.getFirstKeyStroke()), table);
|
||||
}
|
||||
shortcut = getShowUsagesShortcut();
|
||||
if (shortcut != null) {
|
||||
builder.registerKeyboardAction(shortcut.getFirstKeyStroke(), new ActionListener() {
|
||||
new DumbAwareAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
popup[0].cancel();
|
||||
searchEverywhere(options, handler, editor, popupPosition, maxUsages);
|
||||
}
|
||||
});
|
||||
}.registerCustomShortcutSet(new CustomShortcutSet(shortcut.getFirstKeyStroke()), table);
|
||||
}
|
||||
|
||||
InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, new Runnable() {
|
||||
|
||||
@@ -509,15 +509,7 @@ public class FindInProjectUtil {
|
||||
|
||||
fast |= findModel.isWholeWordsOnly() && findModel.getStringToFind().indexOf('$') < 0;
|
||||
|
||||
List<String> words = StringUtil.getWordsIn(findModel.getStringToFind());
|
||||
|
||||
// hope long words are rare
|
||||
Collections.sort(words, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(final String o1, final String o2) {
|
||||
return o2.length() - o1.length();
|
||||
}
|
||||
});
|
||||
List<String> words = StringUtil.getWordsInStringLongestFirst(findModel.getStringToFind());
|
||||
|
||||
for (int i = 0; i < words.size(); i++) {
|
||||
String word = words.get(i);
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.ide.actions;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.impl.PresentationFactory;
|
||||
import com.intellij.openapi.actionSystem.impl.Utils;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -29,6 +30,7 @@ import java.util.ArrayList;
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class WeighingActionGroup extends ActionGroup {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.WeighingActionGroup");
|
||||
private final PresentationFactory myPresentationFactory = new PresentationFactory();
|
||||
|
||||
@Override
|
||||
@@ -40,9 +42,13 @@ public abstract class WeighingActionGroup extends ActionGroup {
|
||||
|
||||
private static void getAllChildren(@Nullable AnActionEvent e, ActionGroup group, List<AnAction> result) {
|
||||
for (final AnAction action : group.getChildren(e)) {
|
||||
if (action instanceof ActionGroup && !((ActionGroup) action).isPopup()) {
|
||||
getAllChildren(e, (ActionGroup) action, result);
|
||||
} else {
|
||||
if (action == null) {
|
||||
LOG.error("Null child for " + group);
|
||||
}
|
||||
if (action instanceof ActionGroup && !((ActionGroup)action).isPopup()) {
|
||||
getAllChildren(e, (ActionGroup)action, result);
|
||||
}
|
||||
else {
|
||||
result.add(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -39,7 +39,6 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -61,7 +60,6 @@ import com.intellij.openapi.ui.SimpleToolWindowPanel;
|
||||
import com.intellij.openapi.ui.SplitterProportionsData;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -75,6 +73,7 @@ import com.intellij.openapi.wm.impl.content.ToolWindowContentUi;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.file.PsiDirectoryFactory;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.ui.AutoScrollFromSourceHandler;
|
||||
import com.intellij.ui.AutoScrollToSourceHandler;
|
||||
import com.intellij.ui.GuiUtils;
|
||||
@@ -157,7 +156,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
@Deprecated static final String PROJECT_VIEW_DATA_CONSTANT = DATA_KEY.getName();
|
||||
|
||||
private DefaultActionGroup myActionGroup;
|
||||
private final Runnable myTreeChangeListener;
|
||||
private String mySavedPaneId = ProjectViewPane.ID;
|
||||
private String mySavedPaneSubId;
|
||||
//private static final Icon COMPACT_EMPTY_MIDDLE_PACKAGES_ICON = IconLoader.getIcon("/objectBrowser/compactEmptyPackages.png");
|
||||
@@ -200,11 +198,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
|
||||
Disposer.register(myProject, this);
|
||||
myFileEditorManager = fileEditorManager;
|
||||
myTreeChangeListener = new Runnable() {
|
||||
public void run() {
|
||||
updateToolWindowTitle();
|
||||
}
|
||||
};
|
||||
|
||||
myConnection = project.getMessageBus().connect();
|
||||
myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
@@ -474,15 +467,13 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
createToolbarActions();
|
||||
updateTitleActions();
|
||||
|
||||
newPane.setTreeChangeListener(myTreeChangeListener);
|
||||
myAutoScrollToSourceHandler.install(newPane.myTree);
|
||||
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(newPane.getComponentToFocus(), false);
|
||||
updateToolWindowTitle();
|
||||
|
||||
newPane.restoreExpandedPaths();
|
||||
if (selectedPsiElement != null) {
|
||||
final VirtualFile virtualFile = PsiUtilBase.getVirtualFile(selectedPsiElement);
|
||||
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(selectedPsiElement);
|
||||
if (virtualFile != null && ((ProjectViewSelectInTarget)newPane.createSelectInTarget()).isSubIdSelectable(newSubId, new SelectInContext() {
|
||||
@NotNull
|
||||
public Project getProject() {
|
||||
@@ -754,49 +745,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
return myCurrentViewId;
|
||||
}
|
||||
|
||||
private void updateToolWindowTitle() {
|
||||
if (true) return;
|
||||
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
|
||||
ToolWindow toolWindow = toolWindowManager == null ? null : toolWindowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
|
||||
if (toolWindow == null) return;
|
||||
String title = null;
|
||||
final AbstractProjectViewPane pane = getCurrentProjectViewPane();
|
||||
if (pane != null) {
|
||||
final DefaultMutableTreeNode selectedNode = pane.getSelectedNode();
|
||||
if (selectedNode != null) {
|
||||
final Object o = selectedNode.getUserObject();
|
||||
if (o instanceof ProjectViewNode) {
|
||||
title = ((ProjectViewNode)o).getTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (title == null) {
|
||||
if (true) return;
|
||||
|
||||
final PsiElement element = (PsiElement)myDataProvider.getData(LangDataKeys.PSI_ELEMENT.getName());
|
||||
if (element != null) {
|
||||
PsiFile file = element.getContainingFile();
|
||||
if (file != null) {
|
||||
title = FileUtil.getLocationRelativeToUserHome(file.getVirtualFile().getPresentableUrl());
|
||||
}
|
||||
else if (element instanceof PsiDirectory) {
|
||||
title = PsiDirectoryFactory.getInstance(myProject).getQualifiedName((PsiDirectory) element, true);
|
||||
}
|
||||
else {
|
||||
title = element.toString();
|
||||
}
|
||||
}
|
||||
else {
|
||||
title = "";
|
||||
if (myProject != null) {
|
||||
title = FileUtil.getLocationRelativeToUserHome(myProject.getPresentableUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toolWindow.setTitle(title);
|
||||
}
|
||||
|
||||
public PsiElement getParentOfCurrentSelection() {
|
||||
final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
|
||||
if (viewPane == null) {
|
||||
|
||||
@@ -781,7 +781,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
if (scope instanceof LocalSearchScope) {
|
||||
registerRequest(locals, primitive, processor);
|
||||
} else {
|
||||
final List<String> words = StringUtil.getWordsIn(primitive.word);
|
||||
final List<String> words = StringUtil.getWordsInStringLongestFirst(primitive.word);
|
||||
final Set<IdIndexEntry> key = new HashSet<IdIndexEntry>(words.size() * 2);
|
||||
for (String word : words) {
|
||||
key.add(new IdIndexEntry(word, primitive.caseSensitive));
|
||||
@@ -857,7 +857,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
}
|
||||
|
||||
private static ArrayList<IdIndexEntry> getWordEntries(String name, boolean caseSensitively) {
|
||||
List<String> words = StringUtil.getWordsIn(name);
|
||||
List<String> words = StringUtil.getWordsInStringLongestFirst(name);
|
||||
final ArrayList<IdIndexEntry> keys = new ArrayList<IdIndexEntry>();
|
||||
for (String word : words) {
|
||||
keys.add(new IdIndexEntry(word, caseSensitively));
|
||||
|
||||
@@ -199,10 +199,13 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
index.getReadLock().lock();
|
||||
final ValueContainer<TIntArrayList> container = index.getData(key);
|
||||
|
||||
final FileBasedIndex.ProjectIndexableFilesFilter projectFilesFilter = FileBasedIndex.getInstance().projectIndexableFiles(project);
|
||||
|
||||
container.forEach(new ValueContainer.ContainerAction<TIntArrayList>() {
|
||||
@Override
|
||||
public void perform(final int id, final TIntArrayList value) {
|
||||
ProgressManager.checkCanceled();
|
||||
if (projectFilesFilter != null && !projectFilesFilter.contains(id)) return;
|
||||
final VirtualFile file = IndexInfrastructure.findFileByIdIfCached(fs, id);
|
||||
if (file == null || scope != null && !scope.contains(file)) {
|
||||
return;
|
||||
|
||||
@@ -77,6 +77,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@@ -122,6 +123,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
private final boolean myIsUnitTestMode;
|
||||
private ScheduledFuture<?> myFlushingFuture;
|
||||
private volatile int myLocalModCount;
|
||||
private volatile int myFilesModCount;
|
||||
|
||||
public void requestReindex(final VirtualFile file) {
|
||||
myChangedFilesCollector.invalidateIndices(file, true);
|
||||
@@ -860,7 +862,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
|
||||
|
||||
private <K, V, R> R processExceptions(final ID<K, V> indexId,
|
||||
@Nullable final VirtualFile restrictToFile,
|
||||
@Nullable final VirtualFile restrictToFile,
|
||||
final GlobalSearchScope filter,
|
||||
ThrowableConvertor<UpdatableIndex<K, V, FileContent>, R, StorageException> computable) {
|
||||
try {
|
||||
@@ -921,10 +923,12 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
else {
|
||||
final PersistentFS fs = (PersistentFS)ManagingFS.getInstance();
|
||||
ProjectIndexableFilesFilter projectFilesSet = projectIndexableFiles(filter.getProject());
|
||||
VALUES_LOOP: for (final Iterator<V> valueIt = container.getValueIterator(); valueIt.hasNext();) {
|
||||
final V value = valueIt.next();
|
||||
for (final ValueContainer.IntIterator inputIdsIterator = container.getInputIdsIterator(value); inputIdsIterator.hasNext();) {
|
||||
final int id = inputIdsIterator.next();
|
||||
if (projectFilesSet != null && !projectFilesSet.contains(id)) continue;
|
||||
VirtualFile file = IndexInfrastructure.findFileByIdIfCached(fs, id);
|
||||
if (file != null && filter.accept(file)) {
|
||||
shouldContinue = processor.process(file, value);
|
||||
@@ -944,24 +948,70 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
final Boolean result = processExceptions(indexId, restrictToFile, filter, keyProcessor);
|
||||
return result == null || result.booleanValue();
|
||||
}
|
||||
|
||||
|
||||
public <K, V> boolean processFilesContainingAllKeys(final ID<K, V> indexId,
|
||||
final Collection<K> dataKeys,
|
||||
final GlobalSearchScope filter,
|
||||
@Nullable Condition<V> valueChecker,
|
||||
final Processor<VirtualFile> processor) {
|
||||
final TIntHashSet set = collectFileIdsContainingAllKeys(indexId, dataKeys, filter, valueChecker);
|
||||
ProjectIndexableFilesFilter filesSet = projectIndexableFiles(filter.getProject());
|
||||
final TIntHashSet set = collectFileIdsContainingAllKeys(indexId, dataKeys, filter, valueChecker, filesSet);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
return processVirtualFiles(set, filter, processor);
|
||||
}
|
||||
|
||||
private static final Key<SoftReference<ProjectIndexableFilesFilter>> ourProjectFilesSetKey = Key.create("projectFiles");
|
||||
|
||||
public static final class ProjectIndexableFilesFilter extends BloomFilterBase {
|
||||
private static final int MAGIC = 0x278DDE6D;
|
||||
private final int myModificationCount;
|
||||
|
||||
private ProjectIndexableFilesFilter(TIntHashSet set, int modificationCount) {
|
||||
super(set.size(), 0.005d);
|
||||
myModificationCount = modificationCount;
|
||||
set.forEach(new TIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(int value) {
|
||||
addIt(value, value * MAGIC);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean contains(int id) {
|
||||
return maybeContains(id, id * MAGIC);
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable ProjectIndexableFilesFilter projectIndexableFiles(Project project) {
|
||||
if (project == null) return null;
|
||||
|
||||
SoftReference<ProjectIndexableFilesFilter> reference = project.getUserData(ourProjectFilesSetKey);
|
||||
ProjectIndexableFilesFilter data = reference != null ? reference.get() : null;
|
||||
if (data != null && data.myModificationCount == myFilesModCount) return data;
|
||||
|
||||
final TIntHashSet filesSet = new TIntHashSet();
|
||||
iterateIndexableFiles(new ContentIterator() {
|
||||
@Override
|
||||
public boolean processFile(VirtualFile fileOrDir) {
|
||||
filesSet.add(((VirtualFileWithId)fileOrDir).getId());
|
||||
return true;
|
||||
}
|
||||
}, project, ProgressManager.getInstance().getProgressIndicator());
|
||||
ProjectIndexableFilesFilter files = new ProjectIndexableFilesFilter(filesSet, myFilesModCount);
|
||||
project.putUserData(ourProjectFilesSetKey, new SoftReference<ProjectIndexableFilesFilter>(files));
|
||||
return files;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <K, V> TIntHashSet collectFileIdsContainingAllKeys(final ID<K, V> indexId,
|
||||
final Collection<K> dataKeys,
|
||||
final GlobalSearchScope filter,
|
||||
@Nullable final Condition<V> valueChecker) {
|
||||
@Nullable final Condition<V> valueChecker,
|
||||
@Nullable final ProjectIndexableFilesFilter projectFilesFilter
|
||||
) {
|
||||
final ThrowableConvertor<UpdatableIndex<K, V, FileContent>, TIntHashSet, StorageException> convertor =
|
||||
new ThrowableConvertor<UpdatableIndex<K, V, FileContent>, TIntHashSet, StorageException>() {
|
||||
@Nullable
|
||||
@@ -981,7 +1031,8 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
for (final ValueContainer.IntIterator inputIdsIterator = container.getInputIdsIterator(value); inputIdsIterator.hasNext(); ) {
|
||||
final int id = inputIdsIterator.next();
|
||||
if (mainIntersection == null || mainIntersection.contains(id)) {
|
||||
if ((mainIntersection == null || mainIntersection.contains(id)) &&
|
||||
(projectFilesFilter == null || projectFilesFilter.contains(id))) {
|
||||
copy.add(id);
|
||||
}
|
||||
}
|
||||
@@ -1063,8 +1114,10 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
|
||||
final PersistentFS fs = (PersistentFS)ManagingFS.getInstance();
|
||||
TIntIterator ids = join(locals).iterator();
|
||||
ProjectIndexableFilesFilter projectIndexableFilesFilter = projectIndexableFiles(project);
|
||||
while (ids.hasNext()) {
|
||||
int id = ids.next();
|
||||
if (projectIndexableFilesFilter != null && !projectIndexableFilesFilter.contains(id)) continue;
|
||||
//VirtualFile file = IndexInfrastructure.findFileById(fs, id);
|
||||
VirtualFile file = IndexInfrastructure.findFileByIdIfCached(fs, id);
|
||||
if (file != null && filter.accept(file)) {
|
||||
@@ -1611,7 +1664,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
|
||||
@Override
|
||||
public void fileCreated(final VirtualFileEvent event) {
|
||||
markDirty(event);
|
||||
markDirty(event, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1621,7 +1674,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
|
||||
@Override
|
||||
public void fileCopied(final VirtualFileCopyEvent event) {
|
||||
markDirty(event);
|
||||
markDirty(event, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1636,7 +1689,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
|
||||
@Override
|
||||
public void contentsChanged(final VirtualFileEvent event) {
|
||||
markDirty(event);
|
||||
markDirty(event, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1657,17 +1710,18 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
if (event.getPropertyName().equals(VirtualFile.PROP_NAME)) {
|
||||
// indexes may depend on file name
|
||||
if (!event.getFile().isDirectory()) {
|
||||
markDirty(event);
|
||||
markDirty(event, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void markDirty(final VirtualFileEvent event) {
|
||||
private void markDirty(final VirtualFileEvent event, final boolean contentChange) {
|
||||
final VirtualFile eventFile = event.getFile();
|
||||
cleanProcessedFlag(eventFile);
|
||||
iterateIndexableFiles(eventFile, new Processor<VirtualFile>() {
|
||||
@Override
|
||||
public boolean process(final VirtualFile file) {
|
||||
if (!contentChange) ++myFilesModCount;
|
||||
FileContent fileContent = null;
|
||||
// handle 'content-less' indices separately
|
||||
for (ID<?, ?> indexId : myNotRequiringContentIndices) {
|
||||
@@ -2041,6 +2095,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
|
||||
public CollectingContentIterator createContentIterator() {
|
||||
++myFilesModCount;
|
||||
return new UnindexedFilesFinder();
|
||||
}
|
||||
|
||||
|
||||
+35
-19
@@ -100,26 +100,42 @@ public class TypedAction {
|
||||
public final void actionPerformed(final Editor editor, final char charTyped, final DataContext dataContext) {
|
||||
if (editor == null) return;
|
||||
|
||||
Runnable command = new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(editor.getDocument(),editor.getProject()) {
|
||||
public void run() {
|
||||
Document doc = editor.getDocument();
|
||||
doc.startGuardedBlockChecking();
|
||||
try {
|
||||
getHandler().execute(editor, charTyped, dataContext);
|
||||
}
|
||||
catch (ReadOnlyFragmentModificationException e) {
|
||||
EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e);
|
||||
}
|
||||
finally {
|
||||
doc.stopGuardedBlockChecking();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Runnable command = new TypingCommand(editor, charTyped, dataContext);
|
||||
|
||||
CommandProcessor.getInstance().executeCommand(PlatformDataKeys.PROJECT.getData(dataContext), command, "", editor.getDocument(), UndoConfirmationPolicy.DEFAULT, editor.getDocument());
|
||||
}
|
||||
|
||||
public static boolean isTypedActionInProgress() {
|
||||
return CommandProcessor.getInstance().getCurrentCommand() instanceof TypingCommand;
|
||||
}
|
||||
|
||||
private class TypingCommand implements Runnable {
|
||||
private final Editor myEditor;
|
||||
private final char myCharTyped;
|
||||
private final DataContext myDataContext;
|
||||
|
||||
public TypingCommand(Editor editor, char charTyped, DataContext dataContext) {
|
||||
myEditor = editor;
|
||||
myCharTyped = charTyped;
|
||||
myDataContext = dataContext;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(myEditor.getDocument(), myEditor.getProject()) {
|
||||
public void run() {
|
||||
Document doc = myEditor.getDocument();
|
||||
doc.startGuardedBlockChecking();
|
||||
try {
|
||||
getHandler().execute(myEditor, myCharTyped, myDataContext);
|
||||
}
|
||||
catch (ReadOnlyFragmentModificationException e) {
|
||||
EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e);
|
||||
}
|
||||
finally {
|
||||
doc.stopGuardedBlockChecking();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1186,6 +1186,10 @@ public abstract class DialogWrapper {
|
||||
myPeer.setModal(modal);
|
||||
}
|
||||
|
||||
public boolean isModal() {
|
||||
return myPeer.isModal();
|
||||
}
|
||||
|
||||
protected void setOKActionEnabled(boolean isEnabled) {
|
||||
myOKAction.setEnabled(isEnabled);
|
||||
}
|
||||
|
||||
@@ -94,6 +94,8 @@ public abstract class DialogWrapperPeer {
|
||||
|
||||
public abstract void setModal(boolean modal);
|
||||
|
||||
public abstract boolean isModal();
|
||||
|
||||
/**
|
||||
* @see java.awt.Component#isVisible
|
||||
*/
|
||||
|
||||
@@ -116,7 +116,7 @@ public class Messages {
|
||||
|
||||
if (canShowMacSheetPanel()) {
|
||||
return MacMessages.getInstance()
|
||||
.showMessageDialog(title, message, options, false, WindowManager.getInstance().suggestParentWindow(project), defaultOptionIndex, defaultOptionIndex, null);
|
||||
.showMessageDialog(title, message, options, false, WindowManager.getInstance().suggestParentWindow(project), defaultOptionIndex, defaultOptionIndex, doNotAskOption);
|
||||
}
|
||||
|
||||
return showIdeaMessageDialog(project, message, title, options, defaultOptionIndex, icon, doNotAskOption);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -27,14 +27,11 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ActionPanel extends NonOpaquePanel {
|
||||
|
||||
private final ActionGroup myGroup;
|
||||
private final List<ActionButton> myButtons = new ArrayList<ActionButton>();
|
||||
private final TabInfo myTabInfo;
|
||||
private final JBTabsImpl myTabs;
|
||||
|
||||
private boolean myAutoHide;
|
||||
@@ -44,9 +41,8 @@ public class ActionPanel extends NonOpaquePanel {
|
||||
|
||||
public ActionPanel(JBTabsImpl tabs, TabInfo tabInfo, Pass<MouseEvent> pass) {
|
||||
myTabs = tabs;
|
||||
myTabInfo = tabInfo;
|
||||
myGroup = tabInfo.getTabLabelActions() != null ? tabInfo.getTabLabelActions() : new DefaultActionGroup();
|
||||
AnAction[] children = myGroup.getChildren(null);
|
||||
ActionGroup group = tabInfo.getTabLabelActions() != null ? tabInfo.getTabLabelActions() : new DefaultActionGroup();
|
||||
AnAction[] children = group.getChildren(null);
|
||||
|
||||
final NonOpaquePanel wrapper = new NonOpaquePanel(new BorderLayout());
|
||||
wrapper.add(Box.createHorizontalStrut(myGap), BorderLayout.WEST);
|
||||
@@ -96,8 +92,7 @@ public class ActionPanel extends NonOpaquePanel {
|
||||
|
||||
public void setAutoHide(final boolean autoHide) {
|
||||
myAutoHide = autoHide;
|
||||
for (Iterator<ActionButton> iterator = myButtons.iterator(); iterator.hasNext();) {
|
||||
ActionButton each = iterator.next();
|
||||
for (ActionButton each : myButtons) {
|
||||
each.setAutoHide(myAutoHide);
|
||||
}
|
||||
}
|
||||
@@ -108,8 +103,7 @@ public class ActionPanel extends NonOpaquePanel {
|
||||
}
|
||||
|
||||
public void toggleShowActions(final boolean show) {
|
||||
for (Iterator<ActionButton> iterator = myButtons.iterator(); iterator.hasNext();) {
|
||||
ActionButton each = iterator.next();
|
||||
for (ActionButton each : myButtons) {
|
||||
each.toggleShowActions(show);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -64,7 +64,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
public class JBTabsImpl extends JComponent
|
||||
implements JBTabs, PropertyChangeListener, TimerListener, DataProvider, PopupMenuListener, Disposable, JBTabsPresentation, Queryable, QuickActionProvider {
|
||||
|
||||
static DataKey<JBTabsImpl> NAVIGATION_ACTIONS_KEY = DataKey.create("JBTabs");
|
||||
public static DataKey<JBTabsImpl> NAVIGATION_ACTIONS_KEY = DataKey.create("JBTabs");
|
||||
|
||||
public static final String EDITOR_TABS = "main.editor.tabs";
|
||||
public static final Color MAC_AQUA_BG_COLOR = Gray._200;
|
||||
@@ -114,7 +114,7 @@ public class JBTabsImpl extends JComponent
|
||||
public boolean myForcedRelayout;
|
||||
|
||||
private UiDecorator myUiDecorator;
|
||||
static final UiDecorator ourDefaultDecorator = new DefautDecorator();
|
||||
static final UiDecorator ourDefaultDecorator = new DefaultDecorator();
|
||||
|
||||
private boolean myPaintFocus;
|
||||
|
||||
@@ -518,13 +518,22 @@ public class JBTabsImpl extends JComponent
|
||||
}
|
||||
}
|
||||
|
||||
private void showMorePopup(final MouseEvent e) {
|
||||
public boolean canShowMorePopup() {
|
||||
final SingleRowPassInfo lastLayout = mySingleRowLayout.myLastSingRowLayout;
|
||||
return lastLayout != null && lastLayout.moreRect != null;
|
||||
}
|
||||
|
||||
public void showMorePopup(@Nullable final MouseEvent e) {
|
||||
final SingleRowPassInfo lastLayout = mySingleRowLayout.myLastSingRowLayout;
|
||||
if (lastLayout == null) {
|
||||
return;
|
||||
}
|
||||
mySingleRowLayout.myMorePopup = new JPopupMenu();
|
||||
for (final TabInfo each : myVisibleInfos) {
|
||||
final JCheckBoxMenuItem item = new JCheckBoxMenuItem(each.getText());
|
||||
Color color = UIManager.getColor("MenuItem.background");
|
||||
if (color != null) {
|
||||
if (mySingleRowLayout.myLastSingRowLayout.toDrop.contains(each)) {
|
||||
if (lastLayout.toDrop.contains(each)) {
|
||||
color = new Color((int) (color.getRed() * 0.85f), (int) (color.getGreen() * 0.85f), (int) (color.getBlue() * 0.85f));
|
||||
}
|
||||
|
||||
@@ -555,7 +564,15 @@ public class JBTabsImpl extends JComponent
|
||||
}
|
||||
});
|
||||
|
||||
mySingleRowLayout.myMorePopup.show(this, e.getX(), e.getY());
|
||||
if (e != null) {
|
||||
mySingleRowLayout.myMorePopup.show(this, e.getX(), e.getY());
|
||||
}
|
||||
else {
|
||||
final Rectangle rect = lastLayout.moreRect;
|
||||
if (rect != null) {
|
||||
mySingleRowLayout.myMorePopup.show(this, rect.x, rect.y+rect.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3010,7 +3027,7 @@ public class JBTabsImpl extends JComponent
|
||||
}
|
||||
|
||||
|
||||
private static class DefautDecorator implements UiDecorator {
|
||||
private static class DefaultDecorator implements UiDecorator {
|
||||
@NotNull
|
||||
public UiDecoration getDecoration() {
|
||||
return new UiDecoration(null, new Insets(0, 4, 0, 5));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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,6 +16,7 @@
|
||||
package com.intellij.ui.tabs.impl;
|
||||
|
||||
import com.intellij.ui.tabs.TabInfo;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
@@ -28,15 +29,19 @@ public abstract class LayoutPassInfo {
|
||||
myVisibleInfos = visibleInfos;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract TabInfo getPreviousFor(TabInfo info);
|
||||
|
||||
@Nullable
|
||||
public abstract TabInfo getNextFor(TabInfo info);
|
||||
|
||||
public TabInfo getPrevious(List<TabInfo> list, int i) {
|
||||
@Nullable
|
||||
public static TabInfo getPrevious(List<TabInfo> list, int i) {
|
||||
return i > 0 ? list.get(i - 1) : null;
|
||||
}
|
||||
|
||||
public TabInfo getNext(List<TabInfo> list, int i) {
|
||||
@Nullable
|
||||
public static TabInfo getNext(List<TabInfo> list, int i) {
|
||||
return i < list.size() - 1 ? list.get(i + 1) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class TabLabel extends JPanel {
|
||||
myLabelPlaceholder.setOpaque(false);
|
||||
add(myLabelPlaceholder, BorderLayout.CENTER);
|
||||
|
||||
setAligmentToCenter(true);
|
||||
setAlignmentToCenter(true);
|
||||
|
||||
myIcon = new LayeredIcon(2);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class TabLabel extends JPanel {
|
||||
return insets;
|
||||
}
|
||||
|
||||
public void setAligmentToCenter(boolean toCenter) {
|
||||
public void setAlignmentToCenter(boolean toCenter) {
|
||||
if (myCentered == toCenter && myLabel.getParent() != null) return;
|
||||
|
||||
myLabelPlaceholder.removeAll();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -19,6 +19,7 @@ import com.intellij.ui.tabs.JBTabsPosition;
|
||||
import com.intellij.ui.tabs.TabInfo;
|
||||
import com.intellij.ui.tabs.TabsUtil;
|
||||
import com.intellij.ui.tabs.impl.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -105,7 +106,7 @@ public class SingleRowLayout extends TabLayout {
|
||||
}
|
||||
|
||||
private boolean checkLayoutLabels(SingleRowPassInfo data) {
|
||||
boolean layoutLabels = true;
|
||||
boolean layoutLabels = true;
|
||||
|
||||
if (!myTabs.myForcedRelayout &&
|
||||
myLastSingRowLayout != null &&
|
||||
@@ -191,7 +192,6 @@ public class SingleRowLayout extends TabLayout {
|
||||
|
||||
private void layoutLabelsAndGhosts(final SingleRowPassInfo data) {
|
||||
final int fixedPosition = getStrategy().getFixedPosition(data);
|
||||
boolean reachedBounds = false;
|
||||
|
||||
if (data.firstGhostVisible || myTabs.isGhostsAlwaysVisible()) {
|
||||
data.firstGhost = getStrategy().getLayoutRec(data.position, fixedPosition, myTabs.getGhostTabLength(), getStrategy().getFixedFitLength(data));
|
||||
@@ -224,7 +224,7 @@ public class SingleRowLayout extends TabLayout {
|
||||
myTabs.layout(label, rec);
|
||||
}
|
||||
|
||||
label.setAligmentToCenter((deltaToFit > 0 || myTabs.isEditorTabs()) && getStrategy().isToCenterTextWhenStretched());
|
||||
label.setAlignmentToCenter((deltaToFit > 0 || myTabs.isEditorTabs()) && getStrategy().isToCenterTextWhenStretched());
|
||||
|
||||
data.position = getStrategy().getMaxPosition(label.getBounds());
|
||||
data.position += myTabs.getInterTabSpaceLength();
|
||||
@@ -233,7 +233,7 @@ public class SingleRowLayout extends TabLayout {
|
||||
}
|
||||
|
||||
for (TabInfo eachInfo : data.toDrop) {
|
||||
myTabs.resetLayout(myTabs.myInfo2Label.get(eachInfo));
|
||||
JBTabsImpl.resetLayout(myTabs.myInfo2Label.get(eachInfo));
|
||||
}
|
||||
|
||||
if (data.lastGhostVisible || myTabs.isGhostsAlwaysVisible()) {
|
||||
@@ -326,13 +326,13 @@ public class SingleRowLayout extends TabLayout {
|
||||
});
|
||||
}
|
||||
|
||||
public void setInfo(final TabInfo info) {
|
||||
public void setInfo(@Nullable final TabInfo info) {
|
||||
myInfo = info;
|
||||
setToolTipText(info != null ? info.getTooltipText() : null);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
myTabs.resetLayout(this);
|
||||
JBTabsImpl.resetLayout(this);
|
||||
setInfo(null);
|
||||
}
|
||||
}
|
||||
@@ -367,7 +367,7 @@ public class SingleRowLayout extends TabLayout {
|
||||
|
||||
Component c = myTabs.getComponentAt(point);
|
||||
|
||||
if (c instanceof JBTabsImpl && !(c instanceof TabLabel)) {
|
||||
if (c instanceof JBTabsImpl) {
|
||||
for (int i = 0; i < myLastSingRowLayout.myVisibleInfos.size() - 1; i++) {
|
||||
TabLabel first = myTabs.myInfo2Label.get(myLastSingRowLayout.myVisibleInfos.get(i));
|
||||
TabLabel second = myTabs.myInfo2Label.get(myLastSingRowLayout.myVisibleInfos.get(i + 1));
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -18,7 +18,7 @@ package com.intellij.ui.tabs.impl.singleRow;
|
||||
import com.intellij.ui.tabs.impl.JBTabsImpl;
|
||||
import com.intellij.ui.tabs.impl.ShapeTransform;
|
||||
import com.intellij.ui.tabs.impl.TabLabel;
|
||||
import com.intellij.ui.tabs.impl.table.TableLayout;
|
||||
import com.intellij.ui.tabs.impl.TabLayout;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class SingleRowLayoutStrategy {
|
||||
|
||||
@Override
|
||||
public boolean isDragOut(TabLabel tabLabel, int deltaX, int deltaY) {
|
||||
return Math.abs(deltaY) > tabLabel.getHeight() * TableLayout.getDragOutMultiplier();
|
||||
return Math.abs(deltaY) > tabLabel.getHeight() * TabLayout.getDragOutMultiplier();
|
||||
}
|
||||
|
||||
public int getMoreRectAxisSize() {
|
||||
@@ -230,7 +230,7 @@ public abstract class SingleRowLayoutStrategy {
|
||||
|
||||
@Override
|
||||
public boolean isDragOut(TabLabel tabLabel, int deltaX, int deltaY) {
|
||||
return Math.abs(deltaX) > tabLabel.getHeight() * TableLayout.getDragOutMultiplier();
|
||||
return Math.abs(deltaX) > tabLabel.getHeight() * TabLayout.getDragOutMultiplier();
|
||||
}
|
||||
|
||||
public boolean isToCenterTextWhenStretched() {
|
||||
|
||||
@@ -158,7 +158,7 @@ public class TableLayout extends TabLayout {
|
||||
}
|
||||
|
||||
myTabs.layout(label, eachX, eachY, width, row < data.table.size() - 1 ? myTabs.myHeaderFitSize.height - tabUnderlineFix : myTabs.myHeaderFitSize.height);
|
||||
label.setAligmentToCenter(deltaToFit > 0);
|
||||
label.setAlignmentToCenter(deltaToFit > 0);
|
||||
|
||||
boolean lastCell = i == eachRow.myColumns.size() - 1;
|
||||
eachX += width + (lastCell ? 0 : myTabs.getInterTabSpaceLength());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.ui.tabs.impl.table;
|
||||
import com.intellij.ui.tabs.TabInfo;
|
||||
import com.intellij.ui.tabs.impl.JBTabsImpl;
|
||||
import com.intellij.ui.tabs.impl.LayoutPassInfo;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -36,16 +37,18 @@ public class TablePassInfo extends LayoutPassInfo {
|
||||
|
||||
JBTabsImpl myTabs;
|
||||
|
||||
TablePassInfo(final JBTabsImpl tabs, java.util.List<TabInfo> visibleInfos) {
|
||||
TablePassInfo(final JBTabsImpl tabs, List<TabInfo> visibleInfos) {
|
||||
super(visibleInfos);
|
||||
myTabs = tabs;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TabInfo getPreviousFor(final TabInfo info) {
|
||||
final TableRow row = myInfo2Row.get(info);
|
||||
return row != null ? getPrevious(row.myColumns, row.myColumns.indexOf(info)) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TabInfo getNextFor(final TabInfo info) {
|
||||
final TableRow row = myInfo2Row.get(info);
|
||||
return row != null ? getNext(row.myColumns, row.myColumns.indexOf(info)) : null;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.ide.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.ui.tabs.impl.JBTabsImpl;
|
||||
|
||||
/**
|
||||
* Shows the popup of all tabs when single row editor tab layout is used and all tabs don't fit on the screen.
|
||||
*
|
||||
* @author yole
|
||||
*/
|
||||
public class TabListAction extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
JBTabsImpl tabs = e.getData(JBTabsImpl.NAVIGATION_ACTIONS_KEY);
|
||||
if (tabs != null) {
|
||||
tabs.showMorePopup(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(isTabListAvailable(e));
|
||||
}
|
||||
|
||||
private static boolean isTabListAvailable(AnActionEvent e) {
|
||||
JBTabsImpl tabs = e.getData(JBTabsImpl.NAVIGATION_ACTIONS_KEY);
|
||||
if (tabs == null || !tabs.isEditorTabs()) {
|
||||
return false;
|
||||
}
|
||||
return tabs.canShowMorePopup();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -18,14 +18,12 @@ package com.intellij.ide.impl;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.highlighter.InternalFileType;
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
@@ -53,13 +51,12 @@ import java.io.IOException;
|
||||
public class ProjectUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.impl.ProjectUtil");
|
||||
|
||||
private ProjectUtil() {
|
||||
}
|
||||
private ProjectUtil() { }
|
||||
|
||||
public static void updateLastProjectLocation(final String projectFilePath) {
|
||||
File lastProjectLocation = new File(projectFilePath);
|
||||
if (lastProjectLocation.isFile()) {
|
||||
lastProjectLocation = lastProjectLocation.getParentFile(); //for directory based project storages
|
||||
lastProjectLocation = lastProjectLocation.getParentFile(); // for directory-based project storage
|
||||
}
|
||||
if (lastProjectLocation == null) { // the immediate parent of the ipr file
|
||||
return;
|
||||
@@ -141,7 +138,7 @@ public class ProjectUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Project openProject(final String path, Project projectToClose, boolean forceOpenInNewFrame) {
|
||||
public static Project openProject(final String path, @Nullable Project projectToClose, boolean forceOpenInNewFrame) {
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
Messages.showErrorDialog(IdeBundle.message("error.project.file.does.not.exist", path), CommonBundle.getErrorTitle());
|
||||
@@ -164,7 +161,8 @@ public class ProjectUtil {
|
||||
if (!forceOpenInNewFrame && openProjects.length > 0) {
|
||||
int exitCode = confirmOpenNewProject(false);
|
||||
if (exitCode == GeneralSettings.OPEN_PROJECT_SAME_WINDOW) {
|
||||
if (!closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null;
|
||||
final Project toClose = projectToClose != null ? projectToClose : openProjects[openProjects.length - 1];
|
||||
if (!closeAndDispose(toClose)) return null;
|
||||
}
|
||||
else if (exitCode != GeneralSettings.OPEN_PROJECT_NEW_WINDOW) {
|
||||
return null;
|
||||
@@ -205,19 +203,23 @@ public class ProjectUtil {
|
||||
if (confirmOpenNewProject == GeneralSettings.OPEN_PROJECT_ASK) {
|
||||
if (isNewProject) {
|
||||
int exitCode = Messages.showYesNoDialog(IdeBundle.message("prompt.open.project.in.new.frame"),
|
||||
IdeBundle.message("title.new.project"),
|
||||
IdeBundle.message("button.existingframe"),
|
||||
IdeBundle.message("button.newframe"),
|
||||
Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption());
|
||||
IdeBundle.message("title.new.project"),
|
||||
IdeBundle.message("button.existingframe"),
|
||||
IdeBundle.message("button.newframe"),
|
||||
Messages.getQuestionIcon(),
|
||||
new ProjectNewWindowDoNotAskOption());
|
||||
return exitCode == 0 ? GeneralSettings.OPEN_PROJECT_SAME_WINDOW : GeneralSettings.OPEN_PROJECT_NEW_WINDOW;
|
||||
}
|
||||
else {
|
||||
int exitCode = Messages.showYesNoCancelDialog(IdeBundle.message("prompt.open.project.in.new.frame"),
|
||||
IdeBundle.message("title.open.project"),
|
||||
IdeBundle.message("button.existingframe"), IdeBundle.message("button.newframe"),
|
||||
CommonBundle.getCancelButtonText(), Messages.getQuestionIcon(),
|
||||
new ProjectNewWindowDoNotAskOption());
|
||||
return exitCode == 0 ? GeneralSettings.OPEN_PROJECT_SAME_WINDOW : exitCode == 1 ? GeneralSettings.OPEN_PROJECT_NEW_WINDOW : Messages.CANCEL;
|
||||
IdeBundle.message("title.open.project"),
|
||||
IdeBundle.message("button.existingframe"),
|
||||
IdeBundle.message("button.newframe"),
|
||||
CommonBundle.getCancelButtonText(),
|
||||
Messages.getQuestionIcon(),
|
||||
new ProjectNewWindowDoNotAskOption());
|
||||
return exitCode == 0 ? GeneralSettings.OPEN_PROJECT_SAME_WINDOW :
|
||||
exitCode == 1 ? GeneralSettings.OPEN_PROJECT_NEW_WINDOW : Messages.CANCEL;
|
||||
}
|
||||
}
|
||||
return confirmOpenNewProject;
|
||||
@@ -265,6 +267,10 @@ public class ProjectUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@linkplain com.intellij.openapi.project.ProjectUtil#isProjectOrWorkspaceFile(com.intellij.openapi.vfs.VirtualFile)} (to remove in IDEA 13)
|
||||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public static boolean isProjectOrWorkspaceFile(final VirtualFile file) {
|
||||
return com.intellij.openapi.project.ProjectUtil.isProjectOrWorkspaceFile(file);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -142,6 +144,8 @@ class EventLogConsole {
|
||||
String date = DateFormatUtil.formatTimeWithSeconds(notificationTime) + " ";
|
||||
append(document, date);
|
||||
|
||||
int startLine = document.getLineCount() - 1;
|
||||
|
||||
EventLog.LogEntry pair = EventLog.formatForLog(notification, StringUtil.repeatSymbol(' ', date.length()));
|
||||
|
||||
final NotificationType type = notification.getType();
|
||||
@@ -172,34 +176,44 @@ class EventLogConsole {
|
||||
}
|
||||
|
||||
if (notification.isImportant()) {
|
||||
highlightNotification(notification, pair.status, document.getLineCount() - 2);
|
||||
highlightNotification(notification, pair.status, startLine, document.getLineCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void highlightNotification(final Notification notification,
|
||||
String message, final int line) {
|
||||
String message, final int line1, final int line2) {
|
||||
|
||||
final MarkupModel markupModel = myLogEditor.getValue().getMarkupModel();
|
||||
TextAttributes bold = new TextAttributes(null, null, null, null, Font.BOLD);
|
||||
final RangeHighlighter lineHighlighter = markupModel.addLineHighlighter(line, HighlighterLayer.CARET_ROW + 1, bold);
|
||||
Color color = notification.getType() == NotificationType.ERROR
|
||||
? Color.red
|
||||
: notification.getType() == NotificationType.WARNING ? Color.yellow : Color.green;
|
||||
lineHighlighter.setErrorStripeMarkColor(color);
|
||||
lineHighlighter.setErrorStripeTooltip(message);
|
||||
final List<RangeHighlighter> lineColors = new ArrayList<RangeHighlighter>();
|
||||
for (int line = line1; line < line2; line++) {
|
||||
final RangeHighlighter lineHighlighter = markupModel.addLineHighlighter(line, HighlighterLayer.CARET_ROW + 1, bold);
|
||||
Color color = notification.getType() == NotificationType.ERROR
|
||||
? Color.red
|
||||
: notification.getType() == NotificationType.WARNING ? Color.yellow : Color.green;
|
||||
lineHighlighter.setErrorStripeMarkColor(color);
|
||||
lineHighlighter.setErrorStripeTooltip(message);
|
||||
lineColors.add(lineHighlighter);
|
||||
}
|
||||
|
||||
myProjectModel.removeHandlers.put(notification, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
markupModel.removeHighlighter(lineHighlighter);
|
||||
for (RangeHighlighter color : lineColors) {
|
||||
markupModel.removeHighlighter(color);
|
||||
}
|
||||
|
||||
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(ConsoleViewContentType.LOG_EXPIRED_ENTRY);
|
||||
markupModel.addLineHighlighter(line, HighlighterLayer.CARET_ROW + 1, attributes);
|
||||
for (int line = line1; line < line2; line++) {
|
||||
markupModel.addLineHighlighter(line, HighlighterLayer.CARET_ROW + 1, attributes);
|
||||
}
|
||||
|
||||
TextAttributes italic = new TextAttributes(null, null, null, null, Font.ITALIC);
|
||||
for (RangeHighlighter highlighter : myHyperlinkSupport.getValue().findAllHyperlinksOnLine(line)) {
|
||||
markupModel.addRangeHighlighter(highlighter.getStartOffset(), highlighter.getEndOffset(), HighlighterLayer.CARET_ROW + 2, italic, HighlighterTargetArea.EXACT_RANGE);
|
||||
myHyperlinkSupport.getValue().removeHyperlink(highlighter);
|
||||
for (int line = line1; line < line2; line++) {
|
||||
for (RangeHighlighter highlighter : myHyperlinkSupport.getValue().findAllHyperlinksOnLine(line)) {
|
||||
markupModel.addRangeHighlighter(highlighter.getStartOffset(), highlighter.getEndOffset(), HighlighterLayer.CARET_ROW + 2, italic, HighlighterTargetArea.EXACT_RANGE);
|
||||
myHyperlinkSupport.getValue().removeHyperlink(highlighter);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -24,8 +24,8 @@ import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.impl.actionholder.ActionRef;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.ui.plaf.beg.IdeaMenuUI;
|
||||
import com.intellij.ui.plaf.gtk.GtkMenuUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -198,9 +198,9 @@ public final class ActionMenu extends JMenu {
|
||||
}
|
||||
|
||||
public static void showDescriptionInStatusBar(boolean isIncluded, Component component, String description) {
|
||||
IdeFrameImpl frame = component instanceof IdeFrameImpl
|
||||
? (IdeFrameImpl)component
|
||||
: (IdeFrameImpl)SwingUtilities.getAncestorOfClass(IdeFrameImpl.class, component);
|
||||
IdeFrame frame = component instanceof IdeFrame
|
||||
? (IdeFrame)component
|
||||
: (IdeFrame)SwingUtilities.getAncestorOfClass(IdeFrame.class, component);
|
||||
if (frame != null) {
|
||||
StatusBar statusBar = frame.getStatusBar();
|
||||
if (isIncluded) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -86,6 +86,11 @@ public class DummyProject extends UserDataHolderBase implements Project {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
}
|
||||
|
||||
|
||||
+7
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.components.impl.stores;
|
||||
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
@@ -28,7 +27,7 @@ import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.options.StreamProvider;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileAdapter;
|
||||
@@ -78,6 +77,7 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
syncRefreshPathRecursively(PathManager.getConfigPath(true), "componentVersions");
|
||||
}
|
||||
finally {
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
myConfigDirectoryRefreshed = true;
|
||||
}
|
||||
}
|
||||
@@ -125,10 +125,6 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isOptionsFile(final String filePath) {
|
||||
return FileUtil.isAncestor(new File(PathManager.getOptionsPath()), new File(filePath), false);
|
||||
}
|
||||
|
||||
protected MySaveSession createSaveSession(final MyExternalizationSession externalizationSession) {
|
||||
return new FileSaveSession(externalizationSession);
|
||||
}
|
||||
@@ -162,7 +158,7 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
|
||||
protected void doSave() throws StateStorageException {
|
||||
if (!myBlockSavingTheContent) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() && myFile != null && myFile.getPath().startsWith("$")) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() && myFile != null && StringUtil.startsWithChar(myFile.getPath(), '$')) {
|
||||
throw new StateStorageException("It seems like some macros were not expanded for path: " + myFile.getPath());
|
||||
}
|
||||
|
||||
@@ -228,9 +224,8 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
return StorageUtil.getVirtualFile(myFile);
|
||||
}
|
||||
|
||||
|
||||
public IFile getFile() {
|
||||
return myFile;
|
||||
public File getFile() {
|
||||
return new File(myFile.getPath());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -254,6 +249,7 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Document processReadException(final Exception e) {
|
||||
myBlockSavingTheContent = isProjectOrModuleFile();
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
|
||||
+7
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -31,8 +31,6 @@ import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
public interface IProjectStore extends IComponentStore {
|
||||
|
||||
|
||||
boolean checkVersion();
|
||||
|
||||
void setProjectFilePath(final String filePath);
|
||||
@@ -40,6 +38,12 @@ public interface IProjectStore extends IComponentStore {
|
||||
@Nullable
|
||||
VirtualFile getProjectBaseDir();
|
||||
|
||||
@Nullable
|
||||
String getProjectBasePath();
|
||||
|
||||
/**
|
||||
* @deprecated please use {@linkplain #getPresentableUrl()} or {@linkplain #getProjectBasePath()} (to remove in IDEA 13).
|
||||
*/
|
||||
@Nullable
|
||||
String getLocation();
|
||||
|
||||
|
||||
+116
-110
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -35,10 +35,8 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.util.containers.OrderedSet;
|
||||
import com.intellij.util.io.fs.FileSystem;
|
||||
import com.intellij.util.io.fs.IFile;
|
||||
@@ -46,7 +44,6 @@ import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
@@ -57,30 +54,31 @@ import java.util.Set;
|
||||
|
||||
class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProjectStore {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.components.impl.stores.ProjectStoreImpl");
|
||||
|
||||
@NonNls private static final String OLD_PROJECT_SUFFIX = "_old.";
|
||||
@NonNls static final String OPTION_WORKSPACE = "workspace";
|
||||
|
||||
protected ProjectImpl myProject;
|
||||
|
||||
@NonNls static final String PROJECT_FILE_MACRO = "PROJECT_FILE";
|
||||
@NonNls static final String WS_FILE_MACRO = "WORKSPACE_FILE";
|
||||
@NonNls private static final String PROJECT_CONFIG_DIR = "PROJECT_CONFIG_DIR";
|
||||
|
||||
static final String PROJECT_FILE_STORAGE = "$" + PROJECT_FILE_MACRO + "$";
|
||||
static final String WS_FILE_STORAGE = "$" + WS_FILE_MACRO + "$";
|
||||
static final String DEFAULT_STATE_STORAGE = PROJECT_FILE_STORAGE;
|
||||
@NonNls static final String PROJECT_FILE_STORAGE = "$" + PROJECT_FILE_MACRO + "$";
|
||||
@NonNls static final String WS_FILE_STORAGE = "$" + WS_FILE_MACRO + "$";
|
||||
@NonNls static final String DEFAULT_STATE_STORAGE = PROJECT_FILE_STORAGE;
|
||||
|
||||
static final Storage DEFAULT_STORAGE_ANNOTATION = new MyStorage();
|
||||
private static int originalVersion = -1;
|
||||
|
||||
protected ProjectImpl myProject;
|
||||
private StorageScheme myScheme = StorageScheme.DEFAULT;
|
||||
private String myCachedLocation;
|
||||
private String myPresentableUrl;
|
||||
|
||||
ProjectStoreImpl(final ProjectImpl project) {
|
||||
super(project);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkVersion() {
|
||||
final ApplicationNamesInfo appNamesInfo = ApplicationNamesInfo.getInstance();
|
||||
if (originalVersion >= 0 && originalVersion < ProjectManagerImpl.CURRENT_FORMAT_VERSION) {
|
||||
@@ -130,10 +128,10 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
private void backup(final VirtualFile projectDir, final VirtualFile vile) throws IOException {
|
||||
final String oldName = vile.getNameWithoutExtension() + OLD_PROJECT_SUFFIX + vile.getExtension();
|
||||
VirtualFile oldFile = projectDir.findOrCreateChildData(this, oldName);
|
||||
VfsUtil.saveText(oldFile, VfsUtil.loadText(vile));
|
||||
final VirtualFile oldFile = projectDir.findOrCreateChildData(this, oldName);
|
||||
assert oldFile != null : projectDir + ", " + oldName;
|
||||
VfsUtil.saveText(oldFile, VfsUtilCore.loadText(vile));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -147,6 +145,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackingPathMacroSubstitutor[] getSubstitutors() {
|
||||
return new TrackingPathMacroSubstitutor[] {getStateStorageManager().getMacroSubstitutor()};
|
||||
}
|
||||
@@ -161,79 +160,77 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectFilePath(final String filePath) {
|
||||
if (filePath == null) {
|
||||
return;
|
||||
}
|
||||
final IFile iFile = FileSystem.FILE_SYSTEM.createFile(filePath);
|
||||
|
||||
final StateStorageManager stateStorageManager = getStateStorageManager();
|
||||
|
||||
if (!isIprPath(iFile)) {
|
||||
final IFile dir_store =
|
||||
iFile.isDirectory()
|
||||
? iFile.getChild(Project.DIRECTORY_STORE_FOLDER)
|
||||
: iFile.getParentFile().getChild(Project.DIRECTORY_STORE_FOLDER);
|
||||
|
||||
FileBasedStorage.syncRefreshPathRecursively(dir_store.getPath(), null);
|
||||
final File file = new File(filePath);
|
||||
if (!isIprPath(file)) {
|
||||
final File dirStore = file.isDirectory() ? new File(file, Project.DIRECTORY_STORE_FOLDER)
|
||||
: new File(file.getParentFile(), Project.DIRECTORY_STORE_FOLDER);
|
||||
FileBasedStorage.syncRefreshPathRecursively(dirStore.getPath(), null);
|
||||
|
||||
myScheme = StorageScheme.DIRECTORY_BASED;
|
||||
stateStorageManager.addMacro(PROJECT_FILE_MACRO, new File(dirStore, "misc.xml").getPath());
|
||||
|
||||
stateStorageManager.addMacro(PROJECT_FILE_MACRO, dir_store.getChild("misc.xml").getPath());
|
||||
final IFile ws = dir_store.getChild("workspace.xml");
|
||||
final File ws = new File(dirStore, "workspace.xml");
|
||||
stateStorageManager.addMacro(WS_FILE_MACRO, ws.getPath());
|
||||
|
||||
if (!ws.exists() && !iFile.isDirectory()) {
|
||||
if (!ws.exists() && !file.isDirectory()) {
|
||||
useOldWsContent(filePath, ws);
|
||||
}
|
||||
|
||||
stateStorageManager.addMacro(PROJECT_CONFIG_DIR, dir_store.getPath());
|
||||
} else {
|
||||
stateStorageManager.addMacro(PROJECT_CONFIG_DIR, dirStore.getPath());
|
||||
}
|
||||
else {
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
|
||||
|
||||
myScheme = StorageScheme.DEFAULT;
|
||||
stateStorageManager.addMacro(PROJECT_FILE_MACRO, filePath);
|
||||
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
|
||||
|
||||
int lastDot = filePath.lastIndexOf(".");
|
||||
final String filePathWithoutExt = lastDot > 0 ? filePath.substring(0, lastDot) : filePath;
|
||||
String workspacePath = filePathWithoutExt + WorkspaceFileType.DOT_DEFAULT_EXTENSION;
|
||||
|
||||
final String workspacePath = composeWsPath(filePath);
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByPath(workspacePath);
|
||||
stateStorageManager.addMacro(WS_FILE_MACRO, workspacePath);
|
||||
}
|
||||
|
||||
myCachedLocation = null;
|
||||
}
|
||||
|
||||
private static boolean isIprPath(final IFile file) {
|
||||
return file.getName().indexOf(".") > 0 && ProjectFileType.DEFAULT_EXTENSION.equals(FileUtil.getExtension(file.getName()));
|
||||
myPresentableUrl = null;
|
||||
}
|
||||
|
||||
private static void useOldWsContent(final String filePath, final IFile ws) {
|
||||
int lastDot = filePath.lastIndexOf(".");
|
||||
private static boolean isIprPath(final File file) {
|
||||
final String name = file.getName();
|
||||
return name.indexOf(".") > 0 && ProjectFileType.DEFAULT_EXTENSION.equals(FileUtil.getExtension(name));
|
||||
}
|
||||
|
||||
private static String composeWsPath(String filePath) {
|
||||
final int lastDot = filePath.lastIndexOf(".");
|
||||
final String filePathWithoutExt = lastDot > 0 ? filePath.substring(0, lastDot) : filePath;
|
||||
String workspacePath = filePathWithoutExt + WorkspaceFileType.DOT_DEFAULT_EXTENSION;
|
||||
IFile oldWs = FileSystem.FILE_SYSTEM.createFile(workspacePath);
|
||||
return filePathWithoutExt + WorkspaceFileType.DOT_DEFAULT_EXTENSION;
|
||||
}
|
||||
|
||||
private static void useOldWsContent(final String filePath, final File ws) {
|
||||
final File oldWs = new File(composeWsPath(filePath));
|
||||
if (oldWs.exists()) {
|
||||
try {
|
||||
final InputStream is = oldWs.openInputStream();
|
||||
final byte[] bytes;
|
||||
|
||||
final InputStream is = new FileInputStream(oldWs);
|
||||
try {
|
||||
bytes = FileUtil.loadBytes(is, (int)oldWs.length());
|
||||
final byte[] bytes = FileUtil.loadBytes(is, (int)oldWs.length());
|
||||
|
||||
final OutputStream os = new FileOutputStream(ws);
|
||||
try {
|
||||
os.write(bytes);
|
||||
}
|
||||
finally {
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
|
||||
final OutputStream os = ws.openOutputStream();
|
||||
try {
|
||||
os.write(bytes);
|
||||
}
|
||||
finally {
|
||||
os.close();
|
||||
}
|
||||
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
@@ -241,24 +238,37 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getProjectBaseDir() {
|
||||
final VirtualFile projectFile = getProjectFile();
|
||||
if (projectFile != null) return myScheme == StorageScheme.DEFAULT ? projectFile.getParent() : projectFile.getParent().getParent();
|
||||
if (myProject.isDefault()) return null;
|
||||
|
||||
final String path = getProjectBasePath();
|
||||
if (path == null) return null;
|
||||
|
||||
return LocalFileSystem.getInstance().findFileByPath(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectBasePath() {
|
||||
if (myProject.isDefault()) return null;
|
||||
|
||||
final String path = getProjectFilePath();
|
||||
if (!StringUtil.isEmptyOrSpaces(path)) {
|
||||
return myScheme == StorageScheme.DEFAULT ? new File(path).getParent() : new File(path).getParentFile().getParent();
|
||||
}
|
||||
|
||||
//we are not yet initialized completely ("open directory", etc)
|
||||
final StateStorage s = getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
if (!(s instanceof FileBasedStorage)) return null;
|
||||
final FileBasedStorage storage = (FileBasedStorage)s;
|
||||
|
||||
final IFile file = storage.getFile();
|
||||
final File file = storage.getFile();
|
||||
if (file == null) return null;
|
||||
|
||||
return LocalFileSystem.getInstance()
|
||||
.findFileByIoFile(myScheme == StorageScheme.DEFAULT ? file.getParentFile() : file.getParentFile().getParentFile());
|
||||
return myScheme == StorageScheme.DEFAULT ? file.getParent() : file.getParentFile().getParent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getLocation() {
|
||||
if (myCachedLocation == null) {
|
||||
if (myScheme == StorageScheme.DEFAULT) {
|
||||
@@ -274,79 +284,70 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getProjectName() {
|
||||
if (myScheme == StorageScheme.DIRECTORY_BASED) {
|
||||
final VirtualFile baseDir = getProjectBaseDir();
|
||||
assert baseDir != null : "project file: " + (getProjectFile() == null ? "[NULL]" : getProjectFile().getPath());
|
||||
assert baseDir != null : "project file: " + getProjectFile();
|
||||
|
||||
final VirtualFile ideaDir = baseDir.findChild(".idea");
|
||||
if (ideaDir != null && ideaDir.isValid()) {
|
||||
final VirtualFile nameFile = ideaDir.findChild(".name");
|
||||
if (nameFile != null && nameFile.isValid()) {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), "UTF-8"));
|
||||
final String name = in.readLine();
|
||||
if (name != null && name.length() > 0) return name.trim();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), "UTF-8"));
|
||||
try {
|
||||
final String name = in.readLine();
|
||||
if (name != null && name.length() > 0) {
|
||||
return name.trim();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return baseDir.getName().replace(":", "");
|
||||
}
|
||||
|
||||
String temp = getProjectFileName();
|
||||
FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(temp);
|
||||
if (fileType instanceof ProjectFileType) {
|
||||
temp = temp.substring(0, temp.length() - fileType.getDefaultExtension().length()-1);
|
||||
else {
|
||||
String temp = getProjectFileName();
|
||||
FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(temp);
|
||||
if (fileType instanceof ProjectFileType) {
|
||||
temp = temp.substring(0, temp.length() - fileType.getDefaultExtension().length() - 1);
|
||||
}
|
||||
final int i = temp.lastIndexOf(File.separatorChar);
|
||||
if (i >= 0) {
|
||||
temp = temp.substring(i + 1, temp.length() - i + 1);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
final int i = temp.lastIndexOf(File.separatorChar);
|
||||
if (i >= 0) {
|
||||
temp = temp.substring(i + 1, temp.length() - i + 1);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public StorageScheme getStorageScheme() {
|
||||
return myScheme;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPresentableUrl() {
|
||||
if (myProject.isDefault()) return null;
|
||||
if (myScheme == StorageScheme.DIRECTORY_BASED) {
|
||||
final VirtualFile baseDir = getProjectBaseDir();
|
||||
return baseDir != null ? baseDir.getPresentableUrl() : null;
|
||||
}
|
||||
else {
|
||||
if (myProject.isDefault()) return null;
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
assert storage != null;
|
||||
return storage.getFilePath().replace('/', File.separatorChar);
|
||||
if (myPresentableUrl == null) {
|
||||
final String url = myScheme == StorageScheme.DIRECTORY_BASED ? getProjectBasePath() : getProjectFilePath();
|
||||
myPresentableUrl = url != null ? FileUtil.toSystemDependentName(url) : url;
|
||||
}
|
||||
return myPresentableUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadProject() throws IOException, JDOMException, InvalidDataException, StateStorageException {
|
||||
//load();
|
||||
myProject.init();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getProjectFile() {
|
||||
if (myProject.isDefault()) return null;
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
@@ -354,7 +355,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return storage.getVirtualFile();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getWorkspaceFile() {
|
||||
if (myProject.isDefault()) return null;
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(WS_FILE_STORAGE);
|
||||
@@ -362,6 +363,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return storage.getVirtualFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadProjectFromTemplate(final ProjectImpl defaultProject) {
|
||||
final StateStorage stateStorage = getStateStorageManager().getFileStateStorage(DEFAULT_STATE_STORAGE);
|
||||
|
||||
@@ -379,6 +381,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getProjectFileName() {
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
assert storage != null;
|
||||
@@ -386,20 +389,22 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getProjectFilePath() {
|
||||
if (myProject.isDefault()) return "";
|
||||
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
assert storage != null;
|
||||
return storage.getFilePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected XmlElementStorage getMainStorage() {
|
||||
final XmlElementStorage storage = (XmlElementStorage)getStateStorageManager().getFileStateStorage(DEFAULT_STATE_STORAGE);
|
||||
assert storage != null;
|
||||
return storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StateStorageManager createStateStorageManager() {
|
||||
return new ProjectStateStorageManager(PathMacroManager.getInstance(getComponentManager()).createTrackingSubstitutor(), myProject);
|
||||
}
|
||||
@@ -424,7 +429,6 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
static class WsStorageData extends ProjectStorageData {
|
||||
|
||||
WsStorageData(final String rootElementName, final Project project) {
|
||||
super(rootElementName, project);
|
||||
}
|
||||
@@ -449,6 +453,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
protected void load(@NotNull final Element root) throws IOException {
|
||||
final String v = root.getAttributeValue(VERSION_OPTION);
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
originalVersion = v != null ? Integer.parseInt(v) : 0;
|
||||
|
||||
if (originalVersion != ProjectManagerImpl.CURRENT_FORMAT_VERSION) {
|
||||
@@ -466,12 +471,12 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SaveSessionImpl createSaveSession() throws StateStorageException {
|
||||
return new ProjectSaveSession();
|
||||
}
|
||||
|
||||
protected class ProjectSaveSession extends SaveSessionImpl {
|
||||
|
||||
ProjectSaveSession() throws StateStorageException {
|
||||
}
|
||||
|
||||
@@ -533,7 +538,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
List<VirtualFile> readonlyFiles = new ArrayList<VirtualFile>();
|
||||
|
||||
if (((ProjectImpl)myProject).isToSaveProjectName()) {
|
||||
if (myProject.isToSaveProjectName()) {
|
||||
final VirtualFile baseDir = getProjectBaseDir();
|
||||
if (baseDir != null && baseDir.isValid()) {
|
||||
filesToSave.add(FileSystem.FILE_SYSTEM
|
||||
@@ -627,14 +632,15 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected StateStorageChooser getDefaultStateStorageChooser() {
|
||||
return myStateStorageChooser;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected <T> Storage[] getComponentStorageSpecs(@NotNull final PersistentStateComponent<T> persistentStateComponent, final StateStorageOperation operation) throws
|
||||
StateStorageException {
|
||||
@Override
|
||||
protected <T> Storage[] getComponentStorageSpecs(@NotNull final PersistentStateComponent<T> persistentStateComponent,
|
||||
final StateStorageOperation operation) throws StateStorageException {
|
||||
Storage[] result = super.getComponentStorageSpecs(persistentStateComponent, operation);
|
||||
|
||||
if (operation == StateStorageOperation.READ) {
|
||||
@@ -647,6 +653,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ClassExplicitlyAnnotation")
|
||||
private static class MyStorage implements Storage {
|
||||
public String id() {
|
||||
return "___Default___";
|
||||
@@ -716,7 +723,6 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.ide.diff.DirDiffSettings;
|
||||
import com.intellij.ide.diff.JarFileDiffElement;
|
||||
import com.intellij.ide.diff.VirtualFileDiffElement;
|
||||
import com.intellij.ide.highlighter.ArchiveFileType;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
@@ -26,7 +27,6 @@ import com.intellij.openapi.diff.DirDiffManager;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
@@ -42,21 +42,21 @@ public class CompareJarsAction extends AnAction {
|
||||
if (project != null && files != null) {
|
||||
VirtualFileDiffElement src = null;
|
||||
VirtualFileDiffElement trg = null;
|
||||
if (files.length == 2 && isJar(files[0]) && isJar(files[1])) {
|
||||
if (files.length == 2 && isArchive(files[0]) && isArchive(files[1])) {
|
||||
src = new JarFileDiffElement(files[0]);
|
||||
trg = new JarFileDiffElement(files[1]);
|
||||
} else if (files.length == 1 && isJar(files[0])) {
|
||||
} else if (files.length == 1 && isArchive(files[0])) {
|
||||
src = new JarFileDiffElement(files[0]);
|
||||
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, true, false, false) {
|
||||
@Override
|
||||
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
|
||||
return file.isDirectory()
|
||||
|| (!file.isDirectory() && JarFileSystem.PROTOCOL.equalsIgnoreCase(file.getExtension()));
|
||||
|| (!file.isDirectory() && isArchive(file));
|
||||
}
|
||||
};
|
||||
final VirtualFile[] result = FileChooserFactory.getInstance()
|
||||
.createFileChooser(descriptor, project).choose(project.getBaseDir(), project);
|
||||
if (result.length == 1 && result[0] != null && isJar(result[0])) {
|
||||
if (result.length == 1 && result[0] != null && isArchive(result[0])) {
|
||||
trg = new JarFileDiffElement(result[0]);
|
||||
}
|
||||
}
|
||||
@@ -71,10 +71,10 @@ public class CompareJarsAction extends AnAction {
|
||||
public void update(AnActionEvent e) {
|
||||
final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
|
||||
if (files != null && files.length > 0 && files.length < 3) {
|
||||
if (isJar(files[0]) && (files.length == 1 || isJar(files[1]))) {
|
||||
if (isArchive(files[0]) && (files.length == 1 || isArchive(files[1]))) {
|
||||
e.getPresentation().setEnabled(true);
|
||||
e.getPresentation().setVisible(true);
|
||||
e.getPresentation().setText(files.length == 1 ? "Compare Jar File with..." : "Compare Jar Files");
|
||||
e.getPresentation().setText(files.length == 1 ? "Compare Archive File with..." : "Compare Archives");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class CompareJarsAction extends AnAction {
|
||||
e.getPresentation().setVisible(false);
|
||||
}
|
||||
|
||||
private static boolean isJar(VirtualFile file) {
|
||||
return JarFileSystem.PROTOCOL.equalsIgnoreCase(file.getExtension());
|
||||
private static boolean isArchive(VirtualFile file) {
|
||||
return file.getFileType() instanceof ArchiveFileType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ public class CompositeDiffPanel implements DiffViewer {
|
||||
viewer.setDiffRequest(diffRequest);
|
||||
} else {
|
||||
final DiffViewer newViewer = myRequest.viewerForRequest(myWindow, myParentDisposable, key, diffRequest);
|
||||
if (newViewer == null) continue;
|
||||
myMap.put(key, newViewer);
|
||||
final Content content = myUi.createContent(key, newViewer.getComponent(), key, null, newViewer.getPreferredFocusedComponent());
|
||||
content.setCloseable(false);
|
||||
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.diff.impl.external;
|
||||
|
||||
import com.intellij.ide.diff.JarFileDiffElement;
|
||||
import com.intellij.ide.highlighter.ArchiveFileType;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diff.*;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ArchiveDiffTool implements DiffTool {
|
||||
public static final ArchiveDiffTool INSTANCE = new ArchiveDiffTool();
|
||||
|
||||
private ArchiveDiffTool(){}
|
||||
|
||||
@Override
|
||||
public void show(DiffRequest request) {
|
||||
final DiffContent[] contents = request.getContents();
|
||||
final VirtualFile file1 = contents[0].getFile();
|
||||
final VirtualFile file2 = contents[1].getFile();
|
||||
assert file1 != null && file2 != null;
|
||||
final JarFileDiffElement element = new JarFileDiffElement(file1);
|
||||
final JarFileDiffElement element1 = new JarFileDiffElement(file2);
|
||||
DirDiffManager.getInstance(request.getProject()).showDiff(element, element1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShow(DiffRequest request) {
|
||||
final DiffContent[] contents = request.getContents();
|
||||
final DialogWrapper instance = DialogWrapper.findInstance(IdeFocusManager.getInstance(request.getProject()).getFocusOwner());
|
||||
if (instance != null && instance.isModal()) return false;
|
||||
if (contents.length == 2) {
|
||||
final VirtualFile file1 = contents[0].getFile();
|
||||
final VirtualFile file2 = contents[1].getFile();
|
||||
if (file1 != null && file2 != null) {
|
||||
final FileType type1 = contents[0].getContentType();
|
||||
final FileType type2 = contents[1].getContentType();
|
||||
return type1 == type2 && type1 instanceof ArchiveFileType;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiffViewer createComponent(String title, DiffRequest request, Window window, Disposable parentDisposable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.diff.impl.external;
|
||||
|
||||
import com.intellij.ide.highlighter.ArchiveFileType;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.*;
|
||||
@@ -57,12 +58,17 @@ class CompositeDiffTool implements DiffTool {
|
||||
private DiffTool chooseTool(DiffRequest data) {
|
||||
final DiffContent[] contents = data.getContents();
|
||||
|
||||
if (contents != null && contents.length == 2) {
|
||||
if (contents.length == 2) {
|
||||
final FileType type1 = contents[0].getContentType();
|
||||
final FileType type2 = contents[1].getContentType();
|
||||
if (type1 == type2 && type1 instanceof UIBasedFileType) {
|
||||
return BinaryDiffTool.INSTANCE;
|
||||
}
|
||||
|
||||
//todo[kb] register or not this instance in common diff tools ?
|
||||
if (type1 == type2 && type1 instanceof ArchiveFileType) {
|
||||
return ArchiveDiffTool.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
for (DiffTool tool : myTools) {
|
||||
|
||||
+10
-6
@@ -48,7 +48,7 @@ class FrameDiffTool implements DiffTool {
|
||||
boolean shouldOpenDialog = shouldOpenDialog(hints);
|
||||
if (shouldOpenDialog) {
|
||||
final DialogBuilder builder = new DialogBuilder(request.getProject());
|
||||
DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, builder.getWindow(), builder);
|
||||
DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, builder.getWindow(), builder, true);
|
||||
if (diffPanel == null) {
|
||||
Disposer.dispose(builder);
|
||||
return;
|
||||
@@ -83,7 +83,7 @@ class FrameDiffTool implements DiffTool {
|
||||
}
|
||||
else {
|
||||
final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
|
||||
DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, frameWrapper.getFrame(), frameWrapper);
|
||||
DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, frameWrapper.getFrame(), frameWrapper, true);
|
||||
if (diffPanel == null) {
|
||||
Disposer.dispose(frameWrapper);
|
||||
return;
|
||||
@@ -134,9 +134,10 @@ class FrameDiffTool implements DiffTool {
|
||||
}*/
|
||||
|
||||
@Nullable
|
||||
private static DiffPanelImpl createDiffPanelIfShouldShow(DiffRequest request, Window window, @NotNull Disposable parentDisposable) {
|
||||
private static DiffPanelImpl createDiffPanelIfShouldShow(DiffRequest request, Window window, @NotNull Disposable parentDisposable,
|
||||
final boolean showMessage) {
|
||||
DiffPanelImpl diffPanel = (DiffPanelImpl)DiffManagerImpl.createDiffPanel(request, window, parentDisposable);
|
||||
if (checkNoDifferenceAndNotify(diffPanel, request, window)) {
|
||||
if (checkNoDifferenceAndNotify(diffPanel, request, window, showMessage)) {
|
||||
Disposer.dispose(diffPanel);
|
||||
diffPanel = null;
|
||||
}
|
||||
@@ -154,7 +155,7 @@ class FrameDiffTool implements DiffTool {
|
||||
return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() instanceof JDialog;
|
||||
}
|
||||
|
||||
private static boolean checkNoDifferenceAndNotify(DiffPanel diffPanel, DiffRequest data, final Window window) {
|
||||
private static boolean checkNoDifferenceAndNotify(DiffPanel diffPanel, DiffRequest data, final Window window, final boolean showMessage) {
|
||||
if (!diffPanel.hasDifferences() && !data.getHints().contains(HINT_ALLOW_NO_DIFFERENCES)) {
|
||||
DiffManagerImpl manager = (DiffManagerImpl) DiffManager.getInstance();
|
||||
if (!Comparing.equal(manager.getComparisonPolicy(), ComparisonPolicy.DEFAULT)) {
|
||||
@@ -170,6 +171,9 @@ class FrameDiffTool implements DiffTool {
|
||||
if (hasDiffs) return false;
|
||||
}
|
||||
|
||||
if (! showMessage) {
|
||||
return true;
|
||||
}
|
||||
return !askForceOpenDiff(data);
|
||||
}
|
||||
return false;
|
||||
@@ -208,6 +212,6 @@ class FrameDiffTool implements DiffTool {
|
||||
|
||||
@Override
|
||||
public DiffViewer createComponent(String title, DiffRequest request, Window window, Disposable parentDisposable) {
|
||||
return createDiffPanelIfShouldShow(request, window, parentDisposable);
|
||||
return createDiffPanelIfShouldShow(request, window, parentDisposable, false);
|
||||
}
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.editor.impl;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author gregsh
|
||||
*/
|
||||
public class EditorHeaderComponent extends JPanel {
|
||||
private final Color GRADIENT_C1;
|
||||
private final Color GRADIENT_C2;
|
||||
|
||||
public EditorHeaderComponent() {
|
||||
super(new BorderLayout(0, 0));
|
||||
GRADIENT_C1 = getBackground();
|
||||
GRADIENT_C2 = new Color(Math.max(0, GRADIENT_C1.getRed() - 0x18), Math.max(0, GRADIENT_C1.getGreen() - 0x18),
|
||||
Math.max(0, GRADIENT_C1.getBlue() - 0x18));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
final Graphics2D g2d = (Graphics2D)g;
|
||||
|
||||
if (!UIUtil.isUnderGTKLookAndFeel()) {
|
||||
g2d.setPaint(new GradientPaint(0, 0, GRADIENT_C1, 0, getHeight(), GRADIENT_C2));
|
||||
g2d.fillRect(1, 1, getWidth(), getHeight() - 1);
|
||||
g2d.setPaint(null);
|
||||
}
|
||||
|
||||
g.setColor(UIUtil.getBorderColor());
|
||||
g.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
|
||||
}
|
||||
}
|
||||
@@ -127,6 +127,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public final class EditorImpl extends UserDataHolderBase implements EditorEx, HighlighterClient, Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.EditorImpl");
|
||||
private static final Key DND_COMMAND_KEY = Key.create("DndCommand");
|
||||
public static final Key<JComponent> PERMANENT_HEADER = Key.create("PERMANENT_HEADER");
|
||||
public static final Key<Boolean> DO_DOCUMENT_UPDATE_TEST = Key.create("DoDocumentUpdateTest");
|
||||
public static final Key<Pair<String, String>> EDITABLE_AREA_MARKER = Key.create("editable.area.marker");
|
||||
private static final boolean HONOR_CAMEL_HUMPS_ON_TRIPLE_CLICK
|
||||
@@ -1682,6 +1683,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
graphics.setClip(rect.x, rect.y, rect.width, rect.height);
|
||||
paint(graphics);
|
||||
graphics.translate(rect.x, rect.y);
|
||||
graphics.dispose();
|
||||
putUserData(BUFFER, image);
|
||||
}
|
||||
|
||||
@@ -1767,6 +1769,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
@Override
|
||||
public void setHeaderComponent(JComponent header) {
|
||||
myHeaderPanel.removeAll();
|
||||
header = header == null? getUserData(PERMANENT_HEADER) : header;
|
||||
if (header != null) {
|
||||
myHeaderPanel.add(header);
|
||||
}
|
||||
|
||||
+21
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -39,6 +39,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.*;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerAdapter;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
||||
import com.intellij.ui.InplaceButton;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.docking.DockManager;
|
||||
import com.intellij.ui.docking.DockableContent;
|
||||
@@ -474,6 +475,8 @@ final class EditorTabbedContainer implements Disposable, CloseAction.CloseTarget
|
||||
}
|
||||
|
||||
private class TabMouseListener extends MouseAdapter {
|
||||
private int myActionClickCount;
|
||||
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (UIUtil.isCloseClick(e, MouseEvent.MOUSE_PRESSED)) {
|
||||
@@ -485,9 +488,19 @@ final class EditorTabbedContainer implements Disposable, CloseAction.CloseTarget
|
||||
}
|
||||
}
|
||||
|
||||
if (UIUtil.isActionClick(e) && (e.getClickCount() % 2) == 0 && !isFloating()) {
|
||||
final ActionManager mgr = ActionManager.getInstance();
|
||||
mgr.tryToExecute(mgr.getAction("HideAllWindows"), e, null, ActionPlaces.UNKNOWN, true);
|
||||
if (UIUtil.isActionClick(e)) {
|
||||
if (e.getClickCount() == 1) {
|
||||
myActionClickCount = 0;
|
||||
}
|
||||
// clicks on the close window button don't count in determining whether we have a double-click on tab (IDEA-70403)
|
||||
final Component deepestComponent = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
|
||||
if (!(deepestComponent instanceof InplaceButton)) {
|
||||
myActionClickCount++;
|
||||
}
|
||||
if (myActionClickCount == 2 && !isFloating()) {
|
||||
final ActionManager mgr = ActionManager.getInstance();
|
||||
mgr.tryToExecute(mgr.getAction("HideAllWindows"), e, null, ActionPlaces.UNKNOWN, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,6 +598,7 @@ final class EditorTabbedContainer implements Disposable, CloseAction.CloseTarget
|
||||
public void dragOutFinished(MouseEvent event, TabInfo source) {
|
||||
boolean copy = event.isMetaDown() || (!SystemInfo.isMac && event.isControlDown());
|
||||
if (!copy) {
|
||||
myFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, Boolean.TRUE);
|
||||
FileEditorManagerEx.getInstanceEx(myProject).closeFile(myFile, myWindow);
|
||||
}
|
||||
else {
|
||||
@@ -592,6 +606,9 @@ final class EditorTabbedContainer implements Disposable, CloseAction.CloseTarget
|
||||
}
|
||||
|
||||
mySession.process(event);
|
||||
if (!copy) {
|
||||
myFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, null);
|
||||
}
|
||||
|
||||
myFile = null;
|
||||
mySession = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -464,6 +464,7 @@ public class EditorWindow {
|
||||
return myPanel.getSize();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EditorTabbedContainer getTabbedPane() {
|
||||
return myTabbedPane;
|
||||
}
|
||||
|
||||
+1
@@ -96,6 +96,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
|
||||
|
||||
private static final FileEditor[] EMPTY_EDITOR_ARRAY = {};
|
||||
private static final FileEditorProvider[] EMPTY_PROVIDER_ARRAY = {};
|
||||
public static final Key<Boolean> CLOSING_TO_REOPEN = Key.create("CLOSING_TO_REOPEN");
|
||||
|
||||
private volatile JPanel myPanels;
|
||||
private EditorsSplitters mySplitters;
|
||||
|
||||
@@ -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.
|
||||
@@ -71,7 +71,6 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
||||
public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.project.impl.ProjectImpl");
|
||||
private static final String PLUGIN_SETTINGS_ERROR = "Plugin Settings Error";
|
||||
@@ -103,10 +102,14 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
myOptimiseTestLoadSpeed = isOptimiseTestLoadSpeed;
|
||||
|
||||
myManager = manager;
|
||||
|
||||
myName = isDefault() ? TEMPLATE_PROJECT_NAME : projectName == null ? getStateStore().getProjectName() : projectName;
|
||||
if (!isDefault() && projectName != null && getStateStore().getStorageScheme().equals(StorageScheme.DIRECTORY_BASED)) myOldName = ""; // new project
|
||||
if (!isDefault() && projectName != null && getStateStore().getStorageScheme().equals(StorageScheme.DIRECTORY_BASED)) {
|
||||
myOldName = ""; // new project
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectName(@NotNull String projectName) {
|
||||
if (!projectName.equals(myName)) {
|
||||
myOldName = myName;
|
||||
@@ -175,6 +178,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public synchronized IProjectStore getStateStore() {
|
||||
if (myComponentStore == null) {
|
||||
myComponentStore = (IProjectStore)getPicoContainer().getComponentInstance(IComponentStore.class);
|
||||
@@ -196,10 +200,12 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
getStateStore().initComponent(component, service);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return ProjectManagerEx.getInstanceEx().isProjectOpened(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return isOpen() && !isDisposed() && StartupManagerEx.getInstanceEx(this).startupActivityPassed();
|
||||
}
|
||||
@@ -217,40 +223,49 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
return getStateStore().getProjectFilePath();
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getProjectFile() {
|
||||
return getStateStore().getProjectFile();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getBaseDir() {
|
||||
return getStateStore().getProjectBaseDir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePath() {
|
||||
return getStateStore().getProjectBasePath();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NonNls
|
||||
@Override
|
||||
public String getPresentableUrl() {
|
||||
if (myName == null) return null; // not yet initialized
|
||||
return getStateStore().getPresentableUrl();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNls
|
||||
@Override
|
||||
public String getLocationHash() {
|
||||
String str = getPresentableUrl();
|
||||
if (str == null) str = getName();
|
||||
|
||||
final String prefix = getStateStore().getStorageScheme() == StorageScheme.DIRECTORY_BASED? "" : getName();
|
||||
final String prefix = getStateStore().getStorageScheme() == StorageScheme.DIRECTORY_BASED ? "" : getName();
|
||||
return prefix + Integer.toHexString(str.hashCode());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Nullable
|
||||
@NonNls
|
||||
@Override
|
||||
public String getLocation() {
|
||||
if (myName == null) return null; // was called before initialized
|
||||
return isDisposed() ? null : getStateStore().getLocation();
|
||||
@@ -261,15 +276,17 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
return getStateStore().getWorkspaceFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOptimiseTestLoadSpeed() {
|
||||
return myOptimiseTestLoadSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptimiseTestLoadSpeed(final boolean optimiseTestLoadSpeed) {
|
||||
myOptimiseTestLoadSpeed = optimiseTestLoadSpeed;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
long start = System.currentTimeMillis();
|
||||
// ProfilingUtil.startCPUProfiling();
|
||||
@@ -297,6 +314,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (ApplicationManagerEx.getApplicationEx().isDoNotSave()) return; //no need to save
|
||||
|
||||
@@ -327,11 +345,14 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
catch (PluginException e) {
|
||||
PluginManager.disablePlugin(e.getPluginId().getIdString());
|
||||
Notifications.Bus.notify(new Notification(PLUGIN_SETTINGS_ERROR, "Unable to save plugin settings!",
|
||||
"<p>The plugin <i>" + e.getPluginId() + "</i> failed to save settings and has been disabled. Please restart" +
|
||||
ApplicationNamesInfo.getInstance().getFullProductName() + "</p>" +
|
||||
(ApplicationManagerEx.getApplicationEx().isInternal() ? "<p>" + StringUtil.getThrowableText(e) + "</p>": ""),
|
||||
NotificationType.ERROR), NotificationDisplayType.BALLOON, this);
|
||||
Notification notification = new Notification(
|
||||
PLUGIN_SETTINGS_ERROR,
|
||||
"Unable to save plugin settings!",
|
||||
"<p>The plugin <i>" + e.getPluginId() + "</i> failed to save settings and has been disabled. Please restart" +
|
||||
ApplicationNamesInfo.getInstance().getFullProductName() + "</p>" +
|
||||
(ApplicationManagerEx.getApplicationEx().isInternal() ? "<p>" + StringUtil.getThrowableText(e) + "</p>" : ""),
|
||||
NotificationType.ERROR);
|
||||
Notifications.Bus.notify(notification, this);
|
||||
LOG.info("Unable to save plugin settings",e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -344,6 +365,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dispose() {
|
||||
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
|
||||
assert application.isWriteAccessAllowed(); // dispose must be under write action
|
||||
@@ -382,7 +404,6 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void projectClosed() {
|
||||
List<ProjectComponent> components = new ArrayList<ProjectComponent>(Arrays.asList(getComponents(ProjectComponent.class)));
|
||||
@@ -397,6 +418,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
|
||||
return Extensions.getArea(this).getExtensionPoint(extensionPointName).getExtensions();
|
||||
}
|
||||
@@ -423,10 +445,12 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
return Extensions.getArea(this).getPicoContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUnknownMacros(final boolean showDialog) {
|
||||
final IProjectStore stateStore = getStateStore();
|
||||
|
||||
@@ -472,7 +496,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (Messages.showYesNoDialog(this, "Component could not be reloaded. Reload project?", "Configuration changed",
|
||||
if (Messages.showYesNoDialog(this, "Component could not be reloaded. Reload project?", "Configuration Changed",
|
||||
Messages.getQuestionIcon()) == 0) {
|
||||
ProjectManagerEx.getInstanceEx().reloadProject(this);
|
||||
}
|
||||
@@ -483,13 +507,12 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Project"
|
||||
+ (isDisposed() ? " (Disposed" + (temporarilyDisposed ? " temporarily" : "") + ")"
|
||||
:isDefault() ? "" : " '" + getLocation()+"'")
|
||||
+ (isDefault() ? " (Default)" : "")
|
||||
+ " " + myName
|
||||
;
|
||||
public String toString() {
|
||||
return "Project" +
|
||||
(isDisposed() ? " (Disposed" + (temporarilyDisposed ? " temporarily" : "") + ")"
|
||||
: isDefault() ? "" : " '" + getPresentableUrl() + "'") +
|
||||
(isDefault() ? " (Default)" : "") +
|
||||
" " + myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -918,7 +918,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
ProjectImpl projectImpl = (ProjectImpl)project[0];
|
||||
if (projectImpl.isDisposed()) return;
|
||||
IProjectStore projectStore = projectImpl.getStateStore();
|
||||
final String location = projectImpl.getLocation();
|
||||
final String location = projectImpl.getPresentableUrl();
|
||||
|
||||
final List<IFile> original;
|
||||
try {
|
||||
|
||||
@@ -335,6 +335,11 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
myDialog.setModal(modal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModal() {
|
||||
return myDialog.isModal();
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return myDialog.isVisible();
|
||||
}
|
||||
|
||||
+5
@@ -219,6 +219,11 @@ public class GlassPaneDialogWrapperPeer extends DialogWrapperPeer implements Foc
|
||||
LOG.assertTrue(modal, "Can't be non modal!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return myDialog != null && myDialog.isVisible();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user