Merge remote-tracking branch 'origin/master'

This commit is contained in:
Maxim.Mossienko
2015-01-19 17:20:55 +01:00
30 changed files with 258 additions and 92 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.execution.filters.LineNumbersMapping;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
@@ -129,9 +128,6 @@ public abstract class JavaLineBreakpointTypeBase<P extends JavaBreakpointPropert
result.set(JavaLineBreakpointType.class);
}
}
else if (file.getUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY) != null) {
result.set(JavaLineBreakpointType.class);
}
}
if (result.isNull()) {
result.set(JavaMethodBreakpointType.class);
@@ -455,9 +455,11 @@ public class GenericsHighlightUtil {
HighlightUtil.formatClass(superContainingClass),
JavaHighlightUtil.formatMethod(superMethod),
HighlightUtil.formatClass(superContainingClass, false));
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(classIdentifier).descriptionAndTooltip(message)
.create();
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createImplementMethodsFix(aClass));
return info;
}
if (isDefault || !isAbstract && superMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
@@ -471,9 +473,11 @@ public class GenericsHighlightUtil {
HighlightUtil.formatClass(containingClass) +
" and " +
HighlightUtil.formatClass(superContainingClass);
return HighlightInfo
final HighlightInfo info = HighlightInfo
.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(inheritUnrelatedDefaultsMessage)
.create();
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createImplementMethodsFix(aClass));
return info;
}
}
}
@@ -18,8 +18,8 @@ package org.jetbrains.java.generate.psi;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.JavaVersionService;
import com.intellij.openapi.projectRoots.JdkVersionUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
@@ -670,7 +670,11 @@ public class PsiAdapter {
}
public static int getJavaVersion(PsiElement element) {
final JavaSdkVersion sdkVersion = JavaVersionService.getInstance().getJavaSdkVersion(element);
JavaSdkVersion sdkVersion = JavaVersionService.getInstance().getJavaSdkVersion(element);
if (sdkVersion == null) {
sdkVersion = JavaSdkVersion.fromLanguageLevel(PsiUtil.getLanguageLevel(element));
}
int version = 0;
switch (sdkVersion) {
case JDK_1_0:
@@ -17,6 +17,7 @@ package com.intellij.openapi.projectRoots;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author anna
@@ -28,6 +29,7 @@ public class JavaVersionServiceImpl extends JavaVersionService {
return JavaSdkVersionUtil.isAtLeast(element, version);
}
@Nullable
@Override
public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) {
return JavaSdkVersionUtil.getJavaSdkVersion(element);
@@ -718,6 +718,7 @@ public class RefactoringUtil {
PsiUtil.setModifierProperty(method, PsiModifier.FINAL, false);
PsiUtil.setModifierProperty(method, PsiModifier.SYNCHRONIZED, false);
PsiUtil.setModifierProperty(method, PsiModifier.NATIVE, false);
PsiUtil.setModifierProperty(method, PsiModifier.PUBLIC, false);
removeFinalParameters(method);
}
@@ -23,6 +23,7 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class JavaVersionService {
public static JavaVersionService getInstance() {
@@ -33,6 +34,7 @@ public class JavaVersionService {
return PsiUtil.getLanguageLevel(element).isAtLeast(version.getMaxLanguageLevel());
}
@Nullable
public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) {
return JavaSdkVersion.fromLanguageLevel(PsiUtil.getLanguageLevel(element));
}
@@ -3,5 +3,5 @@ interface Bar<T> { }
interface Base<T> { }
class Foo<T,U> implements Base<U> {
void ge<caret>t(Bar<U> bar) { }
public void ge<caret>t(Bar<U> bar) { }
}
@@ -16,6 +16,7 @@
package com.intellij.openapi.editor.impl;
import com.intellij.codeInsight.folding.CodeFoldingManager;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.FoldRegion;
import com.intellij.testFramework.TestFileType;
@@ -55,7 +56,31 @@ public class FoldingProcessingOnDocumentModificationTest extends AbstractEditorT
assertFalse(foldRegion.isExpanded());
}
public void testCollapseAllHappensBeforeFirstCodeFoldingPass() throws Exception {
init("class Foo {\n" +
" void m() {\n" +
" System.out.println();\n" +
" System.out.println();\n" +
" }\n" +
"}", TestFileType.JAVA);
buildInitialFoldRegions();
executeAction(IdeActions.ACTION_COLLAPSE_ALL_REGIONS);
runFoldingPass(true);
assertEquals(1, myEditor.getFoldingModel().getAllFoldRegions().length);
}
private static void buildInitialFoldRegions() {
CodeFoldingManager.getInstance(getProject()).buildInitialFoldings(myEditor);
}
private static void updateFoldRegions() {
CodeFoldingManager.getInstance(getProject()).updateFoldRegions(myEditor);
}
private static void runFoldingPass(boolean firstTime) {
Runnable runnable = CodeFoldingManager.getInstance(getProject()).updateFoldRegionsAsync(myEditor, firstTime);
assertNotNull(runnable);
runnable.run();
}
}
@@ -16,10 +16,7 @@
package org.jetbrains.jps.incremental;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.LowMemoryWatcher;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SmartList;
@@ -84,7 +81,7 @@ import java.util.concurrent.atomic.AtomicReference;
public class IncProjectBuilder {
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.IncProjectBuilder");
private static final String CLASSPATH_INDEX_FINE_NAME = "classpath.index";
private static final String CLASSPATH_INDEX_FILE_NAME = "classpath.index";
private static final boolean GENERATE_CLASSPATH_INDEX = Boolean.parseBoolean(System.getProperty(GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION, "false"));
private static final boolean SYNC_DELETE = Boolean.parseBoolean(System.getProperty("jps.sync.delete", SystemInfo.isWindows ? "true" : "false"));
private static final GlobalContextKey<Set<BuildTarget<?>>> TARGET_WITH_CLEARED_OUTPUT = GlobalContextKey.create("_targets_with_cleared_output_");
@@ -334,7 +331,25 @@ public class IncProjectBuilder {
BuildRunner.PARALLEL_BUILD_ENABLED);
context.addBuildListener(new ChainedTargetsBuildListener(context));
//Deletes class loader classpath index files for changed output roots
context.addBuildListener(new BuildListener() {
@Override
public void filesGenerated(Collection<Pair<String, String>> paths) {
final Set<File> outputs = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
for (Pair<String, String> pair : paths) {
outputs.add(new File(pair.getFirst()));
}
for (File root : outputs) {
//noinspection ResultOfMethodCallIgnored
new File(root, CLASSPATH_INDEX_FILE_NAME).delete();
}
}
@Override
public void filesDeleted(Collection<String> paths) {
}
});
for (TargetBuilder builder : myBuilderRegistry.getTargetBuilders()) {
builder.buildStarted(context);
}
@@ -965,7 +980,7 @@ public class IncProjectBuilder {
File outputDir = ((ModuleBuildTarget)target).getOutputDir();
if (outputDir != null && outputDirs.add(outputDir)) {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outputDir, CLASSPATH_INDEX_FINE_NAME)));
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outputDir, CLASSPATH_INDEX_FILE_NAME)));
try {
writeIndex(writer, outputDir, "");
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 282 B

@@ -281,6 +281,13 @@ public class FoldingUpdate {
}
public static class FoldingMap extends MultiMap<PsiElement, FoldingDescriptor>{
public FoldingMap() {
}
public FoldingMap(FoldingMap map) {
super(map);
}
@NotNull
@Override
protected Map<PsiElement, Collection<FoldingDescriptor>> createMap() {
@@ -76,11 +76,14 @@ class UpdateFoldRegionsOperation implements Runnable {
FoldingModelEx foldingModel = (FoldingModelEx)myEditor.getFoldingModel();
Map<TextRange,Boolean> rangeToExpandStatusMap = newTroveMap();
removeInvalidRegions(info, foldingModel, rangeToExpandStatusMap);
// FoldingUpdate caches instances of our object, so they must be immutable.
FoldingUpdate.FoldingMap elementsToFold = new FoldingUpdate.FoldingMap(myElementsToFoldMap);
removeInvalidRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap);
Map<FoldRegion, Boolean> shouldExpand = newTroveMap();
Map<FoldingGroup, Boolean> groupExpand = newTroveMap();
List<FoldRegion> newRegions = addNewRegions(info, foldingModel, rangeToExpandStatusMap, shouldExpand, groupExpand);
List<FoldRegion> newRegions = addNewRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap, shouldExpand, groupExpand);
applyExpandStatus(newRegions, shouldExpand, groupExpand);
}
@@ -100,14 +103,14 @@ class UpdateFoldRegionsOperation implements Runnable {
private List<FoldRegion> addNewRegions(@NotNull EditorFoldingInfo info,
@NotNull FoldingModelEx foldingModel,
@NotNull Map<TextRange, Boolean> rangeToExpandStatusMap,
FoldingUpdate.FoldingMap elementsToFold, @NotNull Map<TextRange, Boolean> rangeToExpandStatusMap,
@NotNull Map<FoldRegion, Boolean> shouldExpand,
@NotNull Map<FoldingGroup, Boolean> groupExpand) {
List<FoldRegion> newRegions = newArrayList();
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(myProject);
for (PsiElement element : myElementsToFoldMap.keySet()) {
for (PsiElement element : elementsToFold.keySet()) {
ProgressManager.checkCanceled();
final Collection<FoldingDescriptor> descriptors = myElementsToFoldMap.get(element);
final Collection<FoldingDescriptor> descriptors = elementsToFold.get(element);
for (FoldingDescriptor descriptor : descriptors) {
FoldingGroup group = descriptor.getGroup();
TextRange range = descriptor.getRange();
@@ -165,7 +168,7 @@ class UpdateFoldRegionsOperation implements Runnable {
private void removeInvalidRegions(@NotNull EditorFoldingInfo info,
@NotNull FoldingModelEx foldingModel,
@NotNull Map<TextRange, Boolean> rangeToExpandStatusMap) {
FoldingUpdate.FoldingMap elementsToFold, @NotNull Map<TextRange, Boolean> rangeToExpandStatusMap) {
List<FoldRegion> toRemove = newArrayList();
InjectedLanguageManager injectedManager = InjectedLanguageManager.getInstance(myProject);
for (FoldRegion region : foldingModel.getAllFoldRegions()) {
@@ -176,7 +179,7 @@ class UpdateFoldRegionsOperation implements Runnable {
if (isInjected != myForInjected) continue;
}
final Collection<FoldingDescriptor> descriptors;
if (element != null && !(descriptors = myElementsToFoldMap.get(element)).isEmpty()) {
if (element != null && !(descriptors = elementsToFold.get(element)).isEmpty()) {
boolean matchingDescriptorFound = false;
FoldingDescriptor[] array = descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
for (FoldingDescriptor descriptor : array) {
@@ -194,7 +197,7 @@ class UpdateFoldRegionsOperation implements Runnable {
break;
}
else {
myElementsToFoldMap.remove(element, descriptor);
elementsToFold.remove(element, descriptor);
}
}
}
@@ -1682,10 +1682,10 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
myProgressIndicator, new Processor<Object>() {
@Override
public boolean process(Object o) {
if (o instanceof PsiElement && !(((PsiElement)o).getParent() instanceof PsiFile)) {
if (isSymbol(o)) {
final PsiElement element = (PsiElement)o;
final PsiFile file = element.getContainingFile();
if (!myListModel.contains(o) &&
if (!myListModel.contains(o) && !symbols.contains(o) &&
//some elements are non-physical like DB columns
(file == null || (file.getVirtualFile() != null && (includeLibs || scope.accept(file.getVirtualFile()))))) {
symbols.add(o);
@@ -1698,6 +1698,16 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
return symbols;
}
protected boolean isSymbol(Object o) {
if (o instanceof PsiElement) {
final PsiElement e = (PsiElement)o;
//todo[kb] need a better way to avoid mixing java classes with symbols. Same to other languages where
//todo[kb] symbol provider returns classes. We need kind of suppressor API & EP here.
return !e.getLanguage().is(Language.findLanguageByID("JAVA")) || !(e.getParent() instanceof PsiFile);
}
return false;
}
private SearchResult getClasses(String pattern, boolean includeLibs, final int max, ChooseByNamePopup chooseByNamePopup) {
final SearchResult classes = new SearchResult();
if (chooseByNamePopup == null) {
@@ -38,6 +38,7 @@ import com.intellij.ui.*;
import com.intellij.ui.components.panels.VerticalLayout;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.Alarm;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Consumer;
import com.intellij.util.ui.ColorIcon;
import com.intellij.util.ui.UIUtil;
@@ -237,11 +238,11 @@ public class ScopeEditorPanel {
myPackageTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
final boolean recursiveEnabled = isButtonEnabled(true, e.getPaths(), e);
final boolean recursiveEnabled = isButtonEnabled(true);
includeRec.setEnabled(recursiveEnabled);
excludeRec.setEnabled(recursiveEnabled);
final boolean nonRecursiveEnabled = isButtonEnabled(false, e.getPaths(), e);
final boolean nonRecursiveEnabled = isButtonEnabled(false);
include.setEnabled(nonRecursiveEnabled);
exclude.setEnabled(nonRecursiveEnabled);
}
@@ -281,19 +282,6 @@ public class ScopeEditorPanel {
return buttonsPanel;
}
static boolean isButtonEnabled(boolean rec, TreePath[] paths, TreeSelectionEvent e) {
if (paths != null) {
for (TreePath path : paths) {
if (!e.isAddedPath(path)) continue;
final PackageDependenciesNode node = (PackageDependenciesNode)path.getLastPathComponent();
if (PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE).createPackageSet(node, rec) != null) {
return true;
}
}
}
return false;
}
boolean isButtonEnabled(boolean rec) {
final TreePath[] paths = myPackageTree.getSelectionPaths();
if (paths != null) {
@@ -25,6 +25,7 @@ import com.intellij.openapi.wm.ex.WindowManagerEx;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.ui.mac.MacMainFrameDecorator;
import com.intellij.util.IJSwingUtilities;
import com.intellij.util.ui.Animator;
import org.jetbrains.annotations.NotNull;
@@ -221,6 +222,7 @@ public class SheetMessage {
staticImage = null;
myWindow.setContentPane(myController.getPanel(myWindow));
IJSwingUtilities.moveMousePointerOn(myWindow.getRootPane().getDefaultButton());
myController.requestFocus();
} else {
if (restoreFullScreenButton) {
@@ -100,7 +100,7 @@ inspection.empty.method.delete.quickfix=Delete unnecessary method(s)
inspection.empty.method.problem.descriptor=Method only calls its super
inspection.empty.method.problem.descriptor1=Empty method overrides empty method
inspection.empty.method.problem.descriptor2=The method is empty
inspection.empty.method.problem.descriptor3=The method and all it's derivables are empty
inspection.empty.method.problem.descriptor3=The method and all its derivables are empty
inspection.empty.method.problem.descriptor4=All implementations of this method are empty
#redundant cast
@@ -716,9 +716,6 @@
<action id="IntroduceParameter">
<keyboard-shortcut first-keystroke="control alt P"/>
</action>
<action id="IntroduceFunctionalParameter">
<keyboard-shortcut first-keystroke="control alt shift P"/>
</action>
<action id="NextOccurence">
<keyboard-shortcut first-keystroke="control alt DOWN"/>
</action>
@@ -0,0 +1,21 @@
package org.jetbrains.debugger;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.XSourcePosition;
import org.jetbrains.annotations.Nullable;
public final class DebuggerSupportUtils {
@Nullable
public static XSourcePosition calcSourcePosition(@Nullable PsiElement element) {
if (element != null) {
PsiElement navigationElement = element.getNavigationElement();
VirtualFile file = navigationElement.getContainingFile().getVirtualFile();
if (file != null) {
return XDebuggerUtil.getInstance().createPositionByOffset(file, navigationElement.getTextOffset());
}
}
return null;
}
}
@@ -56,7 +56,7 @@ public class FileSystemUtil {
@Nullable
protected abstract String resolveSymLink(@NotNull String path) throws Exception;
protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception { return false; }
protected boolean clonePermissions(@NotNull String source, @NotNull String target, boolean onlyPermissionsToExecute) throws Exception { return false; }
@NotNull
private String getName() { return getClass().getSimpleName().replace("MediatorImpl", ""); }
@@ -196,7 +196,21 @@ public class FileSystemUtil {
*/
public static boolean clonePermissions(@NotNull String source, @NotNull String target) {
try {
return ourMediator.clonePermissions(source, target);
return ourMediator.clonePermissions(source, target, false);
}
catch (Exception e) {
LOG.warn(e);
return false;
}
}
/**
* Gives the second file permissions to execute of the first one if possible; returns true if succeed.
* Will do nothing on Windows.
*/
public static boolean clonePermissionsToExecute(@NotNull String source, @NotNull String target) {
try {
return ourMediator.clonePermissions(source, target, true);
}
catch (Exception e) {
LOG.warn(e);
@@ -303,21 +317,44 @@ public class FileSystemUtil {
}
@Override
protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception {
protected boolean clonePermissions(@NotNull String source, @NotNull String target, boolean onlyPermissionsToExecute) throws Exception {
if (SystemInfo.isUnix) {
Object pathObj = myGetPath.invoke(myDefaultFileSystem, source, ArrayUtil.EMPTY_STRING_ARRAY);
Map attributes = (Map)myReadAttributes.invoke(null, pathObj, "posix:permissions", myLinkOptions);
if (attributes != null) {
Object permissions = attributes.get("permissions");
if (permissions instanceof Collection) {
mySetAttribute.invoke(null, pathObj, "posix:permissions", permissions, myLinkOptions);
return true;
Object sourcePath = myGetPath.invoke(myDefaultFileSystem, source, ArrayUtil.EMPTY_STRING_ARRAY);
Object targetPath = myGetPath.invoke(myDefaultFileSystem, target, ArrayUtil.EMPTY_STRING_ARRAY);
Collection sourcePermissions = getPermissions(sourcePath);
if (sourcePermissions != null) {
Collection permissionsToSet;
if (onlyPermissionsToExecute) {
Collection targetPermissions = getPermissions(targetPath);
permissionsToSet = new HashSet();
for (Object permission : targetPermissions) {
if (!permission.toString().endsWith("_EXECUTE")) {
permissionsToSet.add(permission);
}
}
for (Object permission : sourcePermissions) {
if (permission.toString().endsWith("_EXECUTE")) {
permissionsToSet.add(permission);
}
}
}
else {
permissionsToSet = sourcePermissions;
}
mySetAttribute.invoke(null, targetPath, "posix:permissions", permissionsToSet, myLinkOptions);
return true;
}
}
return false;
}
private Collection getPermissions(Object sourcePath) throws IllegalAccessException, InvocationTargetException {
Map attributes = (Map)myReadAttributes.invoke(null, sourcePath, "posix:permissions", myLinkOptions);
if (attributes == null) return null;
Object permissions = attributes.get("permissions");
return permissions instanceof Collection<?> ? (Collection)permissions : null;
}
}
@@ -346,6 +383,7 @@ public class FileSystemUtil {
int S_IFREG = 0100000; // regular file
int S_IFDIR = 0040000; // directory
int PERM_MASK = 0777;
int EXECUTE_MASK = 0111;
int WRITE_MASK = 0222;
int W_OK = 2; // write permission flag for access(2)
@@ -396,14 +434,13 @@ public class FileSystemUtil {
int res = SystemInfo.isLinux ? myLibC.__lxstat64(0, path, buffer) : myLibC.lstat(path, buffer);
if (res != 0) return null;
int mode = (SystemInfo.isLinux ? buffer.getInt(myOffsets[OFF_MODE]) : buffer.getShort(myOffsets[OFF_MODE])) & LibC.S_MASK;
int mode = getModeFlags(buffer) & LibC.S_MASK;
boolean isSymlink = (mode & LibC.S_IFLNK) == LibC.S_IFLNK;
if (isSymlink) {
res = SystemInfo.isLinux ? myLibC.__xstat64(0, path, buffer) : myLibC.stat(path, buffer);
if (res != 0) {
if (!loadFileStatus(path, buffer)) {
return FileAttributes.BROKEN_SYMLINK;
}
mode = (SystemInfo.isLinux ? buffer.getInt(myOffsets[OFF_MODE]) : buffer.getShort(myOffsets[OFF_MODE])) & LibC.S_MASK;
mode = getModeFlags(buffer) & LibC.S_MASK;
}
boolean isDirectory = (mode & LibC.S_IFDIR) == LibC.S_IFDIR;
@@ -418,6 +455,10 @@ public class FileSystemUtil {
return new FileAttributes(isDirectory, isSpecial, isSymlink, false, size, mTime, writable);
}
private boolean loadFileStatus(@NotNull String path, Memory buffer) {
return (SystemInfo.isLinux ? myLibC.__xstat64(0, path, buffer) : myLibC.stat(path, buffer)) == 0;
}
@Override
protected String resolveSymLink(@NotNull final String path) throws Exception {
try {
@@ -434,15 +475,25 @@ public class FileSystemUtil {
}
@Override
protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception {
protected boolean clonePermissions(@NotNull String source, @NotNull String target, boolean onlyPermissionsToExecute) throws Exception {
Memory buffer = new Memory(256);
int res = SystemInfo.isLinux ? myLibC.__xstat64(0, source, buffer) : myLibC.stat(source, buffer);
if (res == 0) {
int permissions = (SystemInfo.isLinux ? buffer.getInt(myOffsets[OFF_MODE]) : buffer.getShort(myOffsets[OFF_MODE])) & LibC.PERM_MASK;
return myLibC.chmod(target, permissions) == 0;
}
if (!loadFileStatus(source, buffer)) return false;
return false;
int permissions;
int sourcePermissions = getModeFlags(buffer) & LibC.PERM_MASK;
if (onlyPermissionsToExecute) {
if (!loadFileStatus(target, buffer)) return false;
int targetPermissions = getModeFlags(buffer) & LibC.PERM_MASK;
permissions = targetPermissions & ~LibC.EXECUTE_MASK | sourcePermissions & LibC.EXECUTE_MASK;
}
else {
permissions = sourcePermissions;
}
return myLibC.chmod(target, permissions) == 0;
}
private int getModeFlags(Memory buffer) {
return SystemInfo.isLinux ? buffer.getInt(myOffsets[OFF_MODE]) : buffer.getShort(myOffsets[OFF_MODE]);
}
private boolean ownFile(Memory buffer) {
@@ -509,11 +560,14 @@ public class FileSystemUtil {
}
@Override
protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception {
protected boolean clonePermissions(@NotNull String source, @NotNull String target, boolean onlyPermissionsToExecute) throws Exception {
if (SystemInfo.isUnix) {
File srcFile = new File(source);
File dstFile = new File(target);
return dstFile.setWritable(srcFile.canWrite(), true) && dstFile.setExecutable(srcFile.canExecute(), true);
if (!onlyPermissionsToExecute) {
if (!dstFile.setWritable(srcFile.canWrite(), true)) return false;
}
return dstFile.setExecutable(srcFile.canExecute(), true);
}
return false;
@@ -497,7 +497,7 @@ public class FileUtil extends FileUtilRt {
}
if (SystemInfo.isUnix && fromFile.canExecute()) {
FileSystemUtil.clonePermissions(fromFile.getPath(), toFile.getPath());
FileSystemUtil.clonePermissionsToExecute(fromFile.getPath(), toFile.getPath());
}
}
@@ -156,6 +156,7 @@ public class Restarter {
public static File createTempExecutable(File executable) throws IOException {
File executableDir = new File(System.getProperty("user.home") + "/." + System.getProperty("idea.paths.selector") + "/restart");
File copy = new File(executableDir.getPath() + "/" + executable.getName());
if (!FileUtilRt.createDirectory(executableDir)) throw new IOException("Cannot create dir: " + executableDir);
if (!FileUtilRt.ensureCanCreateFile(copy) || (copy.exists() && !copy.delete())) {
String ext = FileUtilRt.getExtension(executable.getName());
copy = FileUtilRt.createTempFile(executableDir, FileUtilRt.getNameWithoutExtension(copy.getName()),
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -275,6 +275,11 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
PsiElement element;
int offset = lineStart;
if (file instanceof PsiCompiledFile) {
file = ((PsiCompiledFile)file).getDecompiledPsiFile();
}
while (offset < lineEnd) {
element = file.findElementAt(offset);
if (element != null) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -229,15 +229,17 @@ public class InjectorUtils {
public static BaseInjection findCommentInjection(@NotNull PsiElement context, @NotNull String supportId, @Nullable Ref<PsiElement> causeRef) {
PsiElement target = CompletionUtil.getOriginalOrSelf(context);
PsiFile file = target.getContainingFile();
if (file == null || file.getFileType().isBinary()) return null;
TreeMap<TextRange, BaseInjection> map = getInjectionMap(file);
Map.Entry<TextRange, BaseInjection> entry = map == null ? null : map.lowerEntry(target.getTextRange());
if (map == null) return null;
Map.Entry<TextRange, BaseInjection> entry = map.lowerEntry(target.getTextRange());
if (entry == null) return null;
PsiComment psiComment = PsiTreeUtil.findElementOfClassAtOffset(file, entry.getKey().getStartOffset(), PsiComment.class, false);
if (psiComment == null) return null;
TextRange r0 = psiComment.getTextRange();
// calulate topmost siblings & heights
// calculate topmost siblings & heights
PsiElement commonParent = PsiTreeUtil.findCommonParent(psiComment, target);
int h1 = 0, h2 = 0;
PsiElement e1 = psiComment, e2 = target;
@@ -269,8 +271,7 @@ public class InjectorUtils {
}
@Nullable
private static TreeMap<TextRange, BaseInjection> getInjectionMap(@Nullable final PsiFile file) {
if (file == null) return null; // e.g. null for synthetic groovy variables
private static TreeMap<TextRange, BaseInjection> getInjectionMap(@NotNull final PsiFile file) {
return CachedValuesManager.getCachedValue(file, new CachedValueProvider<TreeMap<TextRange, BaseInjection>>() {
@Nullable
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.jetbrains.plugins.groovy.dsl;
import com.intellij.openapi.components.*;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import gnu.trove.THashMap;
@@ -49,11 +50,16 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
@Nullable
public synchronized String getInactivityReason(VirtualFile file) {
String status = myStatus.get(file);
return status == null || status == ENABLED ? null : status;
return ENABLED.equals(status) ? null : status;
}
public synchronized boolean isActivated(VirtualFile file) {
return myStatus.get(file) == ENABLED;
final String status = myStatus.get(file);
if (status == null) {
myStatus.put(file, ENABLED);
return true;
}
return ENABLED.equals(status);
}
@Nullable
@@ -66,7 +72,9 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
Element element = new Element("file");
root.addContent(element);
element.setAttribute("url", file.getUrl());
element.setAttribute("status", (status == ENABLED ? "" : status));
if (!ENABLED.equals(status)) {
element.setAttribute("status", status);
}
}
return root;
}
@@ -76,10 +84,10 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
List<Element> children = state.getChildren("file");
for (Element element : children) {
String url = element.getAttributeValue("url", "");
String status = element.getAttributeValue("status", ENABLED);
String status = element.getAttributeValue("status");
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
if (file != null) {
myStatus.put(file, status);
myStatus.put(file, StringUtil.isNotEmpty(status) ? status : ENABLED);
}
}
}
@@ -74,7 +74,7 @@ import java.util.regex.Pattern;
*/
public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
private static final Key<Pair<GroovyDslExecutor, Long>> CACHED_EXECUTOR = Key.create("CachedGdslExecutor");
private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.dsl.GroovyDslFileIndex");
private static final Logger LOG = Logger.getInstance(GroovyDslFileIndex.class);
@NonNls public static final ID<String, Void> NAME = ID.create("GroovyDslFileIndex");
@NonNls private static final String OUR_KEY = "ourKey";
@@ -412,7 +412,10 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
if (!vfile.isValid()) {
continue;
}
if (!fileIndex.isInLibraryClasses(vfile) && !fileIndex.isInLibrarySource(vfile)) {
if (fileIndex.isInLibrarySource(vfile)) {
continue;
}
if (!fileIndex.isInLibraryClasses(vfile)) {
if (!fileIndex.isInSourceContent(vfile) || !isActivated(vfile)) {
continue;
}
@@ -221,20 +221,31 @@ public class TypesUtil {
@NotNull PsiElement context,
@NotNull ApplicableTo position) {
if (actualType instanceof PsiIntersectionType) {
ConversionResult min = ConversionResult.ERROR;
for (PsiType child : ((PsiIntersectionType)actualType).getConjuncts()) {
if (canAssign(targetType, child, context, position) == ConversionResult.OK) {
final ConversionResult result = canAssign(targetType, child, context, position);
if (result.ordinal() < min.ordinal()) {
min = result;
}
if (min == ConversionResult.OK) {
return ConversionResult.OK;
}
}
return ConversionResult.ERROR;
return min;
}
if (targetType instanceof PsiIntersectionType) {
ConversionResult max = ConversionResult.OK;
for (PsiType child : ((PsiIntersectionType)targetType).getConjuncts()) {
if (canAssign(child, actualType, context, position) != ConversionResult.OK) {
final ConversionResult result = canAssign(child, actualType, context, position);
if (result.ordinal() > max.ordinal()) {
max = result;
}
if (max == ConversionResult.ERROR) {
return ConversionResult.ERROR;
}
}
return ConversionResult.OK;
return max;
}
final ConversionResult result = areTypesConvertible(targetType, actualType, context, position);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -183,8 +183,9 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light {
}
decompiler.decompileContext();
file.putUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY,
new ExactMatchLineNumbersMapping(saver.myMapping));
if (saver.myMapping != null) {
file.putUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY, new ExactMatchLineNumbersMapping(saver.myMapping));
}
return saver.myResult;
}
@@ -344,7 +345,7 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light {
private static class ExactMatchLineNumbersMapping implements LineNumbersMapping {
private int[] myMapping;
private ExactMatchLineNumbersMapping(int[] mapping) {
private ExactMatchLineNumbersMapping(@NotNull int[] mapping) {
myMapping = mapping;
}
@@ -49,11 +49,15 @@ public class PyProjectStructureDetector extends ProjectStructureDetector {
@NotNull List<DetectedProjectRoot> result) {
LOG.info("Detecting roots under " + dir);
for (File child : children) {
if (FileUtilRt.extensionEquals(child.getName(), "py")) {
final String name = child.getName();
if (FileUtilRt.extensionEquals(name, "py")) {
LOG.info("Found Python file " + child.getPath());
result.add(new DetectedContentRoot(dir, "Python", PythonModuleTypeBase.getInstance(), WebModuleType.getInstance()));
return DirectoryProcessingResult.SKIP_CHILDREN;
}
if ("node_modules".equals(name)) {
return DirectoryProcessingResult.SKIP_CHILDREN;
}
}
return DirectoryProcessingResult.PROCESS_CHILDREN;
}
+1
View File
@@ -70,6 +70,7 @@
<action id="IntroduceFunctionalParameter" class="com.intellij.refactoring.actions.IntroduceFunctionalParameterAction">
<add-to-group group-id="IntroduceActionsGroup" anchor="after" relative-to-action="IntroduceParameter"/>
<keyboard-shortcut first-keystroke="control shift alt P" keymap="$default"/>
</action>
<action id="IntroduceParameterObject" class="com.intellij.refactoring.actions.IntroduceParameterObjectAction">