use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class SvnMergeProvider method conflictResolvedForFile.
public void conflictResolvedForFile(@NotNull VirtualFile file) {
// TODO: Add possibility to resolve content conflicts separately from property conflicts.
SvnVcs vcs = SvnVcs.getInstance(myProject);
File path = virtualToIoFile(file);
try {
// TODO: Probably false should be passed to "resolveTree", but previous logic used true implicitly
vcs.getFactory(path).createConflictClient().resolve(path, Depth.EMPTY, false, true, true);
} catch (VcsException e) {
LOG.warn(e);
}
// the .mine/.r## files have been deleted
final VirtualFile parent = file.getParent();
if (parent != null) {
parent.refresh(true, false);
}
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class SvnMergeProvider method loadRevisions.
@NotNull
public MergeData loadRevisions(@NotNull final VirtualFile file) throws VcsException {
final MergeData data = new MergeData();
VcsRunnable runnable = () -> {
File oldFile = null;
File newFile = null;
File workingFile = null;
boolean mergeCase = false;
SvnVcs vcs = SvnVcs.getInstance(myProject);
Info info = vcs.getInfo(file);
if (info != null) {
oldFile = info.getConflictOldFile();
newFile = info.getConflictNewFile();
workingFile = info.getConflictWrkFile();
mergeCase = workingFile == null || workingFile.getName().contains("working");
// for debug
if (workingFile == null) {
LOG.info("Null working file when merging text conflict for " + file.getPath() + " old file: " + oldFile + " new file: " + newFile);
}
if (mergeCase) {
// this is merge case
oldFile = info.getConflictNewFile();
newFile = info.getConflictOldFile();
workingFile = info.getConflictWrkFile();
}
data.LAST_REVISION_NUMBER = new SvnRevisionNumber(info.getRevision());
} else {
throw new VcsException("Could not get info for " + file.getPath());
}
if (oldFile == null || newFile == null || workingFile == null) {
ByteArrayOutputStream bos = getBaseRevisionContents(vcs, file);
data.ORIGINAL = bos.toByteArray();
data.LAST = bos.toByteArray();
data.CURRENT = readFile(virtualToIoFile(file));
} else {
data.ORIGINAL = readFile(oldFile);
data.LAST = readFile(newFile);
data.CURRENT = readFile(workingFile);
}
if (mergeCase) {
final ByteArrayOutputStream contents = getBaseRevisionContents(vcs, file);
if (!Arrays.equals(contents.toByteArray(), data.ORIGINAL)) {
// swap base and server: another order of merge arguments
byte[] original = data.ORIGINAL;
data.ORIGINAL = data.LAST;
data.LAST = original;
}
}
};
VcsUtil.runVcsProcessWithProgress(runnable, VcsBundle.message("multiple.file.merge.loading.progress.title"), false, myProject);
return data;
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class SuiteBrowser method showDialog.
@Override
public String showDialog() {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileVisible(VirtualFile virtualFile, boolean showHidden) {
if (!showHidden && virtualFile.getName().charAt(0) == '.')
return false;
return virtualFile.isDirectory() || "xml".equals(virtualFile.getExtension());
}
};
descriptor.setDescription("Please select the testng.xml suite file");
descriptor.setTitle("Select Suite");
VirtualFile file = FileChooser.chooseFile(descriptor, getProject(), null);
return file != null ? file.getPath() : null;
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class XsltDebuggerExtension method patchParameters.
public void patchParameters(final SimpleJavaParameters parameters, XsltRunConfiguration configuration, UserDataHolder extensionData) throws CantRunException {
final XsltRunConfiguration.OutputType outputType = configuration.getOutputType();
final Sdk jdk = configuration.getEffectiveJDK();
assert jdk != null;
final String ver = jdk.getVersionString();
if (ver == null || (ver.contains("1.0") || ver.contains("1.1") || ver.contains("1.2") || ver.contains("1.3") || ver.contains("1.4"))) {
throw new CantRunException("The XSLT Debugger can only be used with JDK 1.5+");
}
// TODO: fix and remove
if (outputType != XsltRunConfiguration.OutputType.CONSOLE) {
throw new CantRunException("XSLT Debugger requires Output Type == CONSOLE");
}
try {
final int port = NetUtils.findAvailableSocketPort();
parameters.getVMParametersList().defineProperty("xslt.debugger.port", String.valueOf(port));
extensionData.putUserData(PORT, port);
} catch (IOException e) {
LOG.info(e);
throw new CantRunException("Unable to find a free network port");
}
final char c = File.separatorChar;
final PluginId pluginId = PluginManagerCore.getPluginByClassName(getClass().getName());
assert pluginId != null || System.getProperty("xslt-debugger.plugin.path") != null;
final File pluginPath;
if (pluginId != null) {
final IdeaPluginDescriptor descriptor = PluginManager.getPlugin(pluginId);
assert descriptor != null;
pluginPath = descriptor.getPath();
} else {
// -Dxslt-debugger.plugin.path=C:\work\java\intellij/ultimate\out\classes\production\xslt-debugger-engine
pluginPath = new File(System.getProperty("xslt-debugger.plugin.path"));
}
File rtClasspath = new File(pluginPath, "lib" + c + "xslt-debugger-engine.jar");
if (rtClasspath.exists()) {
parameters.getClassPath().addTail(rtClasspath.getAbsolutePath());
final File rmiStubs = new File(pluginPath, "lib" + c + "rmi-stubs.jar");
assert rmiStubs.exists() : rmiStubs.getAbsolutePath();
parameters.getClassPath().addTail(rmiStubs.getAbsolutePath());
final File engineImpl = new File(pluginPath, "lib" + c + "rt" + c + "xslt-debugger-engine-impl.jar");
assert engineImpl.exists() : engineImpl.getAbsolutePath();
parameters.getClassPath().addTail(engineImpl.getAbsolutePath());
} else {
if (!(rtClasspath = new File(pluginPath, "classes")).exists()) {
if (ApplicationManagerEx.getApplicationEx().isInternal() && new File(pluginPath, "org").exists()) {
rtClasspath = pluginPath;
final File engineImplInternal = new File(pluginPath, ".." + c + "xslt-debugger-engine-impl");
assert engineImplInternal.exists() : engineImplInternal.getAbsolutePath();
parameters.getClassPath().addTail(engineImplInternal.getAbsolutePath());
} else {
throw new CantRunException("Runtime classes not found");
}
}
parameters.getClassPath().addTail(rtClasspath.getAbsolutePath());
final File rmiStubs = new File(rtClasspath, "rmi-stubs.jar");
assert rmiStubs.exists() : rmiStubs.getAbsolutePath();
parameters.getClassPath().addTail(rmiStubs.getAbsolutePath());
}
File trove4j = new File(PathManager.getLibPath() + c + "trove4j.jar");
if (!trove4j.exists()) {
trove4j = new File(PathManager.getHomePath() + c + "community" + c + "lib" + c + "trove4j.jar");
assert trove4j.exists() : trove4j.getAbsolutePath();
}
parameters.getClassPath().addTail(trove4j.getAbsolutePath());
final String type = parameters.getVMParametersList().getPropertyValue("xslt.transformer.type");
if ("saxon".equalsIgnoreCase(type)) {
addSaxon(parameters, pluginPath, SAXON_6_JAR);
} else if ("saxon9".equalsIgnoreCase(type)) {
addSaxon(parameters, pluginPath, SAXON_9_JAR);
} else if ("xalan".equalsIgnoreCase(type)) {
final Boolean xalanPresent = isValidXalanPresent(parameters);
if (xalanPresent == null) {
addXalan(parameters, pluginPath);
} else if (!xalanPresent) {
throw new CantRunException("Unsupported Xalan version is present in classpath.");
}
} else if (type != null) {
throw new CantRunException("Unsupported Transformer type '" + type + "'");
} else if (parameters.getClassPath().getPathsString().toLowerCase().contains("xalan")) {
if (isValidXalanPresent(parameters) == Boolean.TRUE) {
parameters.getVMParametersList().defineProperty("xslt.transformer.type", "xalan");
}
}
final VirtualFile xsltFile = configuration.findXsltFile();
final PsiManager psiManager = PsiManager.getInstance(configuration.getProject());
final XsltChecker.LanguageLevel level;
if (xsltFile != null) {
level = XsltSupport.getXsltLanguageLevel(psiManager.findFile(xsltFile));
} else {
level = XsltChecker.LanguageLevel.V1;
}
extensionData.putUserData(VERSION, level);
if (!parameters.getVMParametersList().hasProperty("xslt.transformer.type")) {
// add saxon for backward-compatibility
if (level == XsltChecker.LanguageLevel.V2) {
parameters.getVMParametersList().defineProperty("xslt.transformer.type", "saxon9");
addSaxon(parameters, pluginPath, SAXON_9_JAR);
} else {
parameters.getVMParametersList().defineProperty("xslt.transformer.type", "saxon");
addSaxon(parameters, pluginPath, SAXON_6_JAR);
}
}
parameters.getVMParametersList().defineProperty("xslt.main", "org.intellij.plugins.xsltDebugger.rt.XSLTDebuggerMain");
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class XsltDebuggerExtension method isValidXalanPresent.
@Nullable
private static Boolean isValidXalanPresent(SimpleJavaParameters parameters) {
final List<VirtualFile> files = parameters.getClassPath().getVirtualFiles();
for (VirtualFile file : files) {
if (file.getName().matches(".*xalan.*\\.jar")) {
final VirtualFile root = JarFileSystem.getInstance().getJarRootForLocalFile(file);
final VirtualFile manifestFile = root != null ? root.findFileByRelativePath("META-INF/MANIFEST.MF") : null;
if (manifestFile != null) {
try {
Manifest manifest = manifestFile.getUserData(MANIFEST);
if (manifest == null) {
manifest = new Manifest(manifestFile.getInputStream());
manifestFile.putUserData(MANIFEST, manifest);
}
Attributes attributes = manifest.getAttributes("org/apache/xalan/");
if (attributes == null) {
attributes = manifest.getAttributes("org/apache/xalan");
}
if (attributes == null) {
LOG.info("No manifest attributes for 'org/apache/xalan/' in " + manifestFile.getPresentableUrl());
continue;
}
final String version = attributes.getValue("Implementation-Version");
if (version != null) {
final String[] parts = version.split("\\.");
if (parts.length >= 2) {
if (Integer.parseInt(parts[0]) >= 2 && Integer.parseInt(parts[1]) >= 6) {
return true;
}
}
LOG.info("Unsupported Xalan version: " + version);
} else {
LOG.info("No Xalan version information in " + file.getPath());
}
} catch (IOException e) {
LOG.warn("Unable to read manifest from " + file.getName(), e);
}
} else {
LOG.info("No manifest file in " + file.getPath());
}
return false;
}
}
return null;
}
Aggregations