use of com.intellij.lang.ant.config.AntConfigurationBase in project intellij-community by JetBrains.
the class AntDomElement method getContextAntProject.
public final AntDomProject getContextAntProject() {
final AntConfigurationBase antConfig = AntConfigurationBase.getInstance(getManager().getProject());
final XmlElement xmlElement = getXmlElement();
if (xmlElement == null) {
return getAntProject();
}
PsiFile containingFile = xmlElement.getContainingFile();
if (containingFile != null) {
containingFile = containingFile.getOriginalFile();
}
if (!(containingFile instanceof XmlFile)) {
return getAntProject();
}
final XmlFile contextFile = antConfig.getEffectiveContextFile(((XmlFile) containingFile));
if (contextFile == null) {
return getAntProject();
}
return AntSupport.getAntDomProject(contextFile);
}
use of com.intellij.lang.ant.config.AntConfigurationBase in project intellij-community by JetBrains.
the class AntHectorConfigurable method createComponent.
public JComponent createComponent() {
final JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(IdeBorderFactory.createTitledBorder("File Context", false));
myCombo = new ComboBox();
myCombo.putClientProperty(CONTEXTS_COMBO_KEY, Boolean.TRUE);
panel.add(new JLabel("Included into:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(5, 0), 0, 0));
panel.add(myCombo, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insets(5, 5, 5, 0), 0, 0));
final PsiManager psiManager = PsiManager.getInstance(myProject);
final FileBasedIndex fbi = FileBasedIndex.getInstance();
final Collection<VirtualFile> antFiles = fbi.getContainingFiles(AntImportsIndex.INDEX_NAME, AntImportsIndex.ANT_FILES_WITH_IMPORTS_KEY, myFileFilter);
for (VirtualFile file : antFiles) {
final PsiFile psiFile = psiManager.findFile(file);
if (!(psiFile instanceof XmlFile)) {
continue;
}
final XmlFile xmlFile = (XmlFile) psiFile;
if (!xmlFile.equals(myFile) && AntDomFileDescription.isAntFile(xmlFile)) {
final String path = PathUtil.getLocalPath(file);
final XmlFile previous = myPathToFileMap.put(path, xmlFile);
assert previous == null;
}
}
final List<String> paths = new ArrayList<>(myPathToFileMap.keySet());
Collections.sort(paths, (o1, o2) -> o1.compareTo(o2));
myCombo.addItem(NONE);
for (String path : paths) {
myCombo.addItem(path);
}
final AntConfigurationBase antConfig = AntConfigurationBase.getInstance(myProject);
final XmlFile currentContext = antConfig.getContextFile(myFile);
if (currentContext != null) {
final VirtualFile vFile = currentContext.getVirtualFile();
assert vFile != null;
final String path = PathUtil.getLocalPath(vFile);
if (!FileUtil.pathsEqual(path, myLocalPath)) {
myOriginalContext = path;
}
}
myCombo.setSelectedItem(myOriginalContext);
return panel;
}
use of com.intellij.lang.ant.config.AntConfigurationBase in project intellij-community by JetBrains.
the class AntToolwindowRegistrar method projectOpened.
@Override
public void projectOpened() {
final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
final String prefix = AntConfiguration.getActionIdPrefix(myProject);
final ActionManager actionManager = ActionManager.getInstance();
for (Keymap keymap : keymapManager.getAllKeymaps()) {
for (String id : keymap.getActionIdList()) {
if (id.startsWith(prefix) && actionManager.getAction(id) == null) {
actionManager.registerAction(id, new TargetActionStub(id, myProject));
}
}
}
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
compilerManager.addBeforeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
final AntConfiguration config = AntConfiguration.getInstance(myProject);
((AntConfigurationBase) config).ensureInitialized();
return config.executeTargetBeforeCompile(createDataContext(context));
}
});
compilerManager.addAfterTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
final AntConfigurationBase config = (AntConfigurationBase) AntConfiguration.getInstance(myProject);
config.ensureInitialized();
if (context.getMessageCount(CompilerMessageCategory.ERROR) > 0) {
final AntBuildTarget target = config.getTargetForEvent(ExecuteAfterCompilationEvent.getInstance());
if (target != null) {
context.addMessage(CompilerMessageCategory.INFORMATION, "Skipping ant target \"" + target.getDisplayName() + "\" because of compilation errors", null, -1, -1);
}
return true;
}
return config.executeTargetAfterCompile(createDataContext(context));
}
});
}
use of com.intellij.lang.ant.config.AntConfigurationBase in project intellij-community by JetBrains.
the class AntDomProject method getAntInstallation.
public AntInstallation getAntInstallation() {
final AntConfigurationBase configuration = AntConfigurationBase.getInstance(getXmlTag().getProject());
AntInstallation antInstallation = null;
if (configuration != null) {
antInstallation = configuration.getProjectDefaultAnt();
}
if (antInstallation == null) {
antInstallation = GlobalAntConfiguration.getInstance().getBundledAnt();
}
assert antInstallation != null;
return antInstallation;
}
Aggregations