functiondefinition.java

来自「plugin for eclipse」· Java 代码 · 共 106 行

JAVA
106
字号
/*
 * Created on May 9, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package isis.anp.nesc.ot;

import isis.anp.nesc.ot.types.FunctionType;
import isis.anp.nesc.tinydoc.TinyDoc;

import java.util.Iterator;


/**
 * @author sallai
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class FunctionDefinition extends FunctionDeclaration {
	CompoundStatement body;

	public FunctionDefinition() {
	    super();
	}
	
	public FunctionDefinition(FunctionDeclaration fcnDecl) {
	    super(fcnDecl);
	}
	
	/**
	 * @param csObj
	 */
	public void setBody(CompoundStatement csObj) {
		body = csObj;
		
	}
	
	public void outline(Outline o) {
//		String doc = getTinyDocText();
	    String doc = null;
	    TinyDoc tinyDoc = getTinyDoc();
	    if(tinyDoc !=null) doc = tinyDoc.toString();
		if(doc!=null) { 
		    o.addTabs();
		    o.append(doc);
		    o.addNewLine();
		}
	    
		o.addTabs();
		
		if(getDefNode()!=null) {
//		    o.append("/* "+getDefNode().getFileName()+":"+getDefNode().getLine()+":"+getDefNode().getColumn()+" */>");
		} else {
		    o.append("/* -*-*-*-*-*-*-*-* DEFNODE IS NULL  */");
		}
		o.ensureSpace();
		
		
		Iterator i = storageClassSpecifiers.iterator();
		while (i.hasNext()) {
			StorageClassSpecifier scs = (StorageClassSpecifier) i.next();
			o.append(scs.getDefNode().getText());
			o.append(" ");
		}
		
		if(getType()!=null && getType() instanceof FunctionType) {
			FunctionType ft = (FunctionType)getType();
			ft.getEnclosedType().outline(o);
			o.ensureSpace();
			if(interfacePort!=null) {
				o.append(interfacePort.getName());
				o.append(".");
			}			
			o.append(getName());
			o.ensureSpace();
			o.append("(");	
			o.ensureSpace();
			ft.getParameterTypeList().outline(o);
			o.ensureSpace();
			o.append(")");
			
			Iterator j = getAttributeList().iterator();
			while (j.hasNext()) {
				Attribute a = (Attribute) j.next();
				o.ensureSpace();
				a.outline(o);
			}
			
			o.addNewLine();
			
			body.outline(o);
			
		} else {
			o.append("/* Error: not a function */");
		}
	}	
    /**
     * @return Returns the body.
     */
    public CompoundStatement getBody() {
        return body;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?