mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -208,6 +208,8 @@ public class IncProjectBuilder {
|
||||
private void runBuild(CompileContext context) throws ProjectBuildException {
|
||||
context.setDone(0.0f);
|
||||
|
||||
LOG.info("Building project '" + context.getProject().getProjectName() + "'; isRebuild:" +context.isProjectRebuild() + "; isMake:" + context.isMake());
|
||||
|
||||
if (context.isProjectRebuild()) {
|
||||
cleanOutputRoots(context);
|
||||
}
|
||||
|
||||
@@ -1445,7 +1445,7 @@ public class Mappings {
|
||||
|
||||
if ((field.access & Opcodes.ACC_PRIVATE) == 0 && (field.access & mask) == mask) {
|
||||
if ((d.base() & Difference.ACCESS) > 0 || ((d.base() & Difference.VALUE) > 0 && d.hadValue())) {
|
||||
debug("Inline field changed it's access or value => a switch to non-incremental mode requested");
|
||||
debug("Inline field changed its access or value => a switch to non-incremental mode requested");
|
||||
if (!incrementalDecision(it.name, field, affectedFiles, filter)) {
|
||||
debug("End of Differentiate, returning false");
|
||||
return false;
|
||||
|
||||
@@ -17,12 +17,22 @@
|
||||
package com.intellij.codeInsight.template.impl;
|
||||
|
||||
import com.intellij.openapi.options.CompoundScheme;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class TemplateGroup extends CompoundScheme<TemplateImpl> {
|
||||
|
||||
private final String myReplace;
|
||||
|
||||
public TemplateGroup(final String name) {
|
||||
super(name);
|
||||
this(name, null);
|
||||
}
|
||||
|
||||
public TemplateGroup(String name, @Nullable String replace) {
|
||||
super(name);
|
||||
myReplace = replace;
|
||||
}
|
||||
|
||||
public String getReplace() {
|
||||
return myReplace;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,7 +487,14 @@ public class TemplateSettings implements PersistentStateComponent<Element>, Expo
|
||||
String templateName = getDefaultTemplateName(defTemplate);
|
||||
InputStream inputStream = DecodeDefaultsUtil.getDefaultsInputStream(provider, defTemplate);
|
||||
if (inputStream != null) {
|
||||
readDefTemplateFile(inputStream, templateName, provider.getClass().getClassLoader(), registerTemplate);
|
||||
TemplateGroup group =
|
||||
readTemplateFile(JDOMUtil.loadDocument(inputStream), templateName, true, registerTemplate, provider.getClass().getClassLoader());
|
||||
if (group != null && group.getReplace() != null) {
|
||||
Collection<TemplateImpl> templates = myTemplates.get(group.getReplace());
|
||||
for (TemplateImpl template : templates) {
|
||||
removeTemplate(template);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,10 +502,6 @@ public class TemplateSettings implements PersistentStateComponent<Element>, Expo
|
||||
return defTemplate.substring(defTemplate.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
private void readDefTemplateFile(InputStream inputStream, String defGroupName, ClassLoader classLoader, boolean registerTemplate) throws JDOMException, InvalidDataException, IOException {
|
||||
readTemplateFile(JDOMUtil.loadDocument(inputStream), defGroupName, true, registerTemplate, classLoader);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TemplateGroup readTemplateFile(Document document, @NonNls String defGroupName, boolean isDefault, boolean registerTemplate, ClassLoader classLoader) throws InvalidDataException {
|
||||
if (document == null) {
|
||||
@@ -512,7 +515,7 @@ public class TemplateSettings implements PersistentStateComponent<Element>, Expo
|
||||
String groupName = root.getAttributeValue(GROUP);
|
||||
if (groupName == null || groupName.length() == 0) groupName = defGroupName;
|
||||
|
||||
TemplateGroup result = new TemplateGroup(groupName);
|
||||
TemplateGroup result = new TemplateGroup(groupName, root.getAttributeValue("REPLACE"));
|
||||
|
||||
Map<String, TemplateImpl> created = new LinkedHashMap<String, TemplateImpl>();
|
||||
|
||||
|
||||
+5
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -176,7 +176,10 @@ public class ProjectWideFacetListenersRegistryImpl extends ProjectWideFacetListe
|
||||
}
|
||||
|
||||
public <F extends Facet> void unregisterListener(@NotNull FacetTypeId<F> typeId, @NotNull ProjectWideFacetListener<? extends F> listener) {
|
||||
myDispatchers.get(typeId).removeListener(listener);
|
||||
final EventDispatcher<ProjectWideFacetListener> dispatcher = myDispatchers.get(typeId);
|
||||
if (dispatcher != null) {
|
||||
dispatcher.removeListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public <F extends Facet> void registerListener(@NotNull final FacetTypeId<F> typeId, @NotNull final ProjectWideFacetListener<? extends F> listener,
|
||||
|
||||
+36
-35
@@ -195,26 +195,32 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
|
||||
|
||||
private static final boolean IS_UNDER_TEAMCITY = System.getProperty("bootstrap.testcases") != null;
|
||||
|
||||
private static final boolean SHOULD_PERFORM_ACCESS_CHECK = System.getenv("NO_FS_ROOTS_ACCESS_CHECK") == null;
|
||||
|
||||
private static final boolean IS_UNIT_TESTS = ApplicationManager.getApplication().isUnitTestMode();
|
||||
|
||||
|
||||
private static final Collection<String> additionalRoots = new THashSet<String>();
|
||||
private static final Collection<String> ourAdditionalRoots = new THashSet<String>();
|
||||
|
||||
@TestOnly
|
||||
public static void allowToAccess(@NotNull String root) {
|
||||
additionalRoots.add(FileUtil.toSystemIndependentName(root));
|
||||
public static void allowRootAccess(@NotNull String... roots) {
|
||||
for (String root : roots) {
|
||||
ourAdditionalRoots.add(FileUtil.toSystemIndependentName(root));
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static void disallowRootAccess(@NotNull String... roots) {
|
||||
for (String root : roots) {
|
||||
ourAdditionalRoots.remove(FileUtil.toSystemIndependentName(root));
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
private static void assertAccessInTests(VirtualFileSystemEntry child) {
|
||||
if (IS_UNIT_TESTS &&
|
||||
IS_UNDER_TEAMCITY &&
|
||||
ApplicationManager.getApplication() instanceof ApplicationImpl &&
|
||||
((ApplicationImpl)ApplicationManager.getApplication()).isComponentsCreated() &&
|
||||
SHOULD_PERFORM_ACCESS_CHECK) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (IS_UNDER_TEAMCITY &&
|
||||
SHOULD_PERFORM_ACCESS_CHECK &&
|
||||
application.isUnitTestMode() &&
|
||||
application instanceof ApplicationImpl &&
|
||||
((ApplicationImpl)application).isComponentsCreated()) {
|
||||
NewVirtualFileSystem fileSystem = child.getFileSystem();
|
||||
if (fileSystem != LocalFileSystem.getInstance() && fileSystem != JarFileSystem.getInstance()) {
|
||||
return;
|
||||
@@ -256,25 +262,25 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
@Nullable
|
||||
private static Set<String> allowedRoots() {
|
||||
if (insideGettingRoots) return null;
|
||||
|
||||
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
if (openProjects.length == 0) return null;
|
||||
|
||||
final Set<String> allowed = new THashSet<String>();
|
||||
String homePath = PathManager.getHomePath();
|
||||
allowed.add(FileUtil.toSystemIndependentName(homePath));
|
||||
allowed.add(FileUtil.toSystemIndependentName(PathManager.getHomePath()));
|
||||
|
||||
try {
|
||||
URL outUrl = Application.class.getResource("/");
|
||||
String output = new File(outUrl.toURI()).getParentFile().getParentFile().getPath();
|
||||
allowed.add(FileUtil.toSystemIndependentName(output));
|
||||
}
|
||||
catch (URISyntaxException ignored) { }
|
||||
String javaHome = SystemProperties.getJavaHome();
|
||||
allowed.add(FileUtil.toSystemIndependentName(javaHome));
|
||||
String tempDirectorySpecific = new File(FileUtil.getTempDirectory()).getParent();
|
||||
allowed.add(FileUtil.toSystemIndependentName(tempDirectorySpecific));
|
||||
String tempDirectory = System.getProperty("java.io.tmpdir");
|
||||
allowed.add(FileUtil.toSystemIndependentName(tempDirectory));
|
||||
String userHome = SystemProperties.getUserHome();
|
||||
allowed.add(FileUtil.toSystemIndependentName(userHome));
|
||||
|
||||
allowed.add(FileUtil.toSystemIndependentName(SystemProperties.getJavaHome()));
|
||||
allowed.add(FileUtil.toSystemIndependentName(new File(FileUtil.getTempDirectory()).getParent()));
|
||||
allowed.add(FileUtil.toSystemIndependentName(System.getProperty("java.io.tmpdir")));
|
||||
allowed.add(FileUtil.toSystemIndependentName(SystemProperties.getUserHome()));
|
||||
|
||||
for (Project project : openProjects) {
|
||||
if (!project.isInitialized()) {
|
||||
return null; // all is allowed
|
||||
@@ -290,12 +296,8 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
allowed.add(FileUtil.toSystemIndependentName(location));
|
||||
}
|
||||
|
||||
//for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
|
||||
// allowed.add(FileUtil.toSystemIndependentName(sdk.getHomePath()));
|
||||
//}
|
||||
for (String root : additionalRoots) {
|
||||
allowed.add(root);
|
||||
}
|
||||
allowed.addAll(ourAdditionalRoots);
|
||||
|
||||
return allowed;
|
||||
}
|
||||
|
||||
@@ -303,20 +305,19 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
|
||||
private static VirtualFile[] getAllRoots(Project project) {
|
||||
insideGettingRoots = true;
|
||||
Set<VirtualFile> roots = new THashSet<VirtualFile>();
|
||||
final Set<VirtualFile> roots = new THashSet<VirtualFile>();
|
||||
|
||||
final Module[] modules = ModuleManager.getInstance(project).getModules();
|
||||
for (Module module : modules) {
|
||||
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
final OrderEntry[] orderEntries = moduleRootManager.getOrderEntries();
|
||||
for (OrderEntry entry : orderEntries) {
|
||||
VirtualFile[] files = entry.getFiles(OrderRootType.CLASSES);
|
||||
ContainerUtil.addAll(roots, files);
|
||||
files = entry.getFiles(OrderRootType.SOURCES);
|
||||
ContainerUtil.addAll(roots, files);
|
||||
files = entry.getFiles(OrderRootType.CLASSES_AND_OUTPUT);
|
||||
ContainerUtil.addAll(roots, files);
|
||||
ContainerUtil.addAll(roots, entry.getFiles(OrderRootType.CLASSES));
|
||||
ContainerUtil.addAll(roots, entry.getFiles(OrderRootType.SOURCES));
|
||||
ContainerUtil.addAll(roots, entry.getFiles(OrderRootType.CLASSES_AND_OUTPUT));
|
||||
}
|
||||
}
|
||||
|
||||
insideGettingRoots = false;
|
||||
return VfsUtil.toVirtualFileArray(roots);
|
||||
}
|
||||
|
||||
+25
-16
@@ -27,6 +27,7 @@ import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl;
|
||||
import com.intellij.testFramework.PlatformLangTestCase;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.TimeoutUtil;
|
||||
@@ -334,32 +335,40 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
final int rv = new GeneralCommandLine("subst", subst + ":", targetDir.getAbsolutePath()).createProcess().waitFor();
|
||||
assertEquals(0, rv);
|
||||
|
||||
final File substDir = new File((subst + ":\\").toUpperCase(Locale.US), subDir.getName());
|
||||
final File substFile = new File(substDir, file.getName());
|
||||
refresh(targetDir);
|
||||
refresh(substDir);
|
||||
final String substRoot = (subst + ":\\").toUpperCase(Locale.US);
|
||||
VirtualDirectoryImpl.allowRootAccess(substRoot);
|
||||
|
||||
final LocalFileSystem.WatchRequest request = watch(substDir);
|
||||
try {
|
||||
FileUtil.writeToFile(file, "new content");
|
||||
assertEvent(VFileContentChangeEvent.class, substFile.getAbsolutePath());
|
||||
final File substDir = new File(substRoot, subDir.getName());
|
||||
final File substFile = new File(substDir, file.getName());
|
||||
refresh(targetDir);
|
||||
refresh(substDir);
|
||||
|
||||
final LocalFileSystem.WatchRequest request2 = watch(targetDir);
|
||||
final LocalFileSystem.WatchRequest request = watch(substDir);
|
||||
try {
|
||||
FileUtil.delete(file);
|
||||
assertEvent(VFileDeleteEvent.class, file.getAbsolutePath(), substFile.getAbsolutePath());
|
||||
FileUtil.writeToFile(file, "new content");
|
||||
assertEvent(VFileContentChangeEvent.class, substFile.getAbsolutePath());
|
||||
|
||||
final LocalFileSystem.WatchRequest request2 = watch(targetDir);
|
||||
try {
|
||||
FileUtil.delete(file);
|
||||
assertEvent(VFileDeleteEvent.class, file.getAbsolutePath(), substFile.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
unwatch(request2);
|
||||
}
|
||||
|
||||
FileUtil.writeToFile(file, "re-creation");
|
||||
assertEvent(VFileCreateEvent.class, substFile.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
unwatch(request2);
|
||||
myFileSystem.removeWatchedRoot(request);
|
||||
}
|
||||
|
||||
FileUtil.writeToFile(file, "re-creation");
|
||||
assertEvent(VFileCreateEvent.class, substFile.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
myFileSystem.removeWatchedRoot(request);
|
||||
new GeneralCommandLine("subst", subst + ":", "/d").createProcess().waitFor();
|
||||
VirtualDirectoryImpl.disallowRootAccess(substRoot);
|
||||
FileUtil.delete(targetDir);
|
||||
new GeneralCommandLine("subst", subst + ":", "/d").createProcess().waitFor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,10 @@ import com.intellij.Patches;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
@@ -679,11 +682,19 @@ public class FileUtil extends FileUtilRt {
|
||||
return next1 == '/' || next1 == File.separatorChar;
|
||||
}
|
||||
|
||||
public static boolean pathsEqual(@NotNull String path1, @NotNull String path2) {
|
||||
public static boolean filesEqual(@Nullable File file1, @Nullable File file2) {
|
||||
// on MacOS java.io.File.equals() is incorrectly case-sensitive
|
||||
return pathsEqual(file1 == null ? null : file1.getPath(), file2 == null ? null : file2.getPath(), true);
|
||||
}
|
||||
|
||||
public static boolean pathsEqual(@Nullable String path1, @Nullable String path2) {
|
||||
return pathsEqual(path1, path2, false);
|
||||
}
|
||||
|
||||
public static boolean pathsEqual(@NotNull String path1, @NotNull String path2, boolean convertSeparators) {
|
||||
public static boolean pathsEqual(@Nullable String path1, @Nullable String path2, boolean convertSeparators) {
|
||||
if (path1 == path2) return true;
|
||||
if (path1 == null || path2 == null) return false;
|
||||
|
||||
if (convertSeparators) {
|
||||
path1 = toSystemIndependentName(path1);
|
||||
path2 = toSystemIndependentName(path2);
|
||||
@@ -691,12 +702,13 @@ public class FileUtil extends FileUtilRt {
|
||||
return SystemInfo.isFileSystemCaseSensitive ? path1.equals(path2) : path1.equalsIgnoreCase(path2);
|
||||
}
|
||||
|
||||
public static int comparePaths(@NotNull String path1, @NotNull String path2) {
|
||||
return SystemInfo.isFileSystemCaseSensitive ? path1.compareTo(path2) : path1.compareToIgnoreCase(path2);
|
||||
public static int comparePaths(@Nullable String path1, @Nullable String path2) {
|
||||
return StringUtil.compare(path1, path2, !SystemInfo.isFileSystemCaseSensitive);
|
||||
}
|
||||
|
||||
public static int pathHashCode(@NotNull String path) {
|
||||
return SystemInfo.isFileSystemCaseSensitive ? path.hashCode() : path.toLowerCase().hashCode();
|
||||
public static int pathHashCode(@Nullable String path) {
|
||||
if (path == null) return 0;
|
||||
return SystemInfo.isFileSystemCaseSensitive ? path.hashCode() : StringUtil.toLowerCase(path).hashCode();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -222,8 +222,8 @@ public class StringUtil extends StringUtilRt {
|
||||
return html.replaceAll("<(.|\n)*?>", "");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String toLowerCase(@Nullable final String str) {
|
||||
//noinspection ConstantConditions
|
||||
return str == null ? null : str.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiErrorElement;
|
||||
import com.intellij.psi.XmlElementFactory;
|
||||
import com.intellij.psi.XmlRecursiveElementVisitor;
|
||||
@@ -168,6 +169,10 @@ public class ModelParser extends XmlRecursiveElementVisitor {
|
||||
}
|
||||
});
|
||||
|
||||
XmlFile xmlFile = container.getRoot().getClientProperty(XML_FILE_KEY);
|
||||
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(xmlFile.getProject());
|
||||
psiDocumentManager.commitDocument(psiDocumentManager.getDocument(xmlFile));
|
||||
|
||||
PropertyParser propertyParser = container.getRoot().getClientProperty(PropertyParser.KEY);
|
||||
propertyParser.load(movedComponent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user