1 11 package org.eclipse.ant.internal.ui.model; 12 13 import java.io.File ; 14 15 import org.apache.tools.ant.Task; 16 import org.apache.tools.ant.util.FileUtils; 17 import org.eclipse.ant.internal.ui.editor.AntEditorCompletionProcessor; 18 import org.xml.sax.Attributes ; 19 20 public class AntAntNode extends AntTaskNode { 21 22 private String fFile; 23 24 public AntAntNode(Task task, Attributes attributes) { 25 super(task); 26 StringBuffer label= new StringBuffer ("ant "); fFile= attributes.getValue(IAntModelConstants.ATTR_DIR); 28 if (fFile != null) { 29 if (!FileUtils.isAbsolutePath(fFile)) { 30 File basedir= task.getProject().getBaseDir(); 31 if (basedir != null) { 32 fFile= basedir.getAbsolutePath() + File.separatorChar + fFile; 33 } 34 } 35 label.append(fFile); 36 label.append(File.separatorChar); 37 } else { 38 File basedir= task.getProject().getBaseDir(); 39 if (basedir != null) { 40 fFile=basedir.getAbsolutePath(); 41 } 42 } 43 String fileName = attributes.getValue(IAntModelConstants.ATTR_ANT_FILE); 44 if (fileName == null) { 45 fileName= "build.xml"; } 47 label.append(fileName); 48 if (fFile == null || FileUtils.isAbsolutePath(fileName)) { 49 fFile= fileName; 50 } else { 51 fFile+=File.separatorChar + fileName; 52 } 53 54 String more = attributes.getValue(IAntModelConstants.ATTR_TARGET); 55 if(more != null) { 56 label.append(' '); 57 label.append(more); 58 } 59 setBaseLabel(label.toString()); 60 } 61 62 65 public String getReferencedElement(int offset) { 66 if (fFile != null) { 67 String textToSearch= getAntModel().getText(getOffset(), offset - getOffset()); 68 if (textToSearch != null && textToSearch.length() != 0) { 69 String attributeString = AntEditorCompletionProcessor.getAttributeStringFromDocumentStringToPrefix(textToSearch); 70 if (IAntModelConstants.ATTR_ANT_FILE.equals(attributeString)) { 71 return fFile; 72 } 73 } 74 } 75 return null; 76 } 77 } 78 | Popular Tags |