use of com.perl5.lang.perl.idea.configuration.settings.PerlSharedSettings in project Perl5-IDEA by Camelcade.
the class PerlParserTestBase method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
registerApplicationService(TemplateDataLanguageMappings.class, new TemplateDataLanguageMappings(getProject()));
registerApplicationService(TemplateDataLanguagePatterns.class, new TemplateDataLanguagePatterns());
addExplicitExtension(LanguageParserDefinitions.INSTANCE, PerlLanguage.INSTANCE, new PerlParserDefinition());
addExplicitExtension(LanguageParserDefinitions.INSTANCE, PodLanguage.INSTANCE, new PodParserDefinition());
registerComponentInstance(myProject, PerlNamesCache.class, new PerlNamesCache(myProject));
registerExtensionPoint(PerlParserExtension.EP_NAME, PerlParserExtension.class);
registerExtension(PerlParserExtension.EP_NAME, new MooseParserExtension());
registerExtension(PerlParserExtension.EP_NAME, new PerlSwitchParserExtensionImpl());
registerExtension(PerlParserExtension.EP_NAME, new ClassAccessorParserExtension());
registerExtension(PerlParserExtension.EP_NAME, new MojoParserExtension());
PerlParserExtensions parserExtensions = new PerlParserExtensions();
registerComponentInstance(ApplicationManager.getApplication(), PerlParserExtensions.class, parserExtensions);
parserExtensions.initComponent();
PerlPackageProcessorEP.EP.addExplicitExtension("constant", new ConstantProcessor());
PerlPackageProcessorEP.EP.addExplicitExtension("vars", new VarsProcessor());
PerlPackageProcessorEP.EP.addExplicitExtension("Exception::Class", new ExceptionClassProcessor());
myProject.registerService(PerlSharedSettings.class, new PerlSharedSettings(getProject()));
}
use of com.perl5.lang.perl.idea.configuration.settings.PerlSharedSettings in project Perl5-IDEA by Camelcade.
the class PerlCriticAnnotator method getPerlCriticExecutable.
protected GeneralCommandLine getPerlCriticExecutable(Project project) throws ExecutionException {
PerlSharedSettings sharedSettings = PerlSharedSettings.getInstance(project);
PerlLocalSettings localSettings = PerlLocalSettings.getInstance(project);
String executable = localSettings.PERL_CRITIC_PATH;
if (StringUtil.isEmpty(executable)) {
throw new ExecutionException("Path to Perl::Critic executable must be configured in perl settings");
}
GeneralCommandLine commandLine = new GeneralCommandLine(executable).withWorkDirectory(project.getBasePath());
if (StringUtil.isNotEmpty(sharedSettings.PERL_CRITIC_ARGS)) {
commandLine.addParameters(StringUtil.split(sharedSettings.PERL_CRITIC_ARGS, " "));
}
return commandLine;
}
use of com.perl5.lang.perl.idea.configuration.settings.PerlSharedSettings in project Perl5-IDEA by Camelcade.
the class PerlDeparseFileAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent event) {
PsiFile file = PerlActionUtil.getPsiFileFromEvent(event);
if (file == null) {
return;
}
final Document document = file.getViewProvider().getDocument();
if (document == null) {
return;
}
final Project project = file.getProject();
String deparseArgument = "-MO=Deparse";
PerlSharedSettings perl5Settings = PerlSharedSettings.getInstance(project);
if (StringUtil.isNotEmpty(perl5Settings.PERL_DEPARSE_ARGUMENTS)) {
deparseArgument += "," + perl5Settings.PERL_DEPARSE_ARGUMENTS;
}
GeneralCommandLine commandLine = PerlRunUtil.getPerlCommandLine(project, file.getVirtualFile(), deparseArgument);
if (commandLine == null) {
return;
}
commandLine.withWorkDirectory(project.getBasePath());
FileDocumentManager.getInstance().saveDocument(document);
try {
ProcessOutput processOutput = ExecUtil.execAndGetOutput(commandLine);
String deparsed = processOutput.getStdout();
String error = processOutput.getStderr();
if (StringUtil.isNotEmpty(error) && !StringUtil.contains(error, "syntax OK")) {
if (StringUtil.isEmpty(deparsed)) {
Notifications.Bus.notify(new Notification(PERL_DEPARSE_GROUP, PerlBundle.message("perl.action.error.notification.title"), error.replaceAll("\\n", "<br/>"), NotificationType.ERROR));
} else {
Notifications.Bus.notify(new Notification(PERL_DEPARSE_GROUP, PerlBundle.message("perl.action.success.notification.title"), PerlBundle.message("perl.action.success.notification.message", error.replaceAll("\\n", "<br/>")), NotificationType.INFORMATION));
}
}
if (StringUtil.isNotEmpty(deparsed)) {
VirtualFile newFile = new LightVirtualFile("Deparsed " + file.getName(), file.getFileType(), deparsed);
OpenFileAction.openFile(newFile, project);
}
} catch (ExecutionException e) {
Notifications.Bus.notify(new Notification(PERL_DEPARSE_GROUP, PerlBundle.message("perl.execution.error.notification.title"), e.getMessage().replaceAll("\\n", "<br/>"), NotificationType.ERROR));
}
}
use of com.perl5.lang.perl.idea.configuration.settings.PerlSharedSettings in project Perl5-IDEA by Camelcade.
the class PerlFormatWithPerlTidyAction method getPerlTidyCommandLine.
protected GeneralCommandLine getPerlTidyCommandLine(Project project) throws ExecutionException {
PerlSharedSettings sharedSettings = PerlSharedSettings.getInstance(project);
PerlLocalSettings localSettings = PerlLocalSettings.getInstance(project);
String executable = localSettings.PERL_TIDY_PATH;
if (StringUtil.isEmpty(executable)) {
throw new ExecutionException(PerlBundle.message("perl.action.perl.tidy.execution.exception"));
}
GeneralCommandLine commandLine = new GeneralCommandLine(executable, "-st", "-se").withWorkDirectory(project.getBasePath());
if (StringUtil.isNotEmpty(sharedSettings.PERL_TIDY_ARGS)) {
commandLine.addParameters(StringUtil.split(sharedSettings.PERL_TIDY_ARGS, " "));
}
return commandLine;
}
use of com.perl5.lang.perl.idea.configuration.settings.PerlSharedSettings in project Perl5-IDEA by Camelcade.
the class PerlSwitchLiveTemplatesTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
PerlSharedSettings settings = PerlSharedSettings.getInstance(getProject());
boolean value = settings.PERL_SWITCH_ENABLED;
addTearDownListener(() -> settings.PERL_SWITCH_ENABLED = value);
settings.PERL_SWITCH_ENABLED = true;
}
Aggregations