Merge remote-tracking branch 'origin/master'

This commit is contained in:
Alexander Zolotov
2013-01-26 19:04:42 +04:00
105 changed files with 3526 additions and 1047 deletions
+3
View File
@@ -593,6 +593,9 @@
<inspection_tool class="UnterminatedStatementJS" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ignoreSemicolonAtEndOfBlock" value="true" />
</inspection_tool>
<inspection_tool class="UseJBColor" enabled="true" level="WARNING" enabled_by_default="true">
<scope name="Tests" level="WARNING" enabled="false" />
</inspection_tool>
<inspection_tool class="UseOfPropertiesAsHashtable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UtilityClassWithPublicConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="WaitNotInLoop" enabled="true" level="WARNING" enabled_by_default="true" />
+2 -2
View File
@@ -1,11 +1,11 @@
<component name="libraryTable">
<library name="Eclipse">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/ecj-4.2.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/ecj-4.2.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/src/ecjsrc-4.2.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/src/ecjsrc-4.2.1.jar!/" />
</SOURCES>
</library>
</component>
+1 -20
View File
@@ -4,25 +4,6 @@
<root url="jar://$PROJECT_DIR$/lib/groovy-all-2.0.6.jar!/"/>
</CLASSES>
<JAVADOC/>
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-json/src/main/groovy"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-json/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-xml/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-servlet/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-console/src/main/groovy"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-bsf/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-groovysh/src/main/groovy"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-templates/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-sql/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-swing/src/main/groovy"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-swing/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-groovydoc/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-jsr223/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-jmx/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/subprojects/groovy-ant/src/main/java"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/src/tck/src"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/src/examples"/>
<root url="jar://$PROJECT_DIR$/lib/src/groovy-src-2.0.6.zip!/groovy-2.0.6/src/main"/>
</SOURCES>
<SOURCES/>
</library>
</component>
+1 -1
View File
@@ -212,7 +212,7 @@ libraryLicense(name: "Microba", libraryName: "microba", version: "0.4.2", licens
libraryLicense(name: "MigLayout", libraryName: "miglayout-swing", version: "3.7.1", license: "BSD", url: "http://www.miglayout.com/", licenseUrl: "http://www.miglayout.com/mavensite/license.html")
libraryLicense(name: "NanoXML", version: "2.2.3", license: "zlib/libpng", url: "http://nanoxml.cyberelf.be/", licenseUrl: "http://devkix.com/nanoxml.php")
libraryLicense(name: "nekohtml", libraryName: "nekohtml", version: "1.9.14", license: "Apache 2.0", url: "http://nekohtml.sourceforge.net/", licenseUrl: "http://apache.org/licenses/LICENSE-2.0.txt")
libraryLicense(name: "Eclipse JDT Core", libraryName: "Eclipse", version: "4.2", license: "CPL 1.0", url: "http://www.eclipse.org/jdt/core/index.php")
libraryLicense(name: "Eclipse JDT Core", libraryName: "Eclipse", version: "4.2.1", license: "CPL 1.0", url: "http://www.eclipse.org/jdt/core/index.php")
libraryLicense(name: "Jakarta ORO", libraryName: "OroMatcher", version: "2.0.8", license: "Apache", url: "http://jakarta.apache.org/oro/", licenseUrl: "http://svn.apache.org/repos/asf/jakarta/oro/trunk/LICENSE")
libraryLicense(name: "PicoContainer", libraryName: "picocontainer", version: "1.2", license: "BSD", url: "http://www.picocontainer.org/", licenseUrl: "http://docs.codehaus.org/display/PICO/License")
libraryLicense(name: "Plexus Utils", libraryName: "plexus-utils-1.5.5.jar", version: "1.5.5", license: "Apache 2.0", url: "http://plexus.codehaus.org/plexus-utils")
@@ -3,13 +3,14 @@
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="CONSOLE_BACKGROUND_KEY" value="000000" />
<option name="INDENT_GUIDE" value="404040" />
<option name="SELECTION_BACKGROUND" value="644d6e" />
<option name="CARET_ROW_COLOR" value="333300" />
<option name="WHITESPACES" value="404040" />
<option name="CARET_COLOR" value="FFFFFF" />
<option name="LINE_NUMBERS_COLOR" value="FFFFFF" />
<option name="CONSOLE_BACKGROUND_KEY" value="000000" />
<option name="SELECTED_INDENT_GUIDE" value="404040" />
<option name="GUTTER_BACKGROUND" value="000000" />
</colors>
<attributes>
+2 -1
View File
@@ -3,13 +3,14 @@
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="CONSOLE_BACKGROUND_KEY" value="0C1021" />
<option name="INDENT_GUIDE" value="484b58" />
<option name="SELECTION_BACKGROUND" value="253B76" />
<option name="CARET_ROW_COLOR" value="1a1e2e" />
<option name="WHITESPACES" value="484b58" />
<option name="CARET_COLOR" value="FFFFFF" />
<option name="LINE_NUMBERS_COLOR" value="F8F8F8" />
<option name="CONSOLE_BACKGROUND_KEY" value="0C1021" />
<option name="SELECTED_INDENT_GUIDE" value="484b58" />
<option name="GUTTER_BACKGROUND" value="0C1021" />
</colors>
<attributes>
+2 -1
View File
@@ -3,13 +3,14 @@
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="CONSOLE_BACKGROUND_KEY" value="002240" />
<option name="INDENT_GUIDE" value="25425c" />
<option name="SELECTION_BACKGROUND" value="85533a" />
<option name="CARET_ROW_COLOR" value="001629" />
<option name="WHITESPACES" value="25425c" />
<option name="CARET_COLOR" value="FFFFFF" />
<option name="LINE_NUMBERS_COLOR" value="FFFFFF" />
<option name="CONSOLE_BACKGROUND_KEY" value="002240" />
<option name="SELECTED_INDENT_GUIDE" value="25425c" />
<option name="GUTTER_BACKGROUND" value="002240" />
</colors>
<attributes>
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -3,13 +3,14 @@
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="CONSOLE_BACKGROUND_KEY" value="272822" />
<option name="INDENT_GUIDE" value="3B3A32" />
<option name="SELECTION_BACKGROUND" value="49483E" />
<option name="CARET_ROW_COLOR" value="3E3D32" />
<option name="WHITESPACES" value="3B3A32" />
<option name="CARET_COLOR" value="F8F8F0" />
<option name="LINE_NUMBERS_COLOR" value="F8F8F2" />
<option name="CONSOLE_BACKGROUND_KEY" value="272822" />
<option name="SELECTED_INDENT_GUIDE" value="3B3A32" />
<option name="GUTTER_BACKGROUND" value="272822" />
</colors>
<attributes>
@@ -3,13 +3,14 @@
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="CONSOLE_BACKGROUND_KEY" value="2B2B2B" />
<option name="INDENT_GUIDE" value="404040" />
<option name="SELECTION_BACKGROUND" value="545c73" />
<option name="CARET_ROW_COLOR" value="333435" />
<option name="WHITESPACES" value="404040" />
<option name="CARET_COLOR" value="FFFFFF" />
<option name="LINE_NUMBERS_COLOR" value="E6E1DC" />
<option name="CONSOLE_BACKGROUND_KEY" value="2B2B2B" />
<option name="SELECTED_INDENT_GUIDE" value="404040" />
<option name="GUTTER_BACKGROUND" value="2B2B2B" />
</colors>
<attributes>
+2 -1
View File
@@ -3,13 +3,14 @@
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="CONSOLE_BACKGROUND_KEY" value="141414" />
<option name="INDENT_GUIDE" value="4e4e4e" />
<option name="SELECTION_BACKGROUND" value="3c3f42" />
<option name="CARET_ROW_COLOR" value="1b1b1b" />
<option name="WHITESPACES" value="4e4e4e" />
<option name="CARET_COLOR" value="A7A7A7" />
<option name="LINE_NUMBERS_COLOR" value="F8F8F8" />
<option name="CONSOLE_BACKGROUND_KEY" value="141414" />
<option name="SELECTED_INDENT_GUIDE" value="4e4e4e" />
<option name="GUTTER_BACKGROUND" value="141414" />
</colors>
<attributes>
@@ -33,6 +33,9 @@ import com.intellij.openapi.application.*;
import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.event.DocumentAdapter;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl;
import com.intellij.openapi.module.Module;
@@ -121,7 +124,8 @@ public class BuildManager implements ApplicationComponent{
private static final String SYSTEM_ROOT = "compile-server";
private static final String LOGGER_CONFIG = "log.xml";
private static final String DEFAULT_LOGGER_CONFIG = "defaultLogConfig.xml";
private static final int MAKE_TRIGGER_DELAY = 3 * 1000 /*3 seconds*/;
private static final int MAKE_TRIGGER_DELAY = 300 /*300 ms*/;
private static final int DOCUMENT_SAVE_TRIGGER_DELAY = 1500 /*1.5 sec*/;
private final boolean IS_UNIT_TEST_MODE;
private static final String IWS_EXTENSION = ".iws";
private static final String IPR_EXTENSION = ".ipr";
@@ -151,10 +155,55 @@ public class BuildManager implements ApplicationComponent{
private final SequentialTaskExecutor myRequestsProcessor = new SequentialTaskExecutor(myPooledThreadExecutor);
private final Map<String, ProjectData> myProjectDataMap = Collections.synchronizedMap(new HashMap<String, ProjectData>());
private final Alarm myMakeScheduleAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
private final AtomicBoolean myAutoMakeInProgress = new AtomicBoolean(false);
private final Alarm myProjectsSaveAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
private final AtomicBoolean myProjectsSaveInProgress = new AtomicBoolean(false);
private final BuildManagerPeriodicTask myAutoMakeTask = new BuildManagerPeriodicTask() {
@Override
protected int getDelay() {
return Registry.intValue("compiler.automake.trigger.delay", MAKE_TRIGGER_DELAY);
}
@Override
protected void runTask() {
runAutoMake();
}
};
private final BuildManagerPeriodicTask myDocumentSaveTask = new BuildManagerPeriodicTask() {
@Override
protected int getDelay() {
return Registry.intValue("compiler.document.save.trigger.delay", DOCUMENT_SAVE_TRIGGER_DELAY);
}
private final Semaphore mySemaphore = new Semaphore();
private final Runnable mySaveDocsRunnable = new Runnable() {
@Override
public void run() {
try {
FileDocumentManager.getInstance().saveAllDocuments();
}
finally {
mySemaphore.up();
}
}
};
@Override
public void runTask() {
if (shouldSaveDocuments()) {
mySemaphore.down();
ApplicationManager.getApplication().invokeLater(mySaveDocsRunnable, ModalityState.NON_MODAL);
mySemaphore.waitFor();
}
}
private boolean shouldSaveDocuments() {
for (final Project project : getActiveProjects()) {
if (canStartAutoMake(project)) {
return true;
}
}
return false;
}
};
private final ChannelGroup myAllOpenChannels = new DefaultChannelGroup("build-manager");
private final BuildMessageDispatcher myMessageDispatcher = new BuildMessageDispatcher();
@@ -218,9 +267,9 @@ public class BuildManager implements ApplicationComponent{
});
application.addApplicationListener(new ApplicationAdapter() {
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentAdapter() {
@Override
public void writeActionFinished(Object action) {
public void documentChanged(DocumentEvent e) {
scheduleProjectSave();
}
});
@@ -361,84 +410,16 @@ public class BuildManager implements ApplicationComponent{
public void scheduleAutoMake() {
if (!IS_UNIT_TEST_MODE && !PowerSaveMode.isEnabled()) {
scheduleTask(myMakeScheduleAlarm, myAutoMakeInProgress, new Runnable() {
@Override
public void run() {
runAutoMake();
}
});
myAutoMakeTask.schedule();
}
}
private void scheduleProjectSave() {
if (!IS_UNIT_TEST_MODE && !PowerSaveMode.isEnabled()) {
scheduleTask(myProjectsSaveAlarm, myProjectsSaveInProgress, new Runnable() {
@Override
public void run() {
boolean shouldSave = false;
for (final Project project : getActiveProjects()) {
if (canStartAutoMake(project)) {
shouldSave = true;
break;
}
}
if (shouldSave) {
final Semaphore semaphore = new Semaphore();
semaphore.down();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
try {
FileDocumentManager.getInstance().saveAllDocuments();
}
finally {
semaphore.up();
}
}
}, ModalityState.NON_MODAL);
semaphore.waitFor();
}
}
});
myDocumentSaveTask.schedule();
}
}
private static void scheduleTask(final Alarm alarm, final AtomicBoolean taskLatch, final Runnable task) {
alarm.cancelAllRequests();
final int delay = Math.max(50, Registry.intValue("compiler.automake.trigger.delay", MAKE_TRIGGER_DELAY));
alarm.addRequest(new Runnable() {
@Override
public void run() {
if (!HeavyProcessLatch.INSTANCE.isRunning() && !taskLatch.getAndSet(true)) {
try {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
try {
task.run();
}
finally {
taskLatch.set(false);
}
}
});
}
catch (RejectedExecutionException ignored) {
// we were shut down
taskLatch.set(false);
}
catch (Throwable e) {
taskLatch.set(false);
throw new RuntimeException(e);
}
}
else {
scheduleTask(alarm, taskLatch, task);
}
}
}, delay);
}
private void runAutoMake() {
final List<RequestFuture> futures = new ArrayList<RequestFuture>();
for (final Project project : getActiveProjects()) {
@@ -1066,6 +1047,52 @@ public class BuildManager implements ApplicationComponent{
}
}
private static abstract class BuildManagerPeriodicTask implements Runnable {
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
private final AtomicBoolean myInProgress = new AtomicBoolean(false);
private final Runnable myTaskRunnable = new Runnable() {
@Override
public void run() {
try {
runTask();
}
finally {
myInProgress.set(false);
}
}
};
public final void schedule() {
myAlarm.cancelAllRequests();
final int delay = Math.max(100, getDelay());
myAlarm.addRequest(this, delay);
}
protected abstract int getDelay();
protected abstract void runTask();
@Override
public final void run() {
if (!HeavyProcessLatch.INSTANCE.isRunning() && !myInProgress.getAndSet(true)) {
try {
ApplicationManager.getApplication().executeOnPooledThread(myTaskRunnable);
}
catch (RejectedExecutionException ignored) {
// we were shut down
myInProgress.set(false);
}
catch (Throwable e) {
myInProgress.set(false);
throw new RuntimeException(e);
}
}
else {
schedule();
}
}
}
private class ProjectWatcher extends ProjectManagerAdapter {
private final Map<Project, MessageBusConnection> myConnections = new HashMap<Project, MessageBusConnection>();
@@ -30,6 +30,7 @@ import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Trinity;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -159,7 +160,8 @@ public class PackageFileWorker {
try {
final JBZipEntry entry = zipFile.getOrCreateEntry(nextPathInArchive);
LOG.debug(" extracting to temp file: " + nextPathInArchive + " from " + archivePath);
final File tempFile = FileUtil.createTempFile("packageFile" + FileUtil.sanitizeFileName(nextPathInArchive), FileUtil.getExtension(PathUtil.getFileName(nextPathInArchive)));
final File tempFile = FileUtil.createTempFile("packageFile" + FileUtil.sanitizeFileName(nextPathInArchive),
FileUtilRt.getExtension(PathUtil.getFileName(nextPathInArchive)));
if (entry.getSize() != -1) {
FileUtil.writeToFile(tempFile, entry.getData());
}
@@ -18,6 +18,7 @@ package com.intellij.ide.util.projectWizard.importSources;
import com.intellij.ide.util.projectWizard.importSources.util.CommonSourceRootDetectionUtil;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.NullableFunction;
import org.jetbrains.annotations.NotNull;
@@ -35,10 +36,10 @@ public abstract class JavaSourceRootDetector extends ProjectStructureDetector {
final String fileExtension = getFileExtension();
for (File child : children) {
if (child.isFile()) {
String extension = FileUtil.getExtension(child.getName());
if (extension.equals(fileExtension)) {
if (FileUtilRt.extensionEquals(child.getName(), fileExtension)) {
Pair<File, String> root = CommonSourceRootDetectionUtil.IO_FILE.suggestRootForFileWithPackageStatement(child, base,
getPackageNameFetcher(), true);
getPackageNameFetcher(),
true);
if (root != null) {
result.add(new JavaModuleSourceRoot(root.getFirst(), root.getSecond(), getLanguageName()));
return DirectoryProcessingResult.skipChildrenAndParentsUpTo(root.getFirst());
@@ -39,6 +39,7 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.packaging.artifacts.Artifact;
@@ -447,7 +448,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName);
final String name = ((ArchivePackagingElement)root).getArchiveFileName();
final String fileName = FileUtil.getNameWithoutExtension(name);
final String extension = FileUtil.getExtension(name);
final String extension = FileUtilRt.getExtension(name);
if (fileName.equals(oldFileName) && extension.length() > 0) {
myLayoutTreeComponent.editLayout(new Runnable() {
@Override
@@ -37,8 +37,11 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChangeLibraryLe
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.PathUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -125,7 +128,7 @@ public abstract class ChangeLibraryLevelActionBase extends AnAction {
for (final File from : filesToProcess) {
indicator.checkCanceled();
final File to = FileUtil.findSequentNonexistentFile(targetDir, FileUtil.getNameWithoutExtension(from),
FileUtil.getExtension(from.getName()));
FileUtilRt.getExtension(from.getName()));
try {
if (from.isDirectory()) {
if (myCopy) {
@@ -38,7 +38,7 @@ import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.NullableComputable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.io.StreamUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -157,7 +157,7 @@ public class TemplateModuleBuilder extends ModuleBuilder {
ZipUtil.unzip(ProgressManager.getInstance().getProgressIndicator(), dir, zipInputStream, moduleMode ? PATH_CONVERTOR : null, new ZipUtil.ContentProcessor() {
@Override
public byte[] processContent(byte[] content, String fileName) throws IOException {
FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(FileUtil.getExtension(fileName));
FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(FileUtilRt.getExtension(fileName));
return fileType.isBinary() ? content : processTemplates(new String(content));
}
});
@@ -21,6 +21,7 @@ import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.util.Comparing;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -150,7 +151,14 @@ public class SillyAssignmentInspection extends BaseJavaLocalInspectionTool {
private static PsiJavaCodeReferenceElement getQualifier(PsiElement qualifier) {
if (qualifier instanceof PsiThisExpression) {
return ((PsiThisExpression)qualifier).getQualifier();
final PsiJavaCodeReferenceElement thisQualifier = ((PsiThisExpression)qualifier).getQualifier();
if (thisQualifier != null) {
final PsiClass innerMostClass = PsiTreeUtil.getParentOfType(thisQualifier, PsiClass.class);
if (innerMostClass == thisQualifier.resolve()) {
return null;
}
}
return thisQualifier;
} else if (qualifier != null) {
return ((PsiSuperExpression)qualifier).getQualifier();
}
@@ -21,15 +21,14 @@ package com.intellij.internal;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.*;
public class BuildIcons {
public static void main(String[] args) throws Exception {
@@ -66,6 +65,9 @@ public class BuildIcons {
System.out.println("Total icons: " + total);
}
private static final Set<String> IMAGE_EXTENSIONS = ContainerUtil.newTroveSet(FileUtil.PATH_HASHING_STRATEGY,
"png", "gif", "jpg", "jpeg");
private static void walk(File root, MultiMap<Pair<Integer,Integer>, String> dimToPath, File file) throws IOException {
if (file.isDirectory()) {
for (File child : file.listFiles()) {
@@ -73,8 +75,7 @@ public class BuildIcons {
}
}
else {
String extension = FileUtil.getExtension(file.getName());
if ("png".equals(extension) || "gif".equals(extension) || "jpg".equals(extension) || "jpeg".equals(extension)) {
if (IMAGE_EXTENSIONS.contains(FileUtilRt.getExtension(file.getName()))) {
String relativePath = file.getAbsolutePath().substring(root.getAbsolutePath().length() + 1);
Image image = loadImage(file);
File target;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@ package com.intellij.psi;
/**
* JavaResolveResult holds additional information that is obtained
* when Java references are being resolved
* when Java references are being resolved.
*
* @author ik, dsl
* @see com.intellij.psi.PsiCall#resolveMethodGenerics()
@@ -26,8 +26,7 @@ public interface JavaResolveResult extends ResolveResult {
JavaResolveResult[] EMPTY_ARRAY = new JavaResolveResult[0];
/**
* Substitutor providing values of type parameters occuring
* in {@link #getElement()}.
* Substitutor providing values of type parameters occurring in {@link #getElement()}.
*/
PsiSubstitutor getSubstitutor();
@@ -35,34 +34,24 @@ public interface JavaResolveResult extends ResolveResult {
/**
* @return true if {@link #getElement()} is accessible from reference.
*
*/
boolean isAccessible();
boolean isStaticsScopeCorrect();
/**
* @return scope in the reference's file where the reference has been resolved
* null for qualified and local references
* @return scope in the reference's file where the reference has been resolved,
* {@code null} for qualified and local references.
*/
PsiElement getCurrentFileResolveScope();
JavaResolveResult EMPTY = new JavaResolveResult(){
@Override
public PsiElement getElement(){return null;}
@Override
public PsiSubstitutor getSubstitutor(){return PsiSubstitutor.EMPTY;}
@Override
public boolean isValidResult(){return false;}
@Override
public boolean isAccessible(){return false;}
@Override
public boolean isStaticsScopeCorrect(){return false;}
@Override
public PsiElement getCurrentFileResolveScope() { return null; }
@Override
public boolean isPackagePrefixPackageReference() { return false; }
JavaResolveResult EMPTY = new JavaResolveResult() {
@Override public PsiElement getElement() { return null; }
@Override public PsiSubstitutor getSubstitutor() { return PsiSubstitutor.EMPTY; }
@Override public boolean isValidResult() { return false; }
@Override public boolean isAccessible() { return false; }
@Override public boolean isStaticsScopeCorrect() { return false; }
@Override public PsiElement getCurrentFileResolveScope() { return null; }
@Override public boolean isPackagePrefixPackageReference() { return false; }
};
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,17 +59,17 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
public static final int CLASS_FQ_OR_PACKAGE_NAME_KIND = 5;
public static final int CLASS_IN_QUALIFIED_NEW_KIND = 6;
private final int myHC = CompositePsiElement.ourHC++;
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") private final int myHC = ourHC++;
public PsiJavaCodeReferenceElementImpl() {
super(JavaElementType.JAVA_CODE_REFERENCE);
}
@Override
public final int hashCode() {
return myHC;
}
public PsiJavaCodeReferenceElementImpl() {
super(JavaElementType.JAVA_CODE_REFERENCE);
}
@Override
public int getTextOffset() {
final ASTNode refName = getReferenceNameNode();
@@ -128,36 +128,22 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
return PACKAGE_NAME_KIND;
}
if (i == JavaElementType.IMPORT_STATEMENT) {
final boolean isOnDemand = ((PsiImportStatement)SourceTreeToPsiMap.treeElementToPsi(treeParent)).isOnDemand();
boolean isOnDemand = SourceTreeToPsiMap.<PsiImportStatement>treeToPsiNotNull(treeParent).isOnDemand();
return isOnDemand ? CLASS_FQ_OR_PACKAGE_NAME_KIND : CLASS_FQ_NAME_KIND;
}
if (i == JavaElementType.IMPORT_STATIC_STATEMENT) {
return CLASS_FQ_OR_PACKAGE_NAME_KIND;
}
if (i == JavaElementType.JAVA_CODE_REFERENCE) {
final int parentKind = ((PsiJavaCodeReferenceElementImpl)treeParent).getKind();
switch (parentKind) {
case CLASS_NAME_KIND:
return CLASS_OR_PACKAGE_NAME_KIND;
case PACKAGE_NAME_KIND:
return PACKAGE_NAME_KIND;
case CLASS_OR_PACKAGE_NAME_KIND:
return CLASS_OR_PACKAGE_NAME_KIND;
case CLASS_FQ_NAME_KIND:
return CLASS_FQ_OR_PACKAGE_NAME_KIND;
case CLASS_FQ_OR_PACKAGE_NAME_KIND:
return CLASS_FQ_OR_PACKAGE_NAME_KIND;
case CLASS_IN_QUALIFIED_NEW_KIND:
return CLASS_IN_QUALIFIED_NEW_KIND; //??
default:
LOG.assertTrue(false);
return -1;
int parentKind = ((PsiJavaCodeReferenceElementImpl)treeParent).getKind();
if (parentKind == CLASS_NAME_KIND) {
return CLASS_OR_PACKAGE_NAME_KIND;
}
else if (parentKind == CLASS_FQ_NAME_KIND) {
return CLASS_FQ_OR_PACKAGE_NAME_KIND;
}
else {
return parentKind;
}
}
if (i == JavaElementType.CLASS || i == JavaElementType.PARAMETER_LIST || i == TokenType.ERROR_ELEMENT) {
@@ -202,9 +188,8 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
@Override
public void deleteChildInternal(@NotNull final ASTNode child) {
if (getChildRole(child) == ChildRole.QUALIFIER) {
final ASTNode dot = findChildByRole(ChildRole.DOT);
/*super.deleteChildInternal(child);
deleteChildInternal(dot);*/
ASTNode dot = findChildByRole(ChildRole.DOT);
assert dot != null : this;
deleteChildRange(child.getPsi(), dot.getPsi());
}
else {
@@ -369,7 +354,8 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
final CandidateInfo resolveResult = (CandidateInfo)result[i];
final PsiClass aClass = (PsiClass)resolveResult.getElement();
assert aClass != null;
newResult[i] = !aClass.hasTypeParameters() ? resolveResult : new CandidateInfo(resolveResult, resolveResult.getSubstitutor().putAll(aClass, parameters));
newResult[i] = !aClass.hasTypeParameters() ?
resolveResult : new CandidateInfo(resolveResult, resolveResult.getSubstitutor().putAll(aClass, parameters));
}
return newResult;
}
@@ -409,7 +395,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
private JavaResolveResult[] resolve(final int kind) {
switch (kind) {
case CLASS_FQ_NAME_KIND:
case CLASS_FQ_NAME_KIND: {
// TODO: support type parameters in FQ names
final String textSkipWhiteSpaceAndComments = getTextSkipWhiteSpaceAndComments();
if (textSkipWhiteSpaceAndComments == null || textSkipWhiteSpaceAndComments.length() == 0) return JavaResolveResult.EMPTY_ARRAY;
@@ -417,7 +403,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
JavaPsiFacade.getInstance(getProject()).findClass(textSkipWhiteSpaceAndComments, getResolveScope());
if (aClass == null) return JavaResolveResult.EMPTY_ARRAY;
return new JavaResolveResult[]{new CandidateInfo(aClass, updateSubstitutor(PsiSubstitutor.EMPTY, aClass), this, false)};
}
case CLASS_IN_QUALIFIED_NEW_KIND: {
PsiElement parent = getParent();
if (parent instanceof JavaDummyHolder) {
@@ -444,13 +430,14 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
if (qualifierType == null) return JavaResolveResult.EMPTY_ARRAY;
if (!(qualifierType instanceof PsiClassType)) return JavaResolveResult.EMPTY_ARRAY;
final JavaResolveResult result = PsiUtil.resolveGenericsClassInType(qualifierType);
if (result.getElement() == null) return JavaResolveResult.EMPTY_ARRAY;
final PsiElement resultElement = result.getElement();
if (resultElement == null) return JavaResolveResult.EMPTY_ARRAY;
final PsiElement classNameElement = getReferenceNameElement();
if (!(classNameElement instanceof PsiIdentifier)) return JavaResolveResult.EMPTY_ARRAY;
final String className = classNameElement.getText();
final ClassResolverProcessor processor = new ClassResolverProcessor(className, this);
result.getElement().processDeclarations(processor, ResolveState.initial().put(PsiSubstitutor.KEY, result.getSubstitutor()), this, this);
resultElement.processDeclarations(processor, ResolveState.initial().put(PsiSubstitutor.KEY, result.getSubstitutor()), this, this);
return processor.getResult();
}
case CLASS_NAME_KIND: {
@@ -463,8 +450,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
return processor.getResult();
}
case PACKAGE_NAME_KIND:
case PACKAGE_NAME_KIND: {
final String packageName = getTextSkipWhiteSpaceAndComments();
final PsiManager manager = getManager();
final PsiPackage aPackage = JavaPsiFacade.getInstance(manager.getProject()).findPackage(packageName);
@@ -474,7 +460,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
: JavaResolveResult.EMPTY_ARRAY;
}
return new JavaResolveResult[]{new CandidateInfo(aPackage, PsiSubstitutor.EMPTY)};
}
case CLASS_FQ_OR_PACKAGE_NAME_KIND: {
final JavaResolveResult[] result = resolve(CLASS_FQ_NAME_KIND);
if (result.length == 0) {
@@ -482,7 +468,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
}
return result;
}
case CLASS_OR_PACKAGE_NAME_KIND:
case CLASS_OR_PACKAGE_NAME_KIND: {
final JavaResolveResult[] classResolveResult = resolve(CLASS_NAME_KIND);
// [dsl]todo[ik]: review this change I guess ResolveInfo should be merged if both
// class and package resolve failed.
@@ -491,6 +477,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
if (packageResolveResult.length > 0) return packageResolveResult;
}
return classResolveResult;
}
default:
LOG.assertTrue(false);
}
@@ -508,7 +495,6 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
return this;
}
@Override
public PsiElement bindToElement(@NotNull final PsiElement element) throws IncorrectOperationException {
CheckUtil.checkWritable(this);
@@ -615,10 +601,10 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
if (qualifier == null) return false;
LOG.assertTrue(qualifier.getElementType() == JavaElementType.JAVA_CODE_REFERENCE);
final PsiElement refElement = ((PsiJavaCodeReferenceElement)SourceTreeToPsiMap.treeElementToPsi(qualifier)).resolve();
final PsiElement refElement = SourceTreeToPsiMap.<PsiJavaCodeReferenceElement>treeToPsiNotNull(qualifier).resolve();
if (refElement instanceof PsiPackage) return true;
return ((PsiJavaCodeReferenceElementImpl)SourceTreeToPsiMap.treeElementToPsi(qualifier)).isFullyQualified();
return SourceTreeToPsiMap.<PsiJavaCodeReferenceElementImpl>treeToPsiNotNull(qualifier).isFullyQualified();
}
private PsiElement bindToPackage(final PsiPackage aPackage) throws IncorrectOperationException {
@@ -784,47 +770,42 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
filter.addFilter(ElementClassFilter.VARIABLE);
}
switch (getKind()) {
case CLASS_OR_PACKAGE_NAME_KIND:
addClassFilter(filter);
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
break;
case CLASS_NAME_KIND:
addClassFilter(filter);
if (isQualified()) {
case CLASS_OR_PACKAGE_NAME_KIND:
addClassFilter(filter);
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
}
break;
case PACKAGE_NAME_KIND:
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
break;
case CLASS_FQ_NAME_KIND:
case CLASS_FQ_OR_PACKAGE_NAME_KIND:
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
if (isQualified()) {
filter.addFilter(ElementClassFilter.CLASS);
}
break;
case CLASS_IN_QUALIFIED_NEW_KIND:
final PsiElement parent = getParent();
if (parent instanceof PsiNewExpression) {
final PsiNewExpression newExpr = (PsiNewExpression)parent;
final PsiType type = newExpr.getQualifier().getType();
final PsiClass aClass = PsiUtil.resolveClassInType(type);
if (aClass != null) {
aClass.processDeclarations(new FilterScopeProcessor(new AndFilter(ElementClassFilter.CLASS, new ModifierFilter(PsiModifier.STATIC, false)),
processor), ResolveState.initial(), null, this);
}
// else{
// throw new RuntimeException("Qualified new is not allowed for primitives");
// }
}
// else{
// throw new RuntimeException("Reference type is qualified new, but parent expression is: " + getParent());
// }
return;
default:
throw new RuntimeException("Unknown reference type");
break;
case CLASS_NAME_KIND:
addClassFilter(filter);
if (isQualified()) {
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
}
break;
case PACKAGE_NAME_KIND:
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
break;
case CLASS_FQ_NAME_KIND:
case CLASS_FQ_OR_PACKAGE_NAME_KIND:
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
if (isQualified()) {
filter.addFilter(ElementClassFilter.CLASS);
}
break;
case CLASS_IN_QUALIFIED_NEW_KIND:
final PsiElement parent = getParent();
if (parent instanceof PsiNewExpression) {
PsiExpression qualifier = ((PsiNewExpression)parent).getQualifier();
assert qualifier != null : parent;
PsiType type = qualifier.getType();
PsiClass aClass = PsiUtil.resolveClassInType(type);
if (aClass != null) {
aClass.processDeclarations(
new FilterScopeProcessor(new AndFilter(ElementClassFilter.CLASS, new ModifierFilter(PsiModifier.STATIC, false)),
processor), ResolveState.initial(), null, this);
}
}
return;
default:
throw new RuntimeException("Unknown reference type");
}
final FilterScopeProcessor proc = new FilterScopeProcessor(filter, processor);
PsiScopesUtil.resolveAndWalk(proc, this, null, true);
Binary file not shown.

After

Width:  |  Height:  |  Size: 57 B

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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,7 +27,6 @@ import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
@@ -232,15 +231,16 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
public void testMultiJDKConflict() throws Exception {
String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true);
VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
assert root != null : path;
loadAllModulesUnder(root);
ModuleManager moduleManager = ModuleManager.getInstance(getProject());
final Module java4 = moduleManager.findModuleByName("java4");
Module java4 = moduleManager.findModuleByName("java4");
Module java5 = moduleManager.findModuleByName("java5");
ModuleRootModificationUtil.setModuleSdk(java4, IdeaTestUtil.getMockJdk17("java 1.4"));
ModuleRootModificationUtil.setModuleSdk(java5, IdeaTestUtil.getMockJdk17("java 1.5"));
ModuleRootModificationUtil.addDependency(java5, java4);
assert root != null;
configureByExistingFile(root.findFileByRelativePath("moduleJava5/com/Java5.java"));
Collection<HighlightInfo> infos = highlightErrors();
assertEmpty(infos);
@@ -249,9 +249,9 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
public void testSameFQNClasses() throws Exception {
String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true);
VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
assert root != null : path;
loadAllModulesUnder(root);
assert root != null;
configureByExistingFile(root.findFileByRelativePath("client/src/BugTest.java"));
Collection<HighlightInfo> infos = highlightErrors();
assertEmpty(infos);
@@ -260,9 +260,9 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
public void testSameClassesInSourceAndLib() throws Exception {
String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true);
VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
assert root != null : path;
loadAllModulesUnder(root);
assert root != null;
configureByExistingFile(root.findFileByRelativePath("src/ppp/SomeClass.java"));
PsiField field = ((PsiJavaFile)myFile).getClasses()[0].findFieldByName("f", false);
assert field != null;
@@ -270,8 +270,8 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
assert aClass != null;
assertEquals("ppp.BadClass", aClass.getQualifiedName());
//lies in source
final VirtualFile vFile1 = myFile.getVirtualFile();
final VirtualFile vFile2 = aClass.getContainingFile().getVirtualFile();
VirtualFile vFile1 = myFile.getVirtualFile();
VirtualFile vFile2 = aClass.getContainingFile().getVirtualFile();
assert vFile1 != null;
assert vFile2 != null;
assertEquals(vFile1.getParent(), vFile2.getParent());
@@ -0,0 +1,100 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.documentation;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.javadoc.JavaDocExternalFilter;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.testFramework.LightCodeInsightTestCase;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
/**
* @author Denis Zhdanov
* @since 1/15/13 7:26 PM
*/
public class RefConvertorsTest extends LightCodeInsightTestCase {
private File myExtractedImagesDir;
@Override
protected void setUp() throws Exception {
super.setUp();
String tempDirectory = FileUtilRt.getTempDirectory();
myExtractedImagesDir = new File(tempDirectory, AbstractExternalFilter.QUICK_DOC_DIR_NAME);
}
@Override
protected void tearDown() throws Exception {
FileUtilRt.delete(myExtractedImagesDir);
super.tearDown();
}
public void testImgInsideJar() throws Exception {
String imgJarName = "test-img";
File imgJar = new File(myExtractedImagesDir, imgJarName + ".jar");
boolean exist = FileUtil.createIfDoesntExist(imgJar);
assertTrue(exist);
JarOutputStream out = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(imgJar)));
try {
out.putNextEntry(new JarEntry("resources/inherit.gif"));
FileInputStream fIn = new FileInputStream(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/documentation/inherit.gif");
try {
FileUtil.copy(fIn, out);
}
finally {
fIn.close();
}
}
finally {
out.close();
}
String textBefore =
"<HTML>" +
"java.lang.Object\n" +
" <IMG SRC=\"../../../resources/inherit.gif\" ALT=\"extended by \"><B>org.bouncycastle.asn1.BERSequenceParser</B>\n" +
"</HTML>";
File f = new File(myExtractedImagesDir, imgJarName);
f = new File(f, "resources");
File extractedImgFile = new File(f, "inherit.gif");
String expectedTextAfter = String.format(
"<HTML>" +
"java.lang.Object\n" +
" <IMG SRC=\"%s%s\" ALT=\"extended by \"><B>org.bouncycastle.asn1.BERSequenceParser</B>\n" +
"</HTML>",
LocalFileSystem.PROTOCOL_PREFIX,
extractedImgFile.getAbsolutePath());
JavaDocExternalFilter filter = new JavaDocExternalFilter(getProject());
String textAfter = filter.correctRefs(
String.format("%s%s!/org/bouncycastle/asn1/BERSequenceParser.html", JarFileSystem.PROTOCOL_PREFIX, imgJar.getAbsolutePath()),
textBefore
);
assertEquals(expectedTextAfter, textAfter);
assertTrue(extractedImgFile.isFile());
}
}
@@ -44,15 +44,15 @@ import org.jetbrains.jps.incremental.storage.ProjectTimestamps;
import org.jetbrains.jps.indices.ModuleExcludeIndex;
import org.jetbrains.jps.indices.impl.IgnoredFileIndexImpl;
import org.jetbrains.jps.indices.impl.ModuleExcludeIndexImpl;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.*;
import org.jetbrains.jps.model.java.*;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.library.JpsTypedLibrary;
import org.jetbrains.jps.model.library.sdk.JpsSdk;
import org.jetbrains.jps.model.library.sdk.JpsSdkReference;
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsSdkReferencesTable;
import org.jetbrains.jps.model.serialization.JpsProjectLoader;
import org.jetbrains.jps.model.serialization.PathMacroUtil;
import org.jetbrains.jps.util.JpsPathUtil;
@@ -73,7 +73,7 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
protected JpsProject myProject;
protected JpsModel myModel;
private JpsSdk<JpsDummyElement> myJdk;
private File myDataStorageRoot;
protected File myDataStorageRoot;
private TestProjectBuilderLogger myLogger;
@Override
@@ -215,15 +215,23 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
return null;
}
protected JpsModule addModule(String moduleName,
String[] srcPaths,
@Nullable String outputPath,
@Nullable String testOutputPath,
JpsSdk<JpsDummyElement> jdk) {
protected <T extends JpsElement> JpsModule addModule(String moduleName,
String[] srcPaths,
@Nullable String outputPath,
@Nullable String testOutputPath,
JpsSdk<T> sdk) {
JpsModule module = myProject.addModule(moduleName, JpsJavaModuleType.INSTANCE);
module.getSdkReferencesTable().setSdkReference(JpsJavaSdkType.INSTANCE, jdk.createReference());
module.getDependenciesList().addSdkDependency(JpsJavaSdkType.INSTANCE);
if (srcPaths.length > 0) {
final JpsSdkType<T> sdkType = sdk.getSdkType();
final JpsSdkReferencesTable sdkTable = module.getSdkReferencesTable();
sdkTable.setSdkReference(sdkType, sdk.createReference());
if (sdkType instanceof JpsJavaSdkTypeWrapper) {
final JpsSdkReference<T> wrapperRef = sdk.createReference();
sdkTable.setSdkReference(JpsJavaSdkType.INSTANCE, JpsJavaExtensionService.
getInstance().createWrappedJavaSdkReference((JpsJavaSdkTypeWrapper)sdkType, wrapperRef));
}
module.getDependenciesList().addSdkDependency(sdkType);
if (srcPaths.length > 0 || outputPath != null) {
for (String srcPath : srcPaths) {
module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(srcPath));
module.addSourceRoot(JpsPathUtil.pathToUrl(srcPath), JavaSourceRootType.SOURCE);
@@ -301,7 +309,7 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
}
protected String copyToProject(String relativeSourcePath, String relativeTargetPath) {
File source = PathManagerEx.findFileUnderProjectHome(relativeSourcePath, getClass());
File source = findFindUnderProjectHome(relativeSourcePath);
String fullTargetPath = getAbsolutePath(relativeTargetPath);
File target = new File(fullTargetPath);
try {
@@ -318,6 +326,10 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
return fullTargetPath;
}
protected File findFindUnderProjectHome(String relativeSourcePath) {
return PathManagerEx.findFileUnderProjectHome(relativeSourcePath, getClass());
}
public File getOrCreateProjectDir() {
if (myProjectDir == null) {
try {
@@ -21,10 +21,9 @@ import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher;
import com.intellij.openapi.fileTypes.FileNameMatcher;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.text.CaseInsensitiveStringHashingStrategy;
import gnu.trove.THashMap;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -44,17 +43,7 @@ public class FileTypeAssocTable<T> {
private FileTypeAssocTable(Map<String, T> extensionMappings, Map<String, T> exactFileNameMappings, Map<String, T> exactFileNameAnyCaseMappings, List<Pair<FileNameMatcher, T>> matchingMappings) {
myExtensionMappings = new THashMap<String, T>(extensionMappings);
myExactFileNameMappings = new THashMap<String, T>(exactFileNameMappings);
myExactFileNameAnyCaseMappings = new THashMap<String, T>(exactFileNameAnyCaseMappings, new TObjectHashingStrategy<String>() {
@Override
public int computeHashCode(String object) {
return StringUtil.stringHashCodeInsensitive(object);
}
@Override
public boolean equals(String o1, String o2) {
return o1.equalsIgnoreCase(o2);
}
}) {
myExactFileNameAnyCaseMappings = new THashMap<String, T>(exactFileNameAnyCaseMappings, CaseInsensitiveStringHashingStrategy.INSTANCE) {
@Override
public T remove(Object key) {
T removed = super.remove(key);
@@ -188,7 +177,7 @@ public class FileTypeAssocTable<T> {
if (mapping.getFirst().accept(fileName)) return mapping.getSecond();
}
return myExtensionMappings.get(FileUtilRt.getExtension(fileName));
return myExtensionMappings.get(FileUtilRt.getExtension(fileName).toLowerCase());
}
@Nullable
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jetbrains.jps.model.JpsElement;
@@ -78,6 +79,6 @@ public abstract class JpsLoaderBase {
}
protected static boolean isXmlFile(File file) {
return file.isFile() && FileUtil.getExtension(file.getName()).equalsIgnoreCase("xml");
return file.isFile() && FileUtilRt.extensionEquals(file.getName(), "xml");
}
}
Binary file not shown.
+1 -1
View File
@@ -30,7 +30,7 @@ microba.jar
miglayout-swing.jar
nanoxml-2.2.3.jar
nekohtml-1.9.14.jar
ecj-4.2.jar
ecj-4.2.1.jar
oromatcher.jar
picocontainer.jar
resolver.jar
View File
Binary file not shown.
@@ -19,12 +19,13 @@ import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.fileTypes.UnknownFileType;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VirtualFile;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,7 +33,7 @@ import java.util.Map;
* @author yole
*/
public class CoreFileTypeRegistry extends FileTypeRegistry {
private final Map<String, FileType> myExtensionsMap = new HashMap<String, FileType>();
private final Map<String, FileType> myExtensionsMap = new THashMap<String, FileType>(FileUtil.PATH_HASHING_STRATEGY);
private final List<FileType> myAllFileTypes = new ArrayList<FileType>();
public CoreFileTypeRegistry() {
@@ -58,7 +59,7 @@ public class CoreFileTypeRegistry extends FileTypeRegistry {
@NotNull
@Override
public FileType getFileTypeByFileName(@NotNull @NonNls String fileName) {
final String extension = FileUtil.getExtension(fileName);
final String extension = FileUtilRt.getExtension(fileName);
final FileType result = myExtensionsMap.get(extension);
return result == null ? UnknownFileType.INSTANCE : result;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 B

After

Width:  |  Height:  |  Size: 385 B

@@ -33,7 +33,7 @@ import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
@@ -171,7 +171,7 @@ public class FilePathCompletionContributor extends CompletionContributor {
if (prefixMatched && (suitableFileTypes.length == 0 || invocationCount > 2)) return true;
if (prefixMatched) {
final String extension = FileUtil.getExtension(fileName);
final String extension = FileUtilRt.getExtension(fileName);
if (extension.length() == 0) return false;
for (final FileType fileType : suitableFileTypes) {
@@ -24,12 +24,12 @@ import com.intellij.openapi.progress.util.ProgressIndicatorBase;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Trinity;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.*;
import com.intellij.psi.PsiElement;
import com.intellij.util.SystemProperties;
import com.intellij.util.io.UrlConnectionUtil;
import com.intellij.util.net.HttpConfigurable;
import org.jetbrains.annotations.NonNls;
@@ -52,35 +52,45 @@ import java.util.regex.Pattern;
*/
public abstract class AbstractExternalFilter {
private static final boolean EXTRACT_IMAGES_FROM_JARS = SystemProperties.getBooleanProperty("extract.doc.images", true);
@NotNull public static final String QUICK_DOC_DIR_NAME = "quickdoc";
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.javadoc.JavaDocExternalFilter");
private static final Pattern ourClassDataStartPattern = Pattern.compile("START OF CLASS DATA", Pattern.CASE_INSENSITIVE);
private static final Pattern ourClassDataEndPattern = Pattern.compile("SUMMARY ========", Pattern.CASE_INSENSITIVE);
private static final Pattern ourClassDataStartPattern = Pattern.compile("START OF CLASS DATA", Pattern.CASE_INSENSITIVE);
private static final Pattern ourClassDataEndPattern = Pattern.compile("SUMMARY ========", Pattern.CASE_INSENSITIVE);
private static final Pattern ourNonClassDataEndPattern = Pattern.compile("<A NAME=", Pattern.CASE_INSENSITIVE);
protected static @NonNls final Pattern ourAnchorsuffix = Pattern.compile("#(.*)$");
protected static @NonNls final Pattern ourHTMLFilesuffix = Pattern.compile("/([^/]*[.][hH][tT][mM][lL]?)$");
private static @NonNls final Pattern ourAnnihilator = Pattern.compile("/[^/^.]*/[.][.]/");
private static @NonNls final Pattern ourIMGselector = Pattern.compile("<IMG[ \\t\\n\\r\\f]+SRC=\"([^>]*)\"", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
private static @NonNls final String JAR_PROTOCOL = "jar:";
@NonNls private static final String HR = "<HR>";
@NonNls private static final String P = "<P>";
@NonNls private static final String DL = "<DL>";
@NonNls protected static final String H2 = "</H2>";
@NonNls protected static final String HTML_CLOSE = "</HTML>";
@NonNls protected static final String HTML = "<HTML>";
@NonNls private static final String BR = "<BR>";
@NonNls private static final String DT = "<DT>";
private static final Pattern CHARSET_META_PATTERN =
protected static @NonNls final Pattern ourAnchorsuffix = Pattern.compile("#(.*)$");
protected static @NonNls final Pattern ourHTMLFilesuffix = Pattern.compile("/([^/]*[.][hH][tT][mM][lL]?)$");
private static @NonNls final Pattern ourAnnihilator = Pattern.compile("/[^/^.]*/[.][.]/");
private static @NonNls final Pattern ourIMGselector =
Pattern.compile("<IMG[ \\t\\n\\r\\f]+SRC=\"([^>]*?)\"", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
private static @NonNls final Pattern ourPathInsideJarPattern = Pattern.compile(
String.format("%s(.+\\.jar)!/(.+?)[^/]+", JarFileSystem.PROTOCOL_PREFIX),
Pattern.CASE_INSENSITIVE | Pattern.DOTALL
);
private static @NonNls final String JAR_PROTOCOL = "jar:";
@NonNls private static final String HR = "<HR>";
@NonNls private static final String P = "<P>";
@NonNls private static final String DL = "<DL>";
@NonNls protected static final String H2 = "</H2>";
@NonNls protected static final String HTML_CLOSE = "</HTML>";
@NonNls protected static final String HTML = "<HTML>";
@NonNls private static final String BR = "<BR>";
@NonNls private static final String DT = "<DT>";
private static final Pattern CHARSET_META_PATTERN =
Pattern.compile("<meta[^>]+\\s*charset=\"?([\\w\\-]*)\\s*\">", Pattern.CASE_INSENSITIVE);
private static final String FIELD_SUMMARY = "<!-- =========== FIELD SUMMARY =========== -->";
private static final String CLASS_SUMMARY = "<div class=\"summary\">";
private final HttpConfigurable myHttpConfigurable = HttpConfigurable.getInstance();
private static final String FIELD_SUMMARY = "<!-- =========== FIELD SUMMARY =========== -->";
private static final String CLASS_SUMMARY = "<div class=\"summary\">";
private final HttpConfigurable myHttpConfigurable = HttpConfigurable.getInstance();
protected static abstract class RefConvertor {
private final Pattern mySelector;
@NotNull private final Pattern mySelector;
public RefConvertor(Pattern selector) {
public RefConvertor(@NotNull Pattern selector) {
mySelector = selector;
}
@@ -99,12 +109,12 @@ public abstract class AbstractExternalFilter {
ready.append(before);
ready.append("\"");
ready.append(ApplicationManager.getApplication().runReadAction(
new Computable<String>() {
@Override
public String compute() {
return convertReference(root, href);
}
new Computable<String>() {
@Override
public String compute() {
return convertReference(root, href);
}
}
));
ready.append("\"");
}
@@ -119,10 +129,63 @@ public abstract class AbstractExternalFilter {
@Override
protected String convertReference(String root, String href) {
if (StringUtil.startsWithChar(href, '#')) {
return DocumentationManager.DOC_ELEMENT_PROTOCOL + root + href;
return DocumentationManagerProtocol.DOC_ELEMENT_PROTOCOL + root + href;
}
if (Comparing.strEqual(VirtualFileManager.extractProtocol(root), LocalFileSystem.PROTOCOL)) {
String protocol = VirtualFileManager.extractProtocol(root);
if (EXTRACT_IMAGES_FROM_JARS && Comparing.strEqual(protocol, JarFileSystem.PROTOCOL)) {
Matcher matcher = ourPathInsideJarPattern.matcher(root);
if (matcher.matches()) {
// There is a possible case that javadoc jar is assembled with images inside. However, our standard quick doc
// renderer (JEditorPane) doesn't know how to reference images from such jars. That's why we unpack them to temp
// directory if necessary and substitute that 'inside jar path' to usual file url.
String jarPath = matcher.group(1);
String jarName = jarPath;
int i = jarName.lastIndexOf(File.separatorChar);
if (i >= 0 && i < jarName.length() - 1) {
jarName = jarName.substring(i + 1);
}
jarName = jarName.substring(0, jarName.length() - ".jar".length());
String basePath = matcher.group(2);
String imgPath = FileUtil.toCanonicalPath(basePath + href);
File unpackedImagesRoot = new File(FileUtilRt.getTempDirectory(), QUICK_DOC_DIR_NAME);
File unpackedJarImagesRoot = new File(unpackedImagesRoot, jarName);
File unpackedImage = new File(unpackedJarImagesRoot, imgPath);
boolean referenceUnpackedImage = true;
if (!unpackedImage.isFile()) {
referenceUnpackedImage = false;
JarFileSystem jarFileSystem = JarFileSystem.getInstance();
try {
JarFile jarFile = jarFileSystem.getJarFile(jarFileSystem.findFileByPath(jarPath + StandardFileSystems.JAR_SEPARATOR));
if (jarFile != null) {
JarFile.JarEntry entry = jarFile.getEntry(imgPath);
if (entry != null) {
FileUtilRt.createIfNotExists(unpackedImage);
FileOutputStream fOut = new FileOutputStream(unpackedImage);
try {
// Don't bother with wrapping file output stream into buffered stream in assumption that FileUtil operates
// on NIO channels.
FileUtilRt.copy(jarFile.getInputStream(entry), fOut);
referenceUnpackedImage = true;
}
finally {
fOut.close();
}
}
unpackedImage.deleteOnExit();
}
}
catch (IOException e) {
// Do nothing
}
}
if (referenceUnpackedImage) {
return LocalFileSystem.PROTOCOL_PREFIX + unpackedImage.getAbsolutePath();
}
}
}
if (Comparing.strEqual(protocol, LocalFileSystem.PROTOCOL)) {
final String path = VirtualFileManager.extractPath(root);
if (!path.startsWith("/")) {//skip host for local file system files (format - file://host_name/path)
root = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, "/" + path);
@@ -143,7 +206,7 @@ public abstract class AbstractExternalFilter {
return path;
}
private String correctRefs(String root, String read) {
public String correctRefs(String root, String read) {
String result = read;
for (RefConvertor myReferenceConvertor : getRefConvertors()) {
@@ -156,7 +219,9 @@ public abstract class AbstractExternalFilter {
protected abstract RefConvertor[] getRefConvertors();
@Nullable
private static Reader getReaderByUrl(final String surl, final HttpConfigurable httpConfigurable, final ProgressIndicator pi) throws IOException {
private static Reader getReaderByUrl(final String surl, final HttpConfigurable httpConfigurable, final ProgressIndicator pi)
throws IOException
{
if (surl.startsWith(JAR_PROTOCOL)) {
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(BrowserUtil.getDocURL(surl));
@@ -188,7 +253,7 @@ public abstract class AbstractExternalFilter {
if (result != null) return result;
//noinspection IOResourceOpenedButNotSafelyClosed
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
for(String htmlLine = reader.readLine();htmlLine != null; htmlLine = reader.readLine()) {
for (String htmlLine = reader.readLine(); htmlLine != null; htmlLine = reader.readLine()) {
result = parseContentEncoding(htmlLine);
if (result != null) {
break;
@@ -196,12 +261,14 @@ public abstract class AbstractExternalFilter {
}
}
catch (IOException ignored) {
} finally {
}
finally {
if (reader != null)
try {
reader.close();
}
catch (IOException ignored) {}
catch (IOException ignored) {
}
}
return result;
}
@@ -209,7 +276,7 @@ public abstract class AbstractExternalFilter {
@Nullable
@SuppressWarnings({"HardCodedStringLiteral"})
public String getExternalDocInfo(final String surl) throws Exception {
if (surl == null) return null;
if (surl == null) return null;
if (MyJavadocFetcher.isFree()) {
final MyJavadocFetcher fetcher = new MyJavadocFetcher(surl, new MyDocBuilder() {
@Override
@@ -240,8 +307,8 @@ public abstract class AbstractExternalFilter {
}
@Nullable
public String getExternalDocInfoForElement(final String docURL, final PsiElement element) throws Exception {
return getExternalDocInfo(docURL);
public String getExternalDocInfoForElement(final String docURL, final PsiElement element) throws Exception {
return getExternalDocInfo(docURL);
}
protected void doBuildFromStream(String surl, Reader input, StringBuffer data) throws IOException {
@@ -257,21 +324,21 @@ public abstract class AbstractExternalFilter {
@NonNls String greatestEndSection = "<!-- ========= END OF CLASS DATA ========= -->";
data.append(HTML);
data.append( "<style type=\"text/css\">" +
" ul.inheritance {\n" +
" margin:0;\n" +
" padding:0;\n" +
" }\n" +
" ul.inheritance li {\n" +
" display:inline;\n" +
" list-style:none;\n" +
" }\n" +
" ul.inheritance li ul.inheritance {\n" +
" margin-left:15px;\n" +
" padding-left:15px;\n" +
" padding-top:1px;\n" +
" }\n" +
"</style>");
data.append("<style type=\"text/css\">" +
" ul.inheritance {\n" +
" margin:0;\n" +
" padding:0;\n" +
" }\n" +
" ul.inheritance li {\n" +
" display:inline;\n" +
" list-style:none;\n" +
" }\n" +
" ul.inheritance li ul.inheritance {\n" +
" margin-left:15px;\n" +
" padding-left:15px;\n" +
" padding-top:1px;\n" +
" }\n" +
"</style>");
String read;
String contentEncoding = null;
@@ -288,7 +355,8 @@ public abstract class AbstractExternalFilter {
if (input instanceof MyReader && contentEncoding != null) {
if (!contentEncoding.equalsIgnoreCase("UTF-8") &&
!contentEncoding.equals(((MyReader)input).getEncoding())) { //restart page parsing with correct encoding
!contentEncoding.equals(((MyReader)input).getEncoding()))
{ //restart page parsing with correct encoding
Reader stream;
try {
stream = getReaderByUrl(surl, myHttpConfigurable, new ProgressIndicatorBase());
@@ -49,7 +49,7 @@ public class EnterInLineCommentHandler extends EnterHandlerDelegateAdapter {
String prefix = commenter.getLineCommentPrefix();
assert prefix != null: "Line Comment type is set but Line Comment Prefix is null!";
if (!StringUtil.startsWith(text, offset, prefix)) {
if (text.charAt(caretOffset) != ' ') {
if (text.charAt(caretOffset) != ' ' && !prefix.endsWith(" ")) {
prefix += " ";
}
document.insertString(caretOffset, prefix);
@@ -343,8 +343,7 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
String prefix = commenter.getLineCommentPrefix();
if (prefix != null) {
commented = CharArrayUtil.regionMatches(chars, lineStart, prefix) ||
prefix.endsWith(" ") && CharArrayUtil.regionMatches(chars, lineStart, prefix.trim() + "\n");
commented = CharArrayUtil.regionMatches(chars, lineStart, StringUtil.trimTrailing(prefix));
}
else {
prefix = commenter.getBlockCommentPrefix();
@@ -513,12 +512,12 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
}
}
boolean skipNewLine = false;
boolean matchesTrimmed = false;
boolean commented = CharArrayUtil.regionMatches(chars, startOffset, prefix) ||
(skipNewLine = prefix.endsWith(" ") && CharArrayUtil.regionMatches(chars, startOffset, prefix.trim() + "\n"));
(matchesTrimmed = prefix.endsWith(" ") && CharArrayUtil.regionMatches(chars, startOffset, prefix.trim()));
assert commented;
int charsToDelete = skipNewLine ? prefix.trim().length() : prefix.length();
int charsToDelete = matchesTrimmed ? prefix.trim().length() : prefix.length();
int theEnd = endOffset > 0 ? endOffset : chars.length();
// if there's exactly one space after line comment prefix and before the text that follows in the same line, delete the space too
if (startOffset + charsToDelete < theEnd - 1 && chars.charAt(startOffset + charsToDelete) == ' ') {
@@ -21,6 +21,7 @@ import com.intellij.framework.library.DownloadableLibraryDescription;
import com.intellij.framework.library.DownloadableLibraryFileDescription;
import com.intellij.framework.library.FrameworkLibraryVersion;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.download.impl.FileSetVersionsFetcherBase;
import org.jetbrains.annotations.NotNull;
@@ -51,6 +52,6 @@ public class LibraryVersionsFetcher extends FileSetVersionsFetcherBase<Framework
docUrl = prependPrefix(docUrl, prefix);
}
final String name = item.getName();
return new DownloadableLibraryFileDescriptionImpl(url, FileUtil.getNameWithoutExtension(name), FileUtil.getExtension(name), sourceUrl, docUrl, item.isOptional());
return new DownloadableLibraryFileDescriptionImpl(url, FileUtil.getNameWithoutExtension(name), FileUtilRt.getExtension(name), sourceUrl, docUrl, item.isOptional());
}
}
@@ -28,7 +28,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.InputValidatorEx;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
@@ -101,7 +101,7 @@ public class CreateFileAction extends CreateElementActionBase implements DumbAwa
}
protected String getFileName(String newName) {
if (getDefaultExtension() == null || FileUtil.getExtension(newName).length() > 0) {
if (getDefaultExtension() == null || FileUtilRt.getExtension(newName).length() > 0) {
return newName;
}
return newName + "." + getDefaultExtension();
@@ -64,7 +64,7 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
private boolean mySorted = false;
private boolean myShowClasses = true;
private boolean myAllowEmptySelection = false;
protected boolean myAllowEmptySelection = false;
private boolean myAllowMultiSelection;
private final Project myProject;
private final boolean myIsInsertOverrideVisible;
@@ -55,7 +55,7 @@ import com.intellij.openapi.util.DimensionService;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
@@ -643,7 +643,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
myExtensionComboBox.setModel(model);
myExtensionComboBox.setVisible(true);
myExtensionLabel.setVisible(true);
String fileExt = myCurrentFile != null ? FileUtil.getExtension(myCurrentFile.getName()) : "";
String fileExt = myCurrentFile != null ? FileUtilRt.getExtension(myCurrentFile.getName()) : "";
if (fileExt.length() > 0 && extensions.contains(fileExt)) {
myExtensionComboBox.setSelectedItem(fileExt);
return;
@@ -32,6 +32,7 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
@@ -75,7 +76,7 @@ public class ModuleAttachProcessor extends ProjectAttachProcessor {
final String[] files = projectDir.list();
if (files != null) {
for (String file : files) {
if (FileUtil.getExtension(file).equals("iml")) {
if (FileUtilRt.extensionEquals(file, "iml")) {
VirtualFile imlFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(projectDir, file));
if (imlFile != null) {
attachModule(project, imlFile, callback);
@@ -33,7 +33,7 @@ public class DownloadUtil {
* @param indicator progress indicator
* @param url url to download
* @param outputFile output file
* @param tempFile temporary file to download to
* @param tempFile temporary file to download to. This file will be removed on method exit.
*/
public static void downloadAtomically(@Nullable ProgressIndicator indicator,
@NotNull String url,
@@ -42,7 +42,7 @@ public class DownloadUtil {
{
try {
downloadContentToFile(indicator, url, tempFile);
FileUtil.copy(tempFile, outputFile);
FileUtil.rename(tempFile, outputFile);
} finally {
FileUtil.delete(tempFile);
}
@@ -29,7 +29,7 @@ import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter;
import com.intellij.psi.*;
@@ -560,7 +560,7 @@ public class PsiVFSListener extends VirtualFileAdapter {
// When file is renamed so that extension changes then language dialect might change and thus psiFile should be invalidated
private static boolean languageDialectChanged(final PsiFile newPsiFile, String oldFileName) {
return newPsiFile != null && !FileUtil.getExtension(newPsiFile.getName()).equals(FileUtil.getExtension(oldFileName));
return newPsiFile != null && !FileUtilRt.extensionEquals(oldFileName, FileUtilRt.getExtension(newPsiFile.getName()));
}
private class MyModuleRootListener implements ModuleRootListener {
@@ -34,12 +34,14 @@ import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Segment;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiLanguageInjectionHost;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.formatter.DocumentBasedFormattingModel;
@@ -56,12 +58,13 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.util.*;
import java.util.List;
public class CodeFormatterFacade {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.codeStyle.CodeFormatterFacade");
private static final String WRAP_LINE_COMMAND_NAME = "AutoWrapLongLine";
/**
@@ -69,7 +72,7 @@ public class CodeFormatterFacade {
*
* @see CodeStyleSettings#WRAP_LONG_LINES
*/
public static final Key<Boolean> WRAP_LONG_LINE_DURING_FORMATTING_IN_PROGRESS_KEY
public static final Key<Boolean> WRAP_LONG_LINE_DURING_FORMATTING_IN_PROGRESS_KEY
= new Key<Boolean>("WRAP_LONG_LINE_DURING_FORMATTING_IN_PROGRESS_KEY");
private final CodeStyleSettings mySettings;
@@ -229,44 +232,71 @@ public class CodeFormatterFacade {
}
return result;
}
PsiFile file = psi.getContainingFile();
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(file.getProject());
List<DocumentWindow> injectedDocuments = InjectedLanguageUtil.getCachedInjectedDocuments(file);
if (!injectedDocuments.isEmpty()) {
List<DocumentWindow> injectedDocumentsToUse = ContainerUtilRt.newArrayList(injectedDocuments);
for (DocumentWindow window : injectedDocumentsToUse) {
if (!window.isValid()) {
// There is a possible case that format pre-processor modifies target document in a way that some injections are dropped.
continue;
}
PsiFile injected = psiDocumentManager.getCachedPsiFile(window);
if (injected != null) {
int startHostOffset = window.injectedToHost(0);
int endHostOffset = window.injectedToHost(window.getTextLength());
int startInjectedOffset = range.getStartOffset() > startHostOffset ? startHostOffset - range.getStartOffset() : 0;
int endInjectedOffset = injected.getTextLength();
if (range.getEndOffset() < endHostOffset) {
endInjectedOffset -= endHostOffset - range.getEndOffset();
}
final TextRange initialInjectedRange = TextRange.create(startInjectedOffset, endInjectedOffset);
TextRange injectedRange = initialInjectedRange;
for (PreFormatProcessor processor : Extensions.getExtensions(PreFormatProcessor.EP_NAME)) {
injectedRange = processor.process(injected.getNode(), injectedRange);
}
// Allow only range expansion (not reduction) for injected context.
if ((initialInjectedRange.getStartOffset() > injectedRange.getStartOffset() && initialInjectedRange.getStartOffset() > 0)
|| (initialInjectedRange.getEndOffset() < injectedRange.getEndOffset()
&& initialInjectedRange.getEndOffset() < injected.getTextLength())) {
range = TextRange.create(
range.getStartOffset() + injectedRange.getStartOffset() - initialInjectedRange.getStartOffset(),
range.getEndOffset() + initialInjectedRange.getEndOffset() - injectedRange.getEndOffset());
PsiFile file = psi.getContainingFile();
// We use a set here because we encountered a situation when more than one PSI leaf points to the same injected fragment
// (at least for sql injected into sql).
final LinkedHashSet<TextRange> injectedFileRangesSet = ContainerUtilRt.newLinkedHashSet();
if (!psi.getProject().isDefault()) {
List<DocumentWindow> injectedDocuments = InjectedLanguageUtil.getCachedInjectedDocuments(file);
if (!injectedDocuments.isEmpty()) {
for (DocumentWindow injectedDocument : injectedDocuments) {
injectedFileRangesSet.add(TextRange.from(injectedDocument.injectedToHost(0), injectedDocument.getTextLength()));
}
}
else {
Collection<PsiLanguageInjectionHost> injectionHosts = collectInjectionHosts(file, range);
PsiLanguageInjectionHost.InjectedPsiVisitor visitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() {
@Override
public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {
for (PsiLanguageInjectionHost.Shred place : places) {
Segment rangeMarker = place.getHostRangeMarker();
injectedFileRangesSet.add(TextRange.create(rangeMarker.getStartOffset(), rangeMarker.getEndOffset()));
}
}
};
for (PsiLanguageInjectionHost host : injectionHosts) {
InjectedLanguageUtil.enumerate(host, visitor);
}
}
}
if (!injectedFileRangesSet.isEmpty()) {
List<TextRange> ranges = ContainerUtilRt.newArrayList(injectedFileRangesSet);
Collections.reverse(ranges);
for (TextRange injectedFileRange : ranges) {
int startHostOffset = injectedFileRange.getStartOffset();
int endHostOffset = injectedFileRange.getEndOffset();
if (startHostOffset >= range.getStartOffset() && endHostOffset <= range.getEndOffset()) {
PsiFile injected = InjectedLanguageUtil.findInjectedPsiNoCommit(file, startHostOffset);
if (injected != null) {
int startInjectedOffset = range.getStartOffset() > startHostOffset ? startHostOffset - range.getStartOffset() : 0;
int endInjectedOffset = injected.getTextLength();
if (range.getEndOffset() < endHostOffset) {
endInjectedOffset -= endHostOffset - range.getEndOffset();
}
final TextRange initialInjectedRange = TextRange.create(startInjectedOffset, endInjectedOffset);
TextRange injectedRange = initialInjectedRange;
for (PreFormatProcessor processor : Extensions.getExtensions(PreFormatProcessor.EP_NAME)) {
injectedRange = processor.process(injected.getNode(), injectedRange);
}
// Allow only range expansion (not reduction) for injected context.
if ((initialInjectedRange.getStartOffset() > injectedRange.getStartOffset() && initialInjectedRange.getStartOffset() > 0)
|| (initialInjectedRange.getEndOffset() < injectedRange.getEndOffset()
&& initialInjectedRange.getEndOffset() < injected.getTextLength()))
{
range = TextRange.create(
range.getStartOffset() + injectedRange.getStartOffset() - initialInjectedRange.getStartOffset(),
range.getEndOffset() + initialInjectedRange.getEndOffset() - injectedRange.getEndOffset());
}
}
}
}
}
for(PreFormatProcessor processor: Extensions.getExtensions(PreFormatProcessor.EP_NAME)) {
result = processor.process(node, result);
}
@@ -274,6 +304,40 @@ public class CodeFormatterFacade {
return result;
}
@NotNull
private static Collection<PsiLanguageInjectionHost> collectInjectionHosts(@NotNull PsiFile file, @NotNull TextRange range) {
Stack<PsiElement> toProcess = new Stack<PsiElement>();
for (PsiElement e = file.findElementAt(range.getStartOffset()); e != null; e = e.getNextSibling()) {
if (e.getTextRange().getStartOffset() >= range.getEndOffset()) {
break;
}
toProcess.push(e);
}
if (toProcess.isEmpty()) {
return Collections.emptySet();
}
Set<PsiLanguageInjectionHost> result = null;
while (!toProcess.isEmpty()) {
PsiElement e = toProcess.pop();
if (e instanceof PsiLanguageInjectionHost) {
if (result == null) {
result = ContainerUtilRt.newHashSet();
}
result.add((PsiLanguageInjectionHost)e);
}
else {
for (PsiElement child = e.getFirstChild(); child != null; child = child.getNextSibling()) {
if (e.getTextRange().getStartOffset() >= range.getEndOffset()) {
break;
}
toProcess.push(child);
}
}
}
return result == null ? Collections.<PsiLanguageInjectionHost>emptySet() : result;
}
/**
* Inspects all lines of the given document and wraps all of them that exceed {@link CodeStyleSettings#RIGHT_MARGIN right margin}.
* <p/>
@@ -335,7 +399,7 @@ public class CodeFormatterFacade {
doWrapLongLinesIfNecessary(editorToUse, file.getProject(), editorToUse.getDocument(), startOffset, endOffset);
if (caretMarker.isValid() && caretModel.getOffset() != caretMarker.getStartOffset()) {
caretModel.moveToOffset(caretMarker.getStartOffset());
}
}
}
});
}
@@ -349,7 +413,7 @@ public class CodeFormatterFacade {
}
public void doWrapLongLinesIfNecessary(@NotNull final Editor editor, @NotNull final Project project, @NotNull Document document,
int startOffset, int endOffset) {
int startOffset, int endOffset) {
// Normalization.
int startOffsetToUse = Math.min(document.getTextLength(), Math.max(0, startOffset));
int endOffsetToUse = Math.min(document.getTextLength(), Math.max(0, endOffset));
@@ -388,7 +452,7 @@ public class CodeFormatterFacade {
}
}
boolean wrapLine = false;
boolean wrapLine = false;
int preferredWrapPosition = Integer.MAX_VALUE;
if (!hasTabs) {
if (Math.min(endLineOffset, endOffsetToUse) - startLineOffset > mySettings.RIGHT_MARGIN) {
@@ -465,7 +529,7 @@ public class CodeFormatterFacade {
continue;
}
editor.getCaretModel().moveToOffset(wrapOffset);
// There is a possible case that formatting is performed from project view and editor is not opened yet. The problem is that
// its data context doesn't contain information about project then. So, we explicitly support that here (see IDEA-72791).
final DataContext baseDataContext = DataManager.getInstance().getDataContext(editor.getComponent());
@@ -475,11 +539,11 @@ public class CodeFormatterFacade {
Object result = baseDataContext.getData(dataId);
if (result == null && PlatformDataKeys.PROJECT.is(dataId)) {
result = project;
}
}
return result;
}
};
SelectionModel selectionModel = editor.getSelectionModel();
int startSelectionOffset = 0;
@@ -528,9 +592,9 @@ public class CodeFormatterFacade {
maxLine++;
}
}
private static class DelegatingDataContext implements DataContext, UserDataHolder {
private final DataContext myDataContextDelegate;
private final UserDataHolder myDataHolderDelegate;
@@ -206,30 +206,9 @@ public class ToolEditorDialog extends DialogWrapper {
pane.add(new JLabel(ToolsBundle.message("tools.program.label")), constr);
FixedSizeButton browseCommandButton = new FixedSizeButton(myTfCommand);
browseCommandButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor();
PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
chooser.choose(null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
VirtualFile file = files.size() > 0 ? files.get(0) : null;
if (file != null) {
myTfCommand.setText(file.getPresentableUrl());
String workingDirectory = myTfCommandWorkingDirectory.getText();
if (workingDirectory == null || workingDirectory.length() == 0) {
VirtualFile parent = file.getParent();
if (parent != null && parent.isDirectory()) {
myTfCommandWorkingDirectory.setText(parent.getPresentableUrl());
}
}
}
}
});
}
}
);
addCommandBrowseAction(pane, browseCommandButton, myTfCommand);
JPanel _pane0 = new JPanel(new BorderLayout());
_pane0.add(myTfCommand, BorderLayout.CENTER);
_pane0.add(browseCommandButton, BorderLayout.EAST);
@@ -291,24 +270,8 @@ public class ToolEditorDialog extends DialogWrapper {
FixedSizeButton browseDirectoryButton = new FixedSizeButton(myTfCommandWorkingDirectory);
TextFieldWithBrowseButton.MyDoClickAction.addTo(browseDirectoryButton, myTfCommandWorkingDirectory);
browseDirectoryButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
addWorkingDirectoryBrowseAction(pane, browseDirectoryButton, myTfCommandWorkingDirectory);
chooser.choose(null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
VirtualFile file = files.size() > 0 ? files.get(0) : null;
if (file != null) {
myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
}
}
});
}
}
);
JPanel _pane1 = new JPanel(new BorderLayout());
_pane1.add(myTfCommandWorkingDirectory, BorderLayout.CENTER);
_pane1.add(browseDirectoryButton, BorderLayout.EAST);
@@ -342,6 +305,56 @@ public class ToolEditorDialog extends DialogWrapper {
return pane;
}
protected void addWorkingDirectoryBrowseAction(final JPanel pane,
FixedSizeButton browseDirectoryButton,
JTextField tfCommandWorkingDirectory) {
browseDirectoryButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
chooser.choose(null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
VirtualFile file = files.size() > 0 ? files.get(0) : null;
if (file != null) {
myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
}
}
});
}
}
);
}
protected void addCommandBrowseAction(final JPanel pane, FixedSizeButton browseCommandButton, JTextField tfCommand) {
browseCommandButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor();
PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
chooser.choose(null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
VirtualFile file = files.size() > 0 ? files.get(0) : null;
if (file != null) {
myTfCommand.setText(file.getPresentableUrl());
String workingDirectory = myTfCommandWorkingDirectory.getText();
if (workingDirectory == null || workingDirectory.length() == 0) {
VirtualFile parent = file.getParent();
if (parent != null && parent.isDirectory()) {
myTfCommandWorkingDirectory.setText(parent.getPresentableUrl());
}
}
}
}
});
}
}
);
}
private class InsertMacroActionListener implements ActionListener {
private final JTextField myTextField;
@@ -507,4 +520,8 @@ public class ToolEditorDialog extends DialogWrapper {
if (s.length() == 0) return null;
return s.replace('/', File.separatorChar);
}
public Project getProject() {
return myProject;
}
}
@@ -19,6 +19,7 @@ import com.intellij.facet.frameworks.beans.Artifact;
import com.intellij.facet.frameworks.beans.ArtifactItem;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.download.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,7 +35,7 @@ public class DownloadableFileServiceImpl extends DownloadableFileService {
@NotNull
@Override
public DownloadableFileDescription createFileDescription(@NotNull String downloadUrl, @NotNull String fileName) {
return new DownloadableFileDescriptionImpl(downloadUrl, FileUtil.getNameWithoutExtension(fileName), FileUtil.getExtension(fileName));
return new DownloadableFileDescriptionImpl(downloadUrl, FileUtil.getNameWithoutExtension(fileName), FileUtilRt.getExtension(fileName));
}
@NotNull
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
* Defines whether the tree has focus or not
*/
private boolean myFocused;
private boolean myFocusedCalculated;
protected JTree myTree;
@@ -57,7 +58,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
clear();
mySelected = selected;
myFocused = hasFocus;
myFocusedCalculated = false;
// We paint background if and only if tree path is selected and tree has focus.
// If path is selected and tree is not focused then we just paint focused border.
@@ -73,7 +74,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
else {
if (selected) {
setPaintFocusBorder(true);
if (hasFocus) {
if (isFocused()) {
setBackground(UIUtil.getTreeSelectionBackground());
}
else {
@@ -107,7 +108,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
super.setIconOpaque(false);
}
else {
super.setOpaque(myOpaque || selected && hasFocus); // draw selection background even for non-opaque tree
super.setOpaque(myOpaque || selected && hasFocus || selected && isFocused()); // draw selection background even for non-opaque tree
}
if (tree.getUI() instanceof WideSelectionTreeUI && UIUtil.isUnderAquaBasedLookAndFeel()) {
@@ -128,6 +129,18 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
return myTree;
}
protected final boolean isFocused() {
if (!myFocusedCalculated) {
myFocused = calcFocusedState();
myFocusedCalculated = true;
}
return myFocused;
}
protected boolean calcFocusedState() {
return myTree.hasFocus();
}
public void setOpaque(boolean isOpaque) {
myOpaque = isOpaque;
super.setOpaque(isOpaque);
@@ -138,7 +151,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
* It guaranties readability of selected text in any LAF.
*/
public void append(@NotNull @Nls String fragment, @NotNull SimpleTextAttributes attributes, boolean isMainText) {
if (mySelected && myFocused) {
if (mySelected && isFocused()) {
super.append(fragment, new SimpleTextAttributes(attributes.getStyle(), UIUtil.getTreeSelectionForeground()), isMainText);
}
else if (mySelected && UIUtil.isUnderAquaBasedLookAndFeel()) {
@@ -155,7 +155,7 @@ public class CommonProxy extends ProxySelector {
isInstalledAssertion();
myIDEAWide.resetAuthenticator();
final String host = uri.getHost();
final String host = uri.getHost() == null ? "" : uri.getHost();
final int port = uri.getPort();
final String protocol = uri.getScheme();
@@ -349,13 +349,14 @@ public class CommonProxy extends ProxySelector {
public static class HostInfo {
public String myProtocol;
@NotNull
public String myHost;
public int myPort;
public HostInfo() {
}
public HostInfo(String protocol, String host, int port) {
public HostInfo(String protocol, @NotNull String host, int port) {
myPort = port;
myHost = host;
myProtocol = protocol;
@@ -35,6 +35,7 @@ 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.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.util.containers.OrderedSet;
@@ -198,7 +199,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
}
private static boolean isIprPath(final File file) {
return ProjectFileType.DEFAULT_EXTENSION.equals(FileUtil.getExtension(file.getName()));
return FileUtilRt.extensionEquals(file.getName(), ProjectFileType.DEFAULT_EXTENSION);
}
private static String composeWsPath(String filePath) {
@@ -24,7 +24,7 @@ import com.intellij.openapi.options.StreamProvider;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
@@ -225,7 +225,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
return null;
}
String extension = FileUtil.getExtension(new File(expandedFile).getName());
String extension = FileUtilRt.getExtension(new File(expandedFile).getName());
if (!ourHeadlessEnvironment && extension.length() == 0) {
throw new IllegalArgumentException("Extension is missing for storage file: " + expandedFile);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.mac.MacFileChooserDialogImpl;
import com.intellij.util.SystemProperties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -70,7 +71,7 @@ public class FileChooserFactoryImpl extends FileChooserFactory {
private static boolean useNativeMacChooser(final FileChooserDescriptor descriptor) {
return SystemInfo.isMac &&
!descriptor.isChooseJarContents() &&
"true".equalsIgnoreCase(System.getProperty("native.mac.file.chooser.enabled", "true")) &&
SystemProperties.getBooleanProperty("native.mac.file.chooser.enabled", true) &&
Registry.is("ide.mac.file.chooser.native") &&
!DialogWrapper.isMultipleModalDialogs();
}
@@ -39,7 +39,7 @@ public interface DirectoryProjectGenerator<T> {
T showGenerationSettings(final VirtualFile baseDir) throws ProcessCanceledException;
void generateProject(@NotNull final Project project, @NotNull final VirtualFile baseDir,
@NotNull final T settings, @NotNull final Module module);
@Nullable final T settings, @NotNull final Module module);
@NotNull
ValidationResult validate(@NotNull String baseDirPath);
@@ -167,6 +167,10 @@ compiler.automake.trigger.delay=300
# suppress inspection "UnusedProperty"
compiler.automake.trigger.delay.description=Delay in milliseconds before triggering auto-make in response to file system events
compiler.document.save.trigger.delay=1500
# suppress inspection "UnusedProperty"
compiler.document.save.trigger.delay.description=Delay in milliseconds before triggering save of unchenged documents in response to document changed events
vcs.show.colored.annotations=true
vcs.showConsole=true
@@ -6,7 +6,7 @@
<p>You can quickly navigate in the currently edited file with <span class="shortcut">&shortcut:FileStructurePopup;</span>
(<span class="control">View | File Structure</span>).</p>
(<span class="control">Navigate | File Structure</span>).</p>
<p>It shows the list of members of the current class. Select an element you want to navigate to and press the
<span class="shortcut">Enter</span> key or the <span class="shortcut">&shortcut:EditSource;</span> key.</p>
<p>To easily locate an item in the list, just start typing its name.</p>
@@ -16,6 +16,8 @@
package com.intellij.openapi.util.text;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import gnu.trove.THashSet;
import gnu.trove.TIntHashSet;
import gnu.trove.TIntObjectHashMap;
import gnu.trove.TIntObjectProcedure;
@@ -74,7 +76,7 @@ public class TrigramBuilderTest {
}
}
else {
String ext = FileUtil.getExtension(name);
String ext = FileUtilRt.getExtension(name);
if (!allowedExtension.contains(ext)) return;
if (root.length() > 100 * 1024) return;
@@ -111,10 +113,10 @@ public class TrigramBuilderTest {
}
}
private static final Set<String> allowedExtension = new HashSet<String>(
private static final Set<String> allowedExtension = new THashSet<String>(
Arrays.asList("iml", "xml", "java", "html", "bat", "policy", "properties", "sh", "dtd", "ipr", "txt", "plist", "form", "xsl", "css",
"jsp", "jspx", "xhtml", "tld", "htm", "tag", "jspf", "js", "ft", "xsd", "xls", "rb", "php", "ftl", "c", "y", "erb", "rjs",
"rhtml", "sql", "cfml", "groovy", "text", "gsp", "h", "cc", "cpp", "wsdl"));
"rhtml", "sql", "cfml", "groovy", "text", "gsp", "h", "cc", "cpp", "wsdl"), FileUtil.PATH_HASHING_STRATEGY);
private static Collection<File> lookup(TIntObjectHashMap<List<File>> trigramsDatabase, String query) {
final Set<File> result = new HashSet<File>();
@@ -6,12 +6,10 @@ import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.containers.IntObjectCache;
import com.intellij.util.io.storage.Storage;
import gnu.trove.THashSet;
import junit.framework.TestCase;
import java.io.DataOutput;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.*;
import java.util.*;
import static com.intellij.util.io.StringEnumeratorTest.createRandomString;
@@ -340,7 +338,7 @@ public class PersistentMapTest extends TestCase {
.printf("Data file size = %d bytes\n", new File(myDataFile.getParentFile(), myDataFile.getName() + Storage.DATA_EXTENSION).length());
}
private static final boolean DO_SLOW_TEST = false;
private static final boolean DO_SLOW_TEST = true;
public void test2GLimit() throws IOException {
if (!DO_SLOW_TEST) return;
@@ -421,4 +419,56 @@ public class PersistentMapTest extends TestCase {
clearMap(file, map);
}
}
public void test2GLimitWithAppend() throws IOException {
if (!DO_SLOW_TEST) return;
File file = FileUtil.createTempFile("persistent", "map");
FileUtil.createParentDirs(file);
EnumeratorStringDescriptor stringDescriptor = new EnumeratorStringDescriptor();
class PathCollectionExternalizer implements DataExternalizer<Collection<String>> {
public void save(DataOutput out, Collection<String> value) throws IOException {
for (String str : value) {
IOUtil.writeString(str, out);
}
}
public Collection<String> read(DataInput in) throws IOException {
final Set<String> result = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
final DataInputStream stream = (DataInputStream)in;
while (stream.available() > 0) {
final String str = IOUtil.readString(stream);
result.add(str);
}
return result;
}
}
PathCollectionExternalizer externalizer = new PathCollectionExternalizer();
PersistentHashMap<String, Collection<String>> map = new PersistentHashMap<String, Collection<String>>(file, stringDescriptor,
externalizer);
for (int j = 0; j < 7; ++j) {
for (int i = 0; i < 2000; i++) {
final int finalJ = j;
map.appendData("abc" + i, new PersistentHashMap.ValueDataAppender() {
@Override
public void append(DataOutput out) throws IOException {
IOUtil.writeString(StringUtil.repeat("0123456789", 10000 + finalJ - 3), out);
}
});
}
}
map.close();
map = new PersistentHashMap<String, Collection<String>>(file, stringDescriptor, externalizer);
long len = 0;
for (String key : map.getAllKeysWithExistingMapping()) {
for (String k : map.get(key)) {
len += k.length();
}
}
map.close();
assertEquals(1400000000L, len);
}
}
@@ -38,6 +38,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.psi.PsiElement;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.refactoring.rename.inplace.InplaceRefactoring;
@@ -199,7 +200,7 @@ public class CodeInsightTestUtil {
}
public static void doActionTest(AnAction action, String file, CodeInsightTestFixture fixture) {
String extension = FileUtil.getExtension(file);
String extension = FileUtilRt.getExtension(file);
String name = FileUtil.getNameWithoutExtension(file);
fixture.configureByFile(file);
fixture.testAction(action);
@@ -68,7 +68,17 @@ public class FileUtilRt {
public static String getExtension(@NotNull String fileName) {
int index = fileName.lastIndexOf('.');
if (index < 0) return "";
return fileName.substring(index + 1).toLowerCase();
return fileName.substring(index + 1);
}
public static boolean extensionEquals(@NotNull String fileName, @NotNull String extension) {
int extLen = extension.length();
if (extLen == 0) {
return fileName.indexOf('.') == -1;
}
int extStart = fileName.length() - extLen;
return extStart >= 1 && fileName.charAt(extStart-1) == '.'
&& fileName.regionMatches(!SystemInfoRt.isFileSystemCaseSensitive, extStart, extension, 0, extLen);
}
@NotNull
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 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,22 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.idea.svn.config;
package com.intellij.util;
import com.intellij.openapi.project.Project;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ConfigureProxiesListener implements ActionListener {
private final Project myProject;
public ConfigureProxiesListener(final Project project) {
myProject = project;
}
public void actionPerformed(final ActionEvent e) {
final SvnConfigureProxiesDialog dialog = new SvnConfigureProxiesDialog(myProject);
dialog.show();
}
/**
* @author traff
*/
public interface AsyncProducer<T> {
void produce(Consumer<T> consumer);
}
@@ -827,9 +827,14 @@ public class FileUtil extends FileUtilRt {
return StringUtil.isEmpty(path) || path == null ? 0 : PATH_HASHING_STRATEGY.computeHashCode(toCanonicalPath(path));
}
/**
* @deprecated this method returns extension converted to lower case, this may not be correct for case-sensitive FS.
* Use {@link FileUtilRt#getExtension(String)} instead to get the unchanged extension.
* If you need to check whether a file has a specified extension use {@link FileUtilRt#extensionEquals(String, String)}
*/
@NotNull
public static String getExtension(@NotNull String fileName) {
return FileUtilRt.getExtension(fileName);
return FileUtilRt.getExtension(fileName).toLowerCase();
}
@NotNull
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.io.URLUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
@@ -101,7 +102,7 @@ public class ImageLoader implements Serializable {
List<Pair<String, Integer>> answer = new ArrayList<Pair<String, Integer>>(4);
final String name = FileUtil.getNameWithoutExtension(file);
final String ext = FileUtil.getExtension(file);
final String ext = FileUtilRt.getExtension(file);
if (dark && retina) {
answer.add(Pair.create(name + "@2x_dark." + ext, 2));
}
@@ -373,7 +373,7 @@ public class PagedFileStorage implements Forceable {
}
try {
assert page <= MAX_PAGES_COUNT;
assert page >= 0 && page <= MAX_PAGES_COUNT:page;
if (myStorageIndex == -1) {
myStorageIndex = myStorageLockContext.myStorageLock.registerPagedFileStorage(this);
@@ -673,14 +673,14 @@ public class PersistentHashMap<Key, Value> extends PersistentEnumeratorDelegate<
myEnumerator.myStorage.putInt(keyId + myParentValueRefOffset, -(int)(value + POSITIVE_VALUE_SHIFT));
if (newKey) ++smallKeys;
} else {
if (newKey && myLargeIndexWatermarkId == 0) {
myLargeIndexWatermarkId = keyId;
}
if (keyId < myLargeIndexWatermarkId && (oldValue == NULL_ADDR || canUseIntAddressForNewRecord(oldValue))) {
if ((keyId < myLargeIndexWatermarkId || myLargeIndexWatermarkId == 0) && (newKey || canUseIntAddressForNewRecord(oldValue))) {
// keyId is result of enumerate, if we do reenumerate then it is no longer accessible unless somebody cached it
myIntAddressForNewRecord = false;
keyId = myEnumerator.reenumerate(key == null ? myEnumerator.getValue(keyId, processingKey) : key);
++transformedKeys;
if (myLargeIndexWatermarkId == 0) {
myLargeIndexWatermarkId = keyId;
}
}
}
}
@@ -25,7 +25,7 @@ import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.DefaultJDOMExternalizer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.PlatformUtils;
import org.jdom.Element;
@@ -345,10 +345,10 @@ public final class VcsConfiguration implements PersistentStateComponent<Element>
public void acceptLastCreatedPatchName(final String string) {
if (StringUtil.isEmptyOrSpaces(string)) return;
final String extension = FileUtil.getExtension(string);
if (DIFF.equalsIgnoreCase(extension)) {
if (FileUtilRt.extensionEquals(string, DIFF)) {
DEFAULT_PATCH_EXTENSION = DIFF;
} else if (PATCH.equalsIgnoreCase(extension)) {
}
else if (FileUtilRt.extensionEquals(string, PATCH)) {
DEFAULT_PATCH_EXTENSION = PATCH;
}
}
@@ -31,6 +31,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.VcsException;
@@ -246,7 +247,7 @@ public class ChangeDiffRequestPresentable implements DiffRequestPresentable {
}
public static boolean checkAssociate(final Project project, final FilePath file, DiffChainContext context) {
final String pattern = FileUtil.getExtension(file.getName());
final String pattern = FileUtilRt.getExtension(file.getName()).toLowerCase();
if (context.contains(pattern)) return false;
int rc = Messages.showOkCancelDialog(project,
VcsBundle.message("diff.unknown.file.type.prompt", file.getName()),
@@ -22,6 +22,7 @@ import com.intellij.openapi.components.RoamingType;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.StreamProvider;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vcs.changes.CommitContext;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.util.containers.ContainerUtil;
@@ -192,7 +193,7 @@ public class CompoundShelfFileProcessor {
private String getNewFileName(final String serverFileName, final List<String> serverFileNames, final List<String> localFileNames) {
String name = FileUtil.getNameWithoutExtension(serverFileName);
String ext = FileUtil.getExtension(serverFileName);
String ext = FileUtilRt.getExtension(serverFileName);
for (int i = 1; ;i++) {
String suggestedName = name + i + "." + ext;
if (!serverFileNames.contains(suggestedName) && !localFileNames.contains(suggestedName)) {
@@ -37,6 +37,7 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.changes.patch.ApplyPatchDefaultExecutor;
@@ -299,7 +300,7 @@ public class ShelveChangesManager implements ProjectComponent, JDOMExternalizabl
String shelvedPath = null;
if (afterFile != null) {
String shelvedName = FileUtil.getNameWithoutExtension(afterFile.getName());
String shelvedExt = FileUtil.getExtension(afterFile.getName());
String shelvedExt = FileUtilRt.getExtension(afterFile.getName());
File shelvedFile = FileUtil.findSequentNonexistentFile(myFileProcessor.getBaseIODir(), shelvedName, shelvedExt);
myFileProcessor.saveFile(afterRevision.getFile().getIOFile(), shelvedFile);
@@ -332,7 +332,14 @@ public class BreakpointMasterDetailPopupBuilder {
actions.add(new AnAction("Remove Breakpoint", null, PlatformIcons.DELETE_ICON) {
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabled(MasterDetailPopupBuilder.allowedToRemoveItems(myPopupBuilder.getSelectedItems()));
boolean enabled = false;
final ItemWrapper[] items = myPopupBuilder.getSelectedItems();
for (ItemWrapper item : items) {
if (item.allowedToRemove()) {
enabled = true;
}
}
e.getPresentation().setEnabled(enabled);
}
@Override
@@ -118,7 +118,13 @@ class JpsIdeaSpecificSettings extends AbstractIdeaSpecificSettings<JpsModule, St
}
@Override
protected void readLanguageLevel(Element root, JpsModule model) throws InvalidDataException {}
protected void readLanguageLevel(Element root, JpsModule model) throws InvalidDataException {
final String languageLevel = root.getAttributeValue("LANGUAGE_LEVEL");
final JpsJavaModuleExtension extension = getService().getOrCreateModuleExtension(model);
if (languageLevel != null) {
extension.setLanguageLevel(LanguageLevel.valueOf(languageLevel));
}
}
@Override
protected void expandElement(Element root, JpsModule model) {
@@ -204,7 +204,7 @@ public class GitHistoryUtils {
final GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--all", "--pretty=format:%H%x20%ct%x0A", "--date-order", "--reverse", "--encoding=UTF-8", "--full-history",
h.addParameters("--branches", "--remotes", "--tags", "--pretty=format:%H%x20%ct%x0A", "--date-order", "--reverse", "--encoding=UTF-8", "--full-history",
"--sparse");
h.endOptions();
@@ -18,7 +18,7 @@ package org.jetbrains.plugins.groovy.intentions.conversions;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
@@ -46,7 +46,7 @@ public class MoveClassToNewFileIntention extends Intention {
final String name = psiClass.getName();
final PsiFile file = psiClass.getContainingFile();
final String fileExtension = FileUtil.getExtension(file.getName());
final String fileExtension = FileUtilRt.getExtension(file.getName());
final String newFileName = name + "." + fileExtension;
final PsiDirectory dir = file.getParent();
if (dir != null) {
@@ -17,7 +17,7 @@ package org.jetbrains.plugins.groovy.intentions.conversions;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.openapi.impl.RenameRefactoringImpl;
@@ -38,7 +38,7 @@ public class RenameFileWithClassIntention extends Intention {
final String name = psiClass.getName();
final PsiFile file = psiClass.getContainingFile();
final String newFileName = name + "." + FileUtil.getExtension(file.getName());
final String newFileName = name + "." + FileUtilRt.getExtension(file.getName());
new RenameRefactoringImpl(project, file, newFileName, true, true).run();
}
-1
View File
@@ -52,7 +52,6 @@
<action id="hg4idea.push" class="org.zmlx.hg4idea.action.HgPushAction" />
<separator/>
<action id="hg4idea.run.conflict.resolver" class="org.zmlx.hg4idea.action.HgRunConflictResolverAction"/>
<!--<action id="hg4idea.mq.rebase" class="org.zmlx.hg4idea.action.HgMqRebaseAction"/>-->
<separator/>
<action id="hg4idea.tag" class="org.zmlx.hg4idea.action.HgCreateTagAction"/>
@@ -36,6 +36,7 @@ import org.zmlx.hg4idea.ui.HgPushDialog;
import org.zmlx.hg4idea.util.HgErrorUtil;
import org.zmlx.hg4idea.util.HgUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
@@ -91,15 +92,16 @@ public class HgPusher {
return configCommand.getDefaultPushPath(repo);
}
@NotNull
public static List<HgTagBranch> getBranches(@NotNull Project project, @NotNull VirtualFile root) {
final AtomicReference<List<HgTagBranch>> branchesRef = new AtomicReference<List<HgTagBranch>>();
final List<HgTagBranch> branches = new ArrayList<HgTagBranch>();
new HgTagBranchCommand(project, root).listBranches(new Consumer<List<HgTagBranch>>() {
@Override
public void consume(final List<HgTagBranch> branches) {
branchesRef.set(branches);
branches.addAll(branches);
}
});
return branchesRef.get();
return branches;
}
private static void push(final Project project, HgPushCommand command) {
@@ -1,85 +0,0 @@
// Copyright 2008-2010 Victor Iacoban
//
// 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 org.zmlx.hg4idea.action;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.zmlx.hg4idea.command.HgMQCommand;
import org.zmlx.hg4idea.command.HgPullCommand;
import org.zmlx.hg4idea.ui.HgPullDialog;
import java.util.Collection;
// TODO unsued code. Keeping until MQ extension will be supported
public class HgMqRebaseAction extends HgAbstractGlobalAction {
protected HgGlobalCommandBuilder getHgGlobalCommandBuilder(final Project project) {
return new HgGlobalCommandBuilder() {
public HgGlobalCommand build(Collection<VirtualFile> repos) {
HgPullDialog dialog = new HgPullDialog(project);
dialog.setRoots(repos);
dialog.show();
if (dialog.isOK()) {
return buildCommand(dialog, project);
}
return null;
}
};
}
private HgGlobalCommand buildCommand(final HgPullDialog dialog, final Project project) {
final VirtualFile repository = dialog.getRepository();
return new HgGlobalCommand() {
public VirtualFile getRepo() {
return repository;
}
public void execute() {
HgMQCommand mqCommand = new HgMQCommand(project);
boolean notFoundAppliedPatches = mqCommand.qapplied(repository).isEmpty();
if (notFoundAppliedPatches) {
return;
}
HgPullCommand pullCommand = new HgPullCommand(project, repository);
pullCommand.setSource(dialog.getSource());
pullCommand.setRebase(true);
pullCommand.setUpdate(false);
//pullCommand.execute(new HgCommandResultHandler() {
// @Override
// public void process(@Nullable HgCommandResult result) {
// new HgCommandResultNotifier(project).process(result, null, null);
//
// String currentBranch = new HgTagBranchCommand(project, repository).getCurrentBranch();
// if (StringUtil.isEmptyOrSpaces(currentBranch)) {
// return;
// }
//
// new HgConflictResolver(project).resolve(repository);
//
// HgResolveCommand resolveCommand = new HgResolveCommand(project);
// Map<HgFile, HgResolveStatusEnum> status = resolveCommand.getListSynchronously(repository);
//
// if (status.containsValue(HgResolveStatusEnum.UNRESOLVED)) {
// return;
// }
//
// new HgRebaseCommand(project, repository).continueRebase();
// }
//});
}
};
}
}
@@ -1,34 +0,0 @@
// Copyright 2008-2010 Victor Iacoban
//
// 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 org.zmlx.hg4idea.command;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
import java.util.List;
public class HgMQCommand {
private final Project project;
public HgMQCommand(Project project) {
this.project = project;
}
public List<String> qapplied(@NotNull VirtualFile repo) {
return new HgCommandExecutor(project).executeInCurrentThread(repo, "qapplied", null).getOutputLines();
}
}
@@ -61,7 +61,9 @@ public class HgTagBranchCommand {
new HgCommandExecutor(project).execute(repo, "branches", null, new HgCommandResultHandler() {
@Override
public void process(@Nullable HgCommandResult result) {
branchListConsumer.consume(tokenize(result));
if (result != null) {
branchListConsumer.consume(tokenize(result));
}
}
});
}
@@ -70,12 +72,14 @@ public class HgTagBranchCommand {
new HgCommandExecutor(project).execute(repo, "tags", null, new HgCommandResultHandler() {
@Override
public void process(@Nullable HgCommandResult result) {
tagListConsumer.consume(tokenize(result));
if (result != null) {
tagListConsumer.consume(tokenize(result));
}
}
});
}
private List<HgTagBranch> tokenize(HgCommandResult result) {
private static List<HgTagBranch> tokenize(HgCommandResult result) {
List<HgTagBranch> branches = new LinkedList<HgTagBranch>();
for (final String line : result.getOutputLines()) {
Matcher matcher = BRANCH_LINE.matcher(line);
@@ -71,8 +71,6 @@ class HgCommandAuthenticator {
public boolean promptForAuthentication(Project project, String proposedLogin, String uri, String path) {
GetPasswordRunnable runnable = new GetPasswordRunnable(project, proposedLogin, uri, path, myForceAuthorization);
// Don't use Application#invokeAndWait here, as IntelliJ
// may already be showing a dialog (such as the clone dialog)
ApplicationManager.getApplication().invokeAndWait(runnable, ModalityState.defaultModalityState());
myRunnable = runnable;
return runnable.isOk();
@@ -91,9 +91,7 @@ public final class HgCommandExecutor {
myShowOutput = showOutput;
}
public void execute(@Nullable final VirtualFile repo,
final String operation,
final List<String> arguments,
public void execute(@Nullable final VirtualFile repo, @NotNull final String operation, @Nullable final List<String> arguments,
@Nullable final HgCommandResultHandler handler) {
HgUtil.executeOnPooledThreadIfNeeded(new Runnable() {
@Override
@@ -34,12 +34,10 @@ import java.util.List;
public class HgUpdateEnvironment implements UpdateEnvironment {
private final Project project;
private final HgUpdaterFactory hgUpdaterFactory;
private final HgUpdater.UpdateConfiguration updateConfiguration = new HgUpdater.UpdateConfiguration();
public HgUpdateEnvironment(Project project) {
this.project = project;
hgUpdaterFactory = new HgUpdaterFactory(project);
}
public void fillGroups(UpdatedFiles updatedFiles) {
@@ -64,7 +62,7 @@ public class HgUpdateEnvironment implements UpdateEnvironment {
continue;
}
try {
HgUpdater updater = hgUpdaterFactory.buildUpdater(repository, updateConfiguration);
HgUpdater updater = new HgRegularUpdater(project, repository, updateConfiguration);
result &= updater.update(updatedFiles, indicator, exceptions);
} catch (VcsException e) {
//TODO include module name where exception occurred
@@ -1,39 +0,0 @@
// Copyright 2008-2010 Victor Iacoban
//
// 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 org.zmlx.hg4idea.provider.update;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.command.HgMQCommand;
class HgUpdaterFactory {
private final Project project;
public HgUpdaterFactory(Project project) {
this.project = project;
}
HgUpdater buildUpdater(@NotNull VirtualFile repository, @NotNull HgUpdater.UpdateConfiguration configuration) throws VcsException {
HgMQCommand mqCommand = new HgMQCommand(project);
boolean foundAppliedPatches = !mqCommand.qapplied(repository).isEmpty();
if (foundAppliedPatches) {
throw new VcsException("Cannot update with applied MQ patches, please use rebase");
} else {
return new HgRegularUpdater(project, repository, configuration);
}
}
}
@@ -70,6 +70,9 @@ public class HgCurrentBranchStatusUpdater implements HgUpdater {
handleUpdate(project, null, Collections.<HgRevisionNumber>emptyList());
}
else {
if (project.isDisposed()) {
return;
}
Document document = textEditor.get().getDocument();
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
@@ -22,7 +22,7 @@ public final class HgErrorUtil {
private HgErrorUtil() { }
public static boolean isAbort(HgCommandResult result) {
public static boolean isAbort(@Nullable HgCommandResult result) {
if (result == null) {
return true;
}
@@ -35,14 +35,12 @@ public final class HgErrorUtil {
return false;
}
String line = getLastErrorLine(result);
return !StringUtil.isEmptyOrSpaces(line) && (
line.contains("authorization required")
|| line.contains("authorization failed")
return !StringUtil.isEmptyOrSpaces(line) && (line.contains("authorization required") || line.contains("authorization failed")
);
}
@Nullable
private static String getLastErrorLine(HgCommandResult result) {
private static String getLastErrorLine(@Nullable HgCommandResult result) {
if (result == null) {
return null;
}
@@ -53,7 +51,7 @@ public final class HgErrorUtil {
return errorLines.get(errorLines.size() - 1);
}
public static boolean hasErrorsInCommandExecution(HgCommandResult result) {
public static boolean hasErrorsInCommandExecution(@Nullable HgCommandResult result) {
return isAbort(result) || result.getExitValue() != 0;
}
@@ -63,6 +63,10 @@ public class IdeaSVNConfigFile {
return new DefaultProxyGroup(myDefaultProperties);
}
public void setValue(final String groupName, final String propertyName, final String value) {
mySVNConfigFile.setPropertyValue(groupName, propertyName, value, true);
}
public void deleteGroup(final String name) {
// remove all properties
final Map<String, String> properties = mySVNConfigFile.getProperties(name);
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.svn.SvnConfigurable">
<grid id="27dc6" binding="myComponent" layout-manager="GridLayoutManager" row-count="13" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myComponent" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="650" height="606"/>
<xy x="20" y="20" width="1135" height="631"/>
</constraints>
<properties/>
<clientProperties>
@@ -11,322 +11,386 @@
</clientProperties>
<border type="none"/>
<children>
<component id="947fd" class="javax.swing.JCheckBox" binding="myLockOnDemand" custom-create="true">
<tabbedpane id="b5f6e" class="com.intellij.ui.components.JBTabbedPane">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="action.Subversion.update.use.locks.on.demand.text.configurable"/>
<toolTipText resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="action.Subversion.update.use.locks.on.demand.description"/>
</properties>
</component>
<grid id="dcfcc" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
</clientProperties>
<border type="none" title="Subversion 1.7 Acceleration">
<color color="-16777216"/>
</border>
<border type="none"/>
<children>
<component id="e6bea" class="javax.swing.JRadioButton" binding="myJavaHLAcceleration">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="with native (JavaHL) Java bindings"/>
</properties>
</component>
<component id="26f6a" class="javax.swing.JRadioButton" binding="myNoAcceleration">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="no"/>
</properties>
</component>
<component id="6812b" class="javax.swing.JLabel" binding="myJavaHLInfo">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="4" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<text value="You need to have JavaHL 1.7.2"/>
</properties>
</component>
<grid id="90c00" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="2ae3a" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<tabbedpane title="General"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9c218" class="javax.swing.JRadioButton" binding="myWithCommandLineClient" default-binding="true">
<grid id="dcfcc" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
</clientProperties>
<border type="none" title="Subversion 1.7 Acceleration">
<color color="-16777216"/>
</border>
<children>
<component id="3ecd1" class="com.intellij.ui.components.JBCheckBox" binding="myWithCommandLineClient">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="with command line client:"/>
</properties>
</component>
<component id="44a8" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myCommandLineClient">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="a4729" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="947fd" class="javax.swing.JCheckBox" binding="myLockOnDemand" custom-create="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="action.Subversion.update.use.locks.on.demand.text.configurable"/>
<toolTipText resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="action.Subversion.update.use.locks.on.demand.description"/>
</properties>
</component>
<hspacer id="b767b">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="ec3a3" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9b7ff" class="javax.swing.JLabel" binding="myConfigurationDirectoryLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="label.configuration.configuration.directory"/>
</properties>
</component>
<component id="212b3" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myConfigurationDirectoryText">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
</children>
</grid>
<grid id="7bffa" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
<component id="df054" class="javax.swing.JCheckBox" binding="myUseDefaultCheckBox">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="with command line client:"/>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="checkbox.configure.use.system.default.configuration.directory"/>
</properties>
</component>
<component id="44a8" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myCommandLineClient">
<grid id="137aa" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="decc5" class="javax.swing.JButton" binding="myClearAuthButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="button.text.clear.authentication.cache"/>
</properties>
</component>
<component id="5b8dd" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
<fontColor value="BRIGHTER"/>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="label.text.delete.stored.credentials"/>
</properties>
</component>
</children>
</grid>
<hspacer id="e8f24">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<vspacer id="aa6b2">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
<grid id="718dd" layout-manager="GridLayoutManager" row-count="5" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Presentation"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="41718" class="javax.swing.JCheckBox" binding="myCheckNestedInQuickMerge">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Check svn:mergeinfo in target subtree when preparing for merge"/>
</properties>
</component>
<hspacer id="7b7ed">
<constraints>
<grid row="0" column="2" row-span="1" col-span="2" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<vspacer id="a25f1">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="a1351" class="javax.swing.JCheckBox" binding="myMaximumNumberOfRevisionsCheckBox" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Maximum number of revisions to look back in annotations:"/>
</properties>
</component>
<hspacer id="44294">
<constraints>
<grid row="1" column="2" row-span="1" col-span="2" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="aa58e" class="javax.swing.JSpinner" binding="myNumRevsInAnnotations" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="70" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="cd5ae" class="javax.swing.JCheckBox" binding="myShowMergeSourceInAnnotate" default-binding="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="annotation.show.merge.sources.default.text"/>
</properties>
</component>
<component id="f2afc" class="javax.swing.JCheckBox" binding="myIgnoreWhitespaceDifferenciesInCheckBox" default-binding="true">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="svn.option.ignore.whitespace.in.annotate"/>
</properties>
</component>
</children>
</grid>
<grid id="84b94" layout-manager="GridLayoutManager" row-count="6" column-count="31" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Network"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="95e5d">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="1283d" class="javax.swing.JCheckBox" binding="myUseCommonProxy">
<constraints>
<grid row="0" column="0" row-span="1" col-span="30" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Use IDEA general proxy settings as default for Subversion" noi18n="true"/>
</properties>
</component>
<grid id="96256" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" column="0" row-span="1" col-span="31" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3e7c5" class="javax.swing.JButton" binding="myEditProxiesButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="button.text.edit.proxies"/>
</properties>
</component>
<component id="d809a" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
<fontColor value="BRIGHTER"/>
<text value="Edit 'servers' Subversion runtime configuration file"/>
</properties>
</component>
<hspacer id="6eca1">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
<component id="f9a79" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="30" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
<fontColor value="BRIGHTER"/>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="use.idea.proxy.as.default.label.text"/>
</properties>
</component>
<grid id="9e56c" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9c08f" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="HTTP timeout:"/>
</properties>
</component>
<component id="ff486" class="javax.swing.JSpinner" binding="myHttpTimeout" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="70" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="234" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="SSH connection timeout:"/>
</properties>
</component>
<component id="21604" class="javax.swing.JSpinner" binding="mySSHConnectionTimeout" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="70" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="6949c" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="seconds"/>
</properties>
</component>
<component id="c9190" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="seconds"/>
</properties>
</component>
<component id="a770c" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="seconds"/>
</properties>
</component>
<component id="8e59f" class="javax.swing.JSpinner" binding="mySSHReadTimeout" custom-create="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="70" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="44801" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="SSH read timeout:"/>
</properties>
</component>
</children>
</grid>
<hspacer id="29b97">
<constraints>
<grid row="3" column="3" row-span="1" col-span="28" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="4756d" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</children>
</grid>
<component id="c2f81" class="javax.swing.JCheckBox" binding="myDetectNestedWorkingCopiesCheckBox" default-binding="true">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="detect.nested.working.copies"/>
</properties>
</component>
<component id="41718" class="javax.swing.JCheckBox" binding="myCheckNestedInQuickMerge">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Check svn:mergeinfo in target subtree when preparing for merge"/>
</properties>
</component>
<grid id="fa93d" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="44294">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="aa58e" class="javax.swing.JSpinner" binding="myNumRevsInAnnotations" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="70" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="a1351" class="javax.swing.JCheckBox" binding="myMaximumNumberOfRevisionsCheckBox" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Maximum number of revisions to look back in annotations:"/>
</properties>
</component>
</children>
</grid>
<component id="cd5ae" class="javax.swing.JCheckBox" binding="myShowMergeSourceInAnnotate" default-binding="true">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="annotation.show.merge.sources.default.text"/>
</properties>
</component>
<component id="f2afc" class="javax.swing.JCheckBox" binding="myIgnoreWhitespaceDifferenciesInCheckBox" default-binding="true">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="svn.option.ignore.whitespace.in.annotate"/>
</properties>
</component>
<grid id="dace9" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="234" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="SSH connection timeout:"/>
</properties>
</component>
<hspacer id="ca199">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="21604" class="javax.swing.JSpinner" binding="mySSHConnectionTimeout" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="70" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="44801" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="SSH read timeout:"/>
</properties>
</component>
<component id="8e59f" class="javax.swing.JSpinner" binding="mySSHReadTimeout" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="70" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<hspacer id="8e62f">
<constraints>
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="b9617" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="seconds"/>
</properties>
</component>
<component id="732b" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="seconds"/>
</properties>
</component>
</children>
</grid>
<grid id="39155" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="0">
<margin top="0" left="0" bottom="5" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9b7ff" class="javax.swing.JLabel" binding="myConfigurationDirectoryLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="label.configuration.configuration.directory"/>
</properties>
</component>
<component id="212b3" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myConfigurationDirectoryText">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="df054" class="javax.swing.JCheckBox" binding="myUseDefaultCheckBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="319" height="23"/>
</grid>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="checkbox.configure.use.system.default.configuration.directory"/>
</properties>
</component>
</children>
</grid>
<component id="1283d" class="javax.swing.JCheckBox" binding="myUseCommonProxy">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Use IDEA general proxy settings as default for Subversion" noi18n="true"/>
</properties>
</component>
<component id="f9a79" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
<fontColor value="BRIGHTER"/>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="use.idea.proxy.as.default.label.text"/>
</properties>
</component>
<grid id="e0f44" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="decc5" class="javax.swing.JButton" binding="myClearAuthButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="button.text.clear.authentication.cache"/>
</properties>
</component>
<component id="5b8dd" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
<fontColor value="BRIGHTER"/>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="label.text.delete.stored.credentials"/>
</properties>
</component>
<component id="3e7c5" class="javax.swing.JButton" binding="myEditProxiesButton">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="button.text.edit.proxies"/>
</properties>
</component>
<component id="d809a" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
<fontColor value="BRIGHTER"/>
<text value="Edit 'servers' Subversion runtime configuration file"/>
</properties>
</component>
<hspacer id="e8f24">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
<vspacer id="76b6e">
<constraints>
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="10"/>
</grid>
</constraints>
</vspacer>
</tabbedpane>
</children>
</grid>
</form>
@@ -18,7 +18,6 @@
package org.jetbrains.idea.svn;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
@@ -32,12 +31,12 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.ui.MultiLineTooltipUI;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.util.Consumer;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.config.ConfigureProxiesListener;
import org.jetbrains.idea.svn.config.SvnConfigureProxiesDialog;
import javax.swing.*;
import java.awt.*;
@@ -61,15 +60,13 @@ public class SvnConfigurable implements Configurable {
private JCheckBox myDetectNestedWorkingCopiesCheckBox;
private JCheckBox myIgnoreWhitespaceDifferenciesInCheckBox;
private JCheckBox myShowMergeSourceInAnnotate;
private JBCheckBox myWithCommandLineClient;
private JSpinner myNumRevsInAnnotations;
private JCheckBox myMaximumNumberOfRevisionsCheckBox;
private JSpinner mySSHConnectionTimeout;
private JSpinner mySSHReadTimeout;
private JRadioButton myJavaHLAcceleration;
private JRadioButton myNoAcceleration;
private JLabel myJavaHLInfo;
private JRadioButton myWithCommandLineClient;
private TextFieldWithBrowseButton myCommandLineClient;
private JSpinner myHttpTimeout;
@NonNls private static final String HELP_ID = "project.propSubversion";
@@ -118,7 +115,14 @@ public class SvnConfigurable implements Configurable {
myConfigurationDirectoryLabel.setLabelFor(myConfigurationDirectoryText);
myUseCommonProxy.setText(SvnBundle.message("use.idea.proxy.as.default", ApplicationNamesInfo.getInstance().getProductName()));
myEditProxiesButton.addActionListener(new ConfigureProxiesListener(myProject));
myEditProxiesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final SvnConfigureProxiesDialog dialog = new SvnConfigureProxiesDialog(myProject);
dialog.show();
myHttpTimeout.setValue(Long.valueOf(SvnConfiguration.getInstance(myProject).getHttpTimeout() / 1000));
}
});
myMaximumNumberOfRevisionsCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -126,15 +130,6 @@ public class SvnConfigurable implements Configurable {
}
});
myNumRevsInAnnotations.setEnabled(myMaximumNumberOfRevisionsCheckBox.isSelected());
ButtonGroup bg = new ButtonGroup();
bg.add(myNoAcceleration);
bg.add(myJavaHLAcceleration);
bg.add(myWithCommandLineClient);
final boolean internal = ApplicationManager.getApplication().isInternal();
myJavaHLAcceleration.setEnabled(internal);
myJavaHLAcceleration.setVisible(internal);
myJavaHLInfo.setVisible(internal);
}
public static void selectConfigirationDirectory(@NotNull String path, @NotNull final Consumer<String> dirConsumer,
@@ -209,9 +204,6 @@ public class SvnConfigurable implements Configurable {
if (configuration.UPDATE_LOCK_ON_DEMAND != myLockOnDemand.isSelected()) {
return true;
}
if (configuration.DETECT_NESTED_COPIES != myDetectNestedWorkingCopiesCheckBox.isSelected()) {
return true;
}
if (configuration.CHECK_NESTED_FOR_QUICK_MERGE != myCheckNestedInQuickMerge.isSelected()) {
return true;
}
@@ -238,41 +230,21 @@ public class SvnConfigurable implements Configurable {
if (configuration.mySSHReadTimeout/1000 != ((SpinnerNumberModel) mySSHReadTimeout.getModel()).getNumber().longValue()) {
return true;
}
if (configuration.getHttpTimeout()/1000 != ((SpinnerNumberModel) myHttpTimeout.getModel()).getNumber().longValue()) {
return true;
}
final SvnApplicationSettings applicationSettings17 = SvnApplicationSettings.getInstance();
if (! Comparing.equal(applicationSettings17.getCommandLinePath(), myCommandLineClient.getText().trim())) return true;
return !configuration.getConfigurationDirectory().equals(myConfigurationDirectoryText.getText().trim());
}
private SvnConfiguration.UseAcceleration acceleration() {
if (myNoAcceleration.isSelected()) return SvnConfiguration.UseAcceleration.nothing;
if (myJavaHLAcceleration.isSelected()) return SvnConfiguration.UseAcceleration.javaHL;
if (myWithCommandLineClient.isSelected()) return SvnConfiguration.UseAcceleration.commandLine;
return SvnConfiguration.UseAcceleration.nothing;
}
private void setAcceleration(SvnConfiguration.UseAcceleration acceleration) {
if (! CheckJavaHL.isPresent()) {
myJavaHLInfo.setText(CheckJavaHL.getProblemDescription());
myJavaHLInfo.setForeground(Color.red);
myJavaHLInfo.setEnabled(true);
myJavaHLAcceleration.setEnabled(false);
/*myJavaHLAcceleration.setText(myJavaHLAcceleration.getText() + ". " + CheckJavaHL.getProblemDescription());
myJavaHLAcceleration.setEnabled(false);
myJavaHLAcceleration.setForeground(Color.red);*/
} else {
myJavaHLInfo.setText("You need to have JavaHL 1.7.2");
myJavaHLInfo.setForeground(UIUtil.getInactiveTextColor());
myJavaHLAcceleration.setEnabled(true);
}
if (SvnConfiguration.UseAcceleration.javaHL.equals(acceleration)) {
myJavaHLAcceleration.setSelected(true);
return;
} else if (SvnConfiguration.UseAcceleration.commandLine.equals(acceleration)) {
myWithCommandLineClient.setSelected(true);
return;
}
myNoAcceleration.setSelected(true);
myWithCommandLineClient.setSelected(SvnConfiguration.UseAcceleration.commandLine.equals(acceleration));
}
public void apply() throws ConfigurationException {
@@ -281,10 +253,6 @@ public class SvnConfigurable implements Configurable {
configuration.setIsUseDefaultProxy(myUseCommonProxy.isSelected());
final SvnVcs vcs17 = SvnVcs.getInstance(myProject);
if ((! configuration.DETECT_NESTED_COPIES) && (configuration.DETECT_NESTED_COPIES != myDetectNestedWorkingCopiesCheckBox.isSelected())) {
vcs17.invokeRefreshSvnRoots(true);
}
configuration.DETECT_NESTED_COPIES = myDetectNestedWorkingCopiesCheckBox.isSelected();
configuration.CHECK_NESTED_FOR_QUICK_MERGE = myCheckNestedInQuickMerge.isSelected();
configuration.UPDATE_LOCK_ON_DEMAND = myLockOnDemand.isSelected();
configuration.setIgnoreSpacesInAnnotate(myIgnoreWhitespaceDifferenciesInCheckBox.isSelected());
@@ -303,6 +271,7 @@ public class SvnConfigurable implements Configurable {
if (SvnConfiguration.UseAcceleration.commandLine.equals(configuration.myUseAcceleration)) {
vcs17.checkCommandLineVersion();
}
configuration.setHttpTimeout(((SpinnerNumberModel) myHttpTimeout.getModel()).getNumber().longValue() * 1000);
}
public void reset() {
@@ -314,7 +283,6 @@ public class SvnConfigurable implements Configurable {
myConfigurationDirectoryText.setText(path);
myUseDefaultCheckBox.setSelected(configuration.isUseDefaultConfiguation());
myUseCommonProxy.setSelected(configuration.isIsUseDefaultProxy());
myDetectNestedWorkingCopiesCheckBox.setSelected(configuration.DETECT_NESTED_COPIES);
myCheckNestedInQuickMerge.setSelected(configuration.CHECK_NESTED_FOR_QUICK_MERGE);
boolean enabled = !myUseDefaultCheckBox.isSelected();
@@ -335,6 +303,7 @@ public class SvnConfigurable implements Configurable {
myNumRevsInAnnotations.setEnabled(myMaximumNumberOfRevisionsCheckBox.isSelected());
mySSHConnectionTimeout.setValue(Long.valueOf(configuration.mySSHConnectionTimeout / 1000));
mySSHReadTimeout.setValue(Long.valueOf(configuration.mySSHReadTimeout / 1000));
myHttpTimeout.setValue(Long.valueOf(configuration.getHttpTimeout() / 1000));
setAcceleration(configuration.myUseAcceleration);
final SvnApplicationSettings applicationSettings17 = SvnApplicationSettings.getInstance();
myCommandLineClient.setText(applicationSettings17.getCommandLinePath());
@@ -365,6 +334,7 @@ public class SvnConfigurable implements Configurable {
final long read = configuration.mySSHReadTimeout <= maximum ? configuration.mySSHReadTimeout : maximum;
mySSHConnectionTimeout = new JSpinner(new SpinnerNumberModel(Long.valueOf(connection / 1000), Long.valueOf(0L), maximum, Long.valueOf(10L)));
mySSHReadTimeout = new JSpinner(new SpinnerNumberModel(Long.valueOf(read / 1000), Long.valueOf(0L), maximum, Long.valueOf(10L)));
myHttpTimeout = new JSpinner(new SpinnerNumberModel(Long.valueOf(read / 1000), Long.valueOf(0L), maximum, Long.valueOf(10L)));
}
}
@@ -29,6 +29,7 @@ import org.jdom.Attribute;
import org.jdom.DataConversionException;
import org.jdom.Element;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.config.SvnServerFileKeys;
import org.jetbrains.idea.svn.dialogs.SvnAuthenticationProvider;
import org.jetbrains.idea.svn.dialogs.SvnInteractiveAuthenticationProvider;
import org.jetbrains.idea.svn.update.MergeRootInfo;
@@ -101,7 +102,7 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
public boolean MERGE_DIFF_USE_ANCESTRY = true;
public boolean UPDATE_LOCK_ON_DEMAND = false;
public boolean IGNORE_SPACES_IN_MERGE = false;
public boolean DETECT_NESTED_COPIES = true;
//public boolean DETECT_NESTED_COPIES = true;
public boolean CHECK_NESTED_FOR_QUICK_MERGE = false;
public boolean IGNORE_SPACES_IN_ANNOTATE = true;
public boolean SHOW_MERGE_SOURCES_IN_ANNOTATE = true;
@@ -114,6 +115,7 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
private final Map<File, MergeRootInfo> myMergeRootInfos = new HashMap<File, MergeRootInfo>();
private final Map<File, UpdateRootInfo> myUpdateRootInfos = new HashMap<File, UpdateRootInfo>();
private SvnInteractiveAuthenticationProvider myInteractiveProvider;
private IdeaSVNConfigFile myConfigFile;
@Override
public Element getState() {
@@ -137,6 +139,31 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
}
}
public long getHttpTimeout() {
initServers();
final String timeout = myConfigFile.getDefaultGroup().getTimeout();
try {
return Long.parseLong(timeout) * 1000;
} catch (NumberFormatException e) {
return 0;
}
}
private void initServers() {
if (myConfigFile == null) {
myConfigFile = new IdeaSVNConfigFile(new File(getConfigurationDirectory(), SERVERS_FILE_NAME));
}
myConfigFile.updateGroups();
}
// uses configuration directory property - it should be saved first
public void setHttpTimeout(final long value) {
initServers();
long cut = value / 1000;
myConfigFile.setValue("global", SvnServerFileKeys.TIMEOUT, String.valueOf(cut));
myConfigFile.save();
}
public static SvnConfiguration getInstance(final Project project) {
return ServiceManager.getService(project, SvnConfiguration.class);
}
@@ -313,10 +340,14 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
public void getServerFilesManagers(final Ref<SvnServerFileManager> systemManager, final Ref<SvnServerFileManager> userManager) {
// created only if does not exist
SVNConfigFile.createDefaultConfiguration(new File(getConfigurationDirectory()));
final File dir = new File(getConfigurationDirectory());
if (! dir.exists()) {
SVNConfigFile.createDefaultConfiguration(dir);
}
systemManager.set(new SvnServerFileManagerImpl(new IdeaSVNConfigFile(new File(SVNFileUtil.getSystemConfigurationDirectory(), SERVERS_FILE_NAME))));
userManager.set(new SvnServerFileManagerImpl(new IdeaSVNConfigFile(new File(getConfigurationDirectory(), SERVERS_FILE_NAME))));
initServers();
userManager.set(new SvnServerFileManagerImpl(myConfigFile));
}
public String getUpgradeMode() {
@@ -315,11 +315,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState
}
}
if (! SvnConfiguration.getInstance(myVcs.getProject()).DETECT_NESTED_COPIES) {
myApplier.apply(myVcs, myTopRoots, myLonelyRoots);
} else {
addNestedRoots(clearState);
}
addNestedRoots(clearState);
}
private void addNestedRoots(final boolean clearState) {
@@ -26,4 +26,6 @@ public interface SvnServerFileManager {
Map<String, ProxyGroup> getGroups();
void updateUserServerFile(final Collection<ProxyGroup> newUserGroups);
void updateFromFile();
}
@@ -65,6 +65,11 @@ public class SvnServerFileManagerImpl implements SvnServerFileManager {
myFile.save();
}
@Override
public void updateFromFile() {
myFile.updateGroups();
}
private void processGroup(final ProxyGroup newGroup, final ProxyGroup oldGroup, final boolean groupWasAdded) {
final String newGroupName = newGroup.getName();
if (groupWasAdded) {
@@ -1063,7 +1063,7 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
@Override
public boolean allowsNestedRoots() {
return SvnConfiguration.getInstance(myProject).DETECT_NESTED_COPIES;
return true;
}
@Override
@@ -29,8 +29,7 @@ public class ProxyGroup {
public ProxyGroup(final String groupName, final String patterns, final Map<String, String> properties) {
myGroupName = groupName;
myPattern = patterns;
myProperties = new HashMap<String, String>();
myProperties.putAll(properties);
myProperties = properties;
}
public Map<String, String> getProperties() {
@@ -57,6 +56,10 @@ public class ProxyGroup {
return myProperties.get(SvnServerFileKeys.TIMEOUT);
}
public void setTimeout(final String value) {
myProperties.put(SvnServerFileKeys.TIMEOUT, value);
}
public String getPatterns() {
return myPattern;
}
@@ -228,6 +228,7 @@ public class SvnConfigureProxiesComponent extends MasterDetailsComponent {
public void reset() {
super.reset();
myManager.updateFromFile();
for (int i = 0; i < myRoot.getChildCount(); i++) {
final MyNode node = (MyNode) myRoot.getChildAt(i);
Binary file not shown.
@@ -46,7 +46,6 @@ import com.intellij.util.io.ZipUtil;
import com.intellij.util.ui.UIUtil;
import junit.framework.Assert;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.svn.SvnConfiguration;
import org.jetbrains.idea.svn.SvnFileUrlMappingImpl;
import org.jetbrains.idea.svn.SvnVcs;
import org.jetbrains.idea.svn.actions.CreateExternalAction;
@@ -306,7 +305,6 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
verify(runSvn("copy", "-q", "-m", "coppy", mainUrl, branchUrl));
clManager.forceGoInTestMode();
SvnConfiguration.getInstance(myProject).DETECT_NESTED_COPIES = true;
vcs.invokeRefreshSvnRoots(false);
clManager.ensureUpToDate(false);
clManager.ensureUpToDate(false);
@@ -344,7 +342,6 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
// start change list manager again
clManager.forceGoInTestMode();
SvnConfiguration.getInstance(myProject).DETECT_NESTED_COPIES = true;
vcs.invokeRefreshSvnRoots(false);
clManager.ensureUpToDate(false);
clManager.ensureUpToDate(false);
@@ -15,7 +15,7 @@
*/
package org.jetbrains.idea.svn;
import org.junit.Test;
//import org.junit.Test;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.internal.util.SVNSocketFactory;
@@ -147,4 +147,6 @@ public class ProxyTest {
}
});
}
private @interface Test {}
}
@@ -41,7 +41,6 @@ public class SvnCommittedViewTest extends Svn17TestCase {
@Before
public void setUp() throws Exception {
super.setUp();
SvnConfiguration.getInstance(myProject).DETECT_NESTED_COPIES = false;
}
@Test
@@ -134,7 +134,6 @@ public class SvnExternalCommitNoticedTest extends Svn17TestCase {
final String branchUrl = prepareBranchesStructure();
final SubTree tree = new SubTree(myWorkingCopyDir);
SvnConfiguration.getInstance(myProject).DETECT_NESTED_COPIES = true;
myVcs.invokeRefreshSvnRoots(false);
clManager.ensureUpToDate(false);
clManager.ensureUpToDate(false);

Some files were not shown because too many files have changed in this diff Show More