use of com.intellij.openapi.extensions.PluginId 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.extensions.PluginId in project Main by SpartanRefactoring.
the class LogFileUtils method getPath.
/**
* When running tests through intellij, the path seems to be:
* <IDEA_PROJECTS_DIR>/<PROJECT_DIR>/build/resources/...
* NOTE: there is no need to put logs in tests.
* When running idea instance through gradle, the path seems to be:
* <IDEA_PROJECTS_DIR>/<PROJECT_DIR>/build/idea-sandbox/plugins/<PLUGIN_NAME>/...
*
* @return The path of the logfile to be used.
*/
private static String getPath() {
PluginId ourPluginId = PluginId.getId(PluginDescriptorReader.getPluginId());
IdeaPluginDescriptor ourPlugin = PluginManager.getPlugin(ourPluginId);
if (ourPlugin == null)
throw new RuntimeException("Cannot retrieve plugin descriptor");
return ourPlugin.getPath().getPath() + SLASH + RELATIVE_LOG_PATH + BASE_LOG_NAME + DOT + LOG_EXT;
}
use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.
the class XsltCommandLineState method createJavaParameters.
protected SimpleJavaParameters createJavaParameters() throws ExecutionException {
final Sdk jdk = myXsltRunConfiguration.getEffectiveJDK();
if (jdk == null) {
throw CantRunException.noJdkConfigured();
}
final SimpleJavaParameters parameters = new SimpleJavaParameters();
parameters.setJdk(jdk);
if (myXsltRunConfiguration.getJdkChoice() == XsltRunConfiguration.JdkChoice.FROM_MODULE) {
final Module module = myXsltRunConfiguration.getEffectiveModule();
// OK to run as if just a JDK has been selected (a missing JDK would already have been complained about above)
if (module != null) {
OrderEnumerator.orderEntries(module).productionOnly().recursively().classes().collectPaths(parameters.getClassPath());
}
}
final ParametersList vmParameters = parameters.getVMParametersList();
vmParameters.addParametersString(myXsltRunConfiguration.myVmArguments);
if (isEmpty(myXsltRunConfiguration.getXsltFile())) {
throw new CantRunException("No XSLT file selected");
}
vmParameters.defineProperty("xslt.file", myXsltRunConfiguration.getXsltFile());
if (isEmpty(myXsltRunConfiguration.getXmlInputFile())) {
throw new CantRunException("No XML input file selected");
}
vmParameters.defineProperty("xslt.input", myXsltRunConfiguration.getXmlInputFile());
final XsltRunConfiguration.OutputType outputType = myXsltRunConfiguration.getOutputType();
if (outputType == XsltRunConfiguration.OutputType.CONSOLE) {
//noinspection deprecation
myPort = NetUtils.tryToFindAvailableSocketPort(myXsltRunConfiguration.myRunnerPort);
vmParameters.defineProperty("xslt.listen-port", String.valueOf(myPort));
}
if (myXsltRunConfiguration.isSaveToFile()) {
vmParameters.defineProperty("xslt.output", myXsltRunConfiguration.myOutputFile);
}
for (Pair<String, String> pair : myXsltRunConfiguration.getParameters()) {
final String name = pair.getFirst();
final String value = pair.getSecond();
if (isEmpty(name) || value == null)
continue;
vmParameters.defineProperty("xslt.param." + name, value);
}
vmParameters.defineProperty("xslt.smart-error-handling", String.valueOf(myXsltRunConfiguration.mySmartErrorHandling));
final PluginId pluginId = PluginManagerCore.getPluginByClassName(getClass().getName());
assert pluginId != null || System.getProperty("xslt.plugin.path") != null : "PluginId not found - development builds need to specify -Dxslt.plugin.path=../out/classes/production/xslt-rt";
final File pluginPath;
if (pluginId != null) {
final IdeaPluginDescriptor descriptor = PluginManager.getPlugin(pluginId);
assert descriptor != null;
pluginPath = descriptor.getPath();
} else {
// -Dxslt.plugin.path=C:\work\java\intellij/ultimate\out\classes\production\xslt-rt
pluginPath = new File(System.getProperty("xslt.plugin.path"));
}
LOG.debug("Plugin Path = " + pluginPath.getAbsolutePath());
final char c = File.separatorChar;
File rtClasspath = new File(pluginPath, "lib" + c + "rt" + c + "xslt-rt.jar");
// File rtClasspath = new File("C:/Demetra/plugins/xpath/lib/rt/xslt-rt.jar");
if (!rtClasspath.exists()) {
LOG.warn("Plugin's Runtime classes not found in " + rtClasspath.getAbsolutePath());
if (!(rtClasspath = new File(pluginPath, "classes")).exists()) {
if (ApplicationManagerEx.getApplicationEx().isInternal() && new File(pluginPath, "org").exists()) {
rtClasspath = pluginPath;
} else {
throw new CantRunException("Runtime classes not found");
}
}
parameters.getVMParametersList().prepend("-ea");
}
parameters.getClassPath().addTail(rtClasspath.getAbsolutePath());
parameters.setMainClass("org.intellij.plugins.xslt.run.rt.XSLTRunner");
if (isEmpty(myXsltRunConfiguration.myWorkingDirectory)) {
parameters.setWorkingDirectory(new File(myXsltRunConfiguration.getXsltFile()).getParentFile().getAbsolutePath());
} else {
parameters.setWorkingDirectory(expandPath(myXsltRunConfiguration.myWorkingDirectory, myXsltRunConfiguration.getEffectiveModule(), myXsltRunConfiguration.getProject()));
}
myExtensionData = new UserDataHolderBase();
final List<XsltRunnerExtension> extensions = XsltRunnerExtension.getExtensions(myXsltRunConfiguration, myIsDebugger);
for (XsltRunnerExtension extension : extensions) {
extension.patchParameters(parameters, myXsltRunConfiguration, myExtensionData);
}
parameters.setUseDynamicClasspath(JdkUtil.useDynamicClasspath(myXsltRunConfiguration.getProject()));
return parameters;
}
use of com.intellij.openapi.extensions.PluginId in project smali by JesusFreke.
the class ErrorReporter method submit.
@Override
public boolean submit(IdeaLoggingEvent[] events, String additionalInfo, Component parentComponent, final Consumer<SubmittedReportInfo> consumer) {
IdeaLoggingEvent event = events[0];
ErrorBean bean = new ErrorBean(event.getThrowable(), IdeaLogger.ourLastActionId);
final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
bean.setDescription(additionalInfo);
bean.setMessage(event.getMessage());
Throwable throwable = event.getThrowable();
if (throwable != null) {
final PluginId pluginId = IdeErrorsDialog.findPluginId(throwable);
if (pluginId != null) {
final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
bean.setPluginName(ideaPluginDescriptor.getName());
bean.setPluginVersion(ideaPluginDescriptor.getVersion());
}
}
}
Object data = event.getData();
if (data instanceof LogMessageEx) {
bean.setAttachments(((LogMessageEx) data).getAttachments());
}
Map<String, String> reportValues = ITNProxy.createParameters(bean);
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
Consumer<String> successCallback = new Consumer<String>() {
@Override
public void consume(String token) {
final SubmittedReportInfo reportInfo = new SubmittedReportInfo(null, "Issue " + token, SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
consumer.consume(reportInfo);
ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, "Submitted", NotificationType.INFORMATION, null).setImportant(false).notify(project);
}
};
Consumer<Exception> errorCallback = new Consumer<Exception>() {
@Override
public void consume(Exception e) {
String message = String.format("<html>There was an error while creating a GitHub issue: %s<br>" + "Please consider manually creating an issue on the " + "<a href=\"https://github.com/JesusFreke/smali/issues\">Smali Issue Tracker</a></html>", e.getMessage());
ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, message, NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(project);
}
};
GithubFeedbackTask task = new GithubFeedbackTask(project, "Submitting error report", true, reportValues, successCallback, errorCallback);
if (project == null) {
task.run(new EmptyProgressIndicator());
} else {
ProgressManager.getInstance().run(task);
}
return true;
}
use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.
the class BuildProcessClasspathManager method computeCompileServerPluginsClasspath.
private static List<String> computeCompileServerPluginsClasspath() {
final List<String> classpath = ContainerUtil.newArrayList();
for (CompileServerPlugin serverPlugin : CompileServerPlugin.EP_NAME.getExtensions()) {
final PluginId pluginId = serverPlugin.getPluginDescriptor().getPluginId();
final IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
LOG.assertTrue(plugin != null, pluginId);
final File baseFile = plugin.getPath();
if (baseFile.isFile()) {
classpath.add(baseFile.getPath());
} else if (baseFile.isDirectory()) {
for (String relativePath : StringUtil.split(serverPlugin.getClasspath(), ";")) {
final File jarFile = new File(new File(baseFile, "lib"), relativePath);
File classesDir = new File(baseFile, "classes");
if (jarFile.exists()) {
classpath.add(jarFile.getPath());
} else if (classesDir.isDirectory()) {
//'plugin run configuration': all module output are copied to 'classes' folder
classpath.add(classesDir.getPath());
} else {
//development mode: add directory out/classes/production/<jar-name> to classpath, assuming that jar-name is equal to module name
final String moduleName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(relativePath));
File baseOutputDir = baseFile.getParentFile();
if (baseOutputDir.getName().equals("test")) {
baseOutputDir = new File(baseOutputDir.getParentFile(), "production");
}
final File dir = new File(baseOutputDir, moduleName);
if (dir.exists()) {
classpath.add(dir.getPath());
} else {
//looks like <jar-name> refers to a library, try to find it under <plugin-dir>/lib
File pluginDir = getPluginDir(plugin);
if (pluginDir != null) {
File libraryFile = new File(pluginDir, "lib" + File.separator + PathUtil.getFileName(relativePath));
if (libraryFile.exists()) {
classpath.add(libraryFile.getPath());
} else {
LOG.error("Cannot add " + relativePath + " from '" + plugin.getName() + ' ' + plugin.getVersion() + "'" + " to external compiler classpath: library " + libraryFile.getAbsolutePath() + " not found");
}
} else {
LOG.error("Cannot add " + relativePath + " from '" + plugin.getName() + ' ' + plugin.getVersion() + "'" + " to external compiler classpath: home directory of plugin not found");
}
}
}
}
}
}
return classpath;
}
Aggregations