mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
"ant" task support
This commit is contained in:
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2010 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.intellij.lang.ant.dom;
|
||||||
|
|
||||||
|
import com.intellij.util.xml.ConvertContext;
|
||||||
|
import com.intellij.util.xml.Converter;
|
||||||
|
import com.intellij.util.xml.GenericAttributeValue;
|
||||||
|
import org.jetbrains.annotations.NonNls;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Eugene Zhuravlev
|
||||||
|
* Date: Aug 3, 2010
|
||||||
|
*/
|
||||||
|
public class AntBooleanConverter extends Converter<Boolean> {
|
||||||
|
public final Boolean DEFAULT_VALUE;
|
||||||
|
|
||||||
|
public AntBooleanConverter() {
|
||||||
|
DEFAULT_VALUE = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AntBooleanConverter(boolean defaultValue) {
|
||||||
|
DEFAULT_VALUE = Boolean.valueOf(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean fromString(@Nullable @NonNls String s, ConvertContext context) {
|
||||||
|
if (s == null || s.length() == 0) {
|
||||||
|
return DEFAULT_VALUE;
|
||||||
|
}
|
||||||
|
return "true".equalsIgnoreCase(s) || "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(@Nullable Boolean aBoolean, ConvertContext context) {
|
||||||
|
final GenericAttributeValue attribValue = context.getInvocationElement().getParentOfType(GenericAttributeValue.class, false);
|
||||||
|
if (attribValue == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return attribValue.getRawText();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2010 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.intellij.lang.ant.dom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Eugene Zhuravlev
|
||||||
|
* Date: Aug 3, 2010
|
||||||
|
*/
|
||||||
|
public class AntBooleanConverterDefaultFalse extends AntBooleanConverter {
|
||||||
|
|
||||||
|
public AntBooleanConverterDefaultFalse() {
|
||||||
|
super(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2010 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.intellij.lang.ant.dom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Eugene Zhuravlev
|
||||||
|
* Date: Aug 3, 2010
|
||||||
|
*/
|
||||||
|
public class AntBooleanConverterDefaultTrue extends AntBooleanConverter {
|
||||||
|
|
||||||
|
public AntBooleanConverterDefaultTrue() {
|
||||||
|
super(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2010 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.intellij.lang.ant.dom;
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiFileSystemItem;
|
||||||
|
import com.intellij.util.xml.Attribute;
|
||||||
|
import com.intellij.util.xml.Convert;
|
||||||
|
import com.intellij.util.xml.GenericAttributeValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Eugene Zhuravlev
|
||||||
|
* Date: Aug 3, 2010
|
||||||
|
*/
|
||||||
|
public abstract class AntDomAnt extends AntDomElement {
|
||||||
|
|
||||||
|
@Attribute("antfile")
|
||||||
|
@Convert(value = AntPathConverter.class)
|
||||||
|
public abstract GenericAttributeValue<PsiFileSystemItem> getAntFilePath();
|
||||||
|
|
||||||
|
@Attribute("dir")
|
||||||
|
@Convert(value = AntPathConverter.class)
|
||||||
|
public abstract GenericAttributeValue<PsiFileSystemItem> getAntFileDir();
|
||||||
|
|
||||||
|
@Attribute("target")
|
||||||
|
public abstract GenericAttributeValue<String> getDefaultTarget();
|
||||||
|
|
||||||
|
@Attribute("output")
|
||||||
|
@Convert(value = AntPathConverter.class)
|
||||||
|
public abstract GenericAttributeValue<PsiFileSystemItem> getOutputtFileName();
|
||||||
|
|
||||||
|
@Attribute("inheritAll")
|
||||||
|
@Convert(value = AntBooleanConverterDefaultTrue.class)
|
||||||
|
public abstract GenericAttributeValue<Boolean> isInheritAllProperties();
|
||||||
|
|
||||||
|
@Attribute("inheritRefs")
|
||||||
|
@Convert(value = AntBooleanConverterDefaultFalse.class)
|
||||||
|
public abstract GenericAttributeValue<Boolean> isInheritRefsProperties();
|
||||||
|
|
||||||
|
@Attribute("useNativeBasedir")
|
||||||
|
@Convert(value = AntBooleanConverterDefaultFalse.class)
|
||||||
|
public abstract GenericAttributeValue<Boolean> isUseNativeBasedir();
|
||||||
|
}
|
||||||
@@ -51,6 +51,7 @@ public class AntDomExtender extends DomExtender<AntDomElement>{
|
|||||||
TAG_MAPPING.put("macrodef", AntDomMacroDef.class);
|
TAG_MAPPING.put("macrodef", AntDomMacroDef.class);
|
||||||
TAG_MAPPING.put("scriptdef", AntDomScriptDef.class);
|
TAG_MAPPING.put("scriptdef", AntDomScriptDef.class);
|
||||||
TAG_MAPPING.put("antlib", AntDomAntlib.class);
|
TAG_MAPPING.put("antlib", AntDomAntlib.class);
|
||||||
|
TAG_MAPPING.put("ant", AntDomAnt.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerExtensions(@NotNull AntDomElement antDomElement, @NotNull DomExtensionsRegistrar registrar) {
|
public void registerExtensions(@NotNull AntDomElement antDomElement, @NotNull DomExtensionsRegistrar registrar) {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class AntDomFileReferenceSet extends FileReferenceSet {
|
|||||||
}
|
}
|
||||||
return FileUtil.isAbsolute(pathString);
|
return FileUtil.isAbsolute(pathString);
|
||||||
}
|
}
|
||||||
// todo: correct context for "output" attribute file reference of the "ant" task
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Collection<PsiFileSystemItem> computeDefaultContexts() {
|
public Collection<PsiFileSystemItem> computeDefaultContexts() {
|
||||||
final AntDomElement element = myValue.getParentOfType(AntDomElement.class, false);
|
final AntDomElement element = myValue.getParentOfType(AntDomElement.class, false);
|
||||||
@@ -109,15 +109,25 @@ public class AntDomFileReferenceSet extends FileReferenceSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final String basedir;
|
|
||||||
if (element instanceof AntDomIncludingDirective) {
|
if (element instanceof AntDomAnt) {
|
||||||
basedir = containingProject.getContainingFileDir();
|
final PsiFileSystemItem dirValue = ((AntDomAnt)element).getAntFileDir().getValue();
|
||||||
|
if (dirValue instanceof PsiDirectory) {
|
||||||
|
root = dirValue.getVirtualFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
basedir = containingProject.getContextAntProject().getProjectBasedirPath();
|
if (root == null) {
|
||||||
|
final String basedir;
|
||||||
|
if (element instanceof AntDomIncludingDirective) {
|
||||||
|
basedir = containingProject.getContainingFileDir();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
basedir = containingProject.getContextAntProject().getProjectBasedirPath();
|
||||||
|
}
|
||||||
|
assert basedir != null;
|
||||||
|
root = LocalFileSystem.getInstance().findFileByPath(basedir);
|
||||||
}
|
}
|
||||||
assert basedir != null;
|
|
||||||
root = LocalFileSystem.getInstance().findFileByPath(basedir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user