This commit is contained in:
Alexey Kudravtsev
2019-01-18 14:48:24 +03:00
parent 8bdafda949
commit 93f518ffc2
7 changed files with 21 additions and 12 deletions
@@ -62,6 +62,7 @@ public class LanguageLevelModuleExtensionImpl extends ModuleExtension implements
myState = state;
}
@NotNull
@Override
public ModuleExtension getModifiableModel(final boolean writable) {
return new LanguageLevelModuleExtensionImpl(this, writable);
@@ -37,6 +37,7 @@ public class JavaModuleExternalPathsImpl extends JavaModuleExternalPaths {
}
}
@NotNull
@Override
public ModuleExtension getModifiableModel(boolean writable) {
return new JavaModuleExternalPathsImpl(this);
@@ -49,17 +49,18 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
private boolean myInheritedCompilerOutput = true;
private boolean myExcludeOutput = true;
@NotNull
private final Module myModule;
private CompilerModuleExtensionImpl mySource;
private boolean myWritable;
private boolean myDisposed;
public CompilerModuleExtensionImpl(@NotNull final Module module) {
public CompilerModuleExtensionImpl(@NotNull Module module) {
myModule = module;
}
public CompilerModuleExtensionImpl(final CompilerModuleExtensionImpl source, final boolean writable) {
public CompilerModuleExtensionImpl(@NotNull CompilerModuleExtensionImpl source, final boolean writable) {
this(source.myModule);
myWritable = writable;
myCompilerOutput = source.myCompilerOutput;
@@ -128,7 +129,7 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
}
@Nullable
protected static String getOutputPathValue(Element element, String tag) {
protected static String getOutputPathValue(@NotNull Element element, @NotNull String tag) {
final Element outputPathChild = element.getChild(tag);
if (outputPathChild != null) {
return outputPathChild.getAttributeValue(ATTRIBUTE_URL);
@@ -180,6 +181,7 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
return myCompilerOutputPathForTestsPointer == null ? null : myCompilerOutputPathForTestsPointer.getUrl();
}
@NotNull
private String getSanitizedModuleName() {
Module module = getModule();
VirtualFile file = module.getModuleFile();
@@ -191,7 +193,8 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
setCompilerOutputPath(file == null ? null : file.getUrl());
}
private VirtualFilePointer createPointer(final String url) {
@NotNull
private VirtualFilePointer createPointer(@NotNull String url) {
return VirtualFilePointerManager.getInstance().create(url, this, null);
}
@@ -214,10 +217,12 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
myCompilerOutputPathForTestsPointer = url == null ? null : createPointer(url);
}
@NotNull
public Module getModule() {
return myModule;
}
@NotNull
public Project getProject() {
return myModule.getProject();
}
@@ -260,6 +265,7 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
return myExcludeOutput;
}
@NotNull
@Override
public CompilerModuleExtension getModifiableModel(final boolean writable) {
assert !myDisposed;
@@ -309,9 +315,10 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
myCompilerOutputForTests = null;
}
@NotNull
@Override
public VirtualFile[] getOutputRoots(final boolean includeTests) {
final ArrayList<VirtualFile> result = new ArrayList<>();
List<VirtualFile> result = new ArrayList<>();
final VirtualFile outputPathForTests = includeTests ? getCompilerOutputPathForTests() : null;
if (outputPathForTests != null) {
@@ -325,6 +332,7 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
return VfsUtilCore.toVirtualFileArray(result);
}
@NotNull
@Override
public String[] getOutputRootUrls(final boolean includeTests) {
final List<String> result = new ArrayList<>();
@@ -4,6 +4,7 @@ package com.intellij.openapi.roots;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -72,7 +73,9 @@ public abstract class CompilerModuleExtension extends ModuleExtension {
public abstract boolean isExcludeOutput();
@NotNull
public abstract VirtualFile[] getOutputRoots(boolean includeTests);
@NotNull
public abstract String[] getOutputRootUrls(boolean includeTests);
}
@@ -51,6 +51,7 @@ public abstract class ModuleExtension implements Disposable {
* @param writable flag which identifies if resulting model is writable
* @return extension model
*/
@NotNull
public abstract ModuleExtension getModifiableModel(final boolean writable);
public abstract void commit();
@@ -17,7 +17,6 @@ import com.intellij.openapi.vfs.newvfs.events.*;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.ExceptionUtilRt;
import com.intellij.util.PathUtil;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
@@ -100,12 +99,7 @@ public class VfsTestUtil {
public static void deleteFile(@NotNull VirtualFile file) {
try {
WriteAction.runAndWait(new ThrowableRunnable<Throwable>() {
@Override
public void run() throws Throwable {
file.delete(null);
}
});
WriteAction.runAndWait(() -> file.delete(null));
}
catch (Throwable throwable) {
ExceptionUtilRt.rethrow(throwable);
@@ -80,6 +80,7 @@ public class MavenSourceFoldersModuleExtension extends ModuleExtension {
}
}
@NotNull
@Override
public ModuleExtension getModifiableModel(boolean writable) {
return new MavenSourceFoldersModuleExtension();