blob: ba228c530d66eca9845293a6ab32044514542c8e [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ant.internal.ui.model;
import java.io.File;
import org.apache.tools.ant.Task;
import org.eclipse.ant.internal.ui.editor.AntEditorCompletionProcessor;
import org.xml.sax.Attributes;
public class AntAntNode extends AntTaskNode {
private String fFile;
public AntAntNode(Task task, Attributes attributes) {
super(task);
StringBuffer label= new StringBuffer("ant "); //$NON-NLS-1$
fFile= attributes.getValue(IAntModelConstants.ATTR_DIR);
if (fFile != null) {
label.append(fFile);
label.append(File.separatorChar);
}
String fileName = attributes.getValue(IAntModelConstants.ATTR_ANT_FILE);
if (fileName == null) {
fileName= "build.xml"; //$NON-NLS-1$
}
label.append(fileName);
fFile+=File.separatorChar + fileName;
String more = attributes.getValue(IAntModelConstants.ATTR_TARGET);
if(more != null) {
label.append(' ');
label.append(more);
}
setBaseLabel(label.toString());
}
/* (non-Javadoc)
* @see org.eclipse.ant.internal.ui.model.AntElementNode#getReferencedElement(int)
*/
public String getReferencedElement(int offset) {
if (fFile != null) {
String textToSearch= getAntModel().getText(getOffset(), offset - getOffset());
String attributeString = AntEditorCompletionProcessor.getAttributeStringFromDocumentStringToPrefix(textToSearch);
if (IAntModelConstants.ATTR_ANT_FILE.equals(attributeString)) {
return fFile;
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.ant.internal.ui.model.AntTaskNode#checkAttributeAgainstModifiedIdentifier(java.lang.String)
*/
protected boolean checkAttributeAgainstModifiedIdentifier(String key) {
if (key.equals("target")) { //$NON-NLS-1$
return false;
}
return true;
}
}