functionport.java
来自「plugin for eclipse」· Java 代码 · 共 81 行
JAVA
81 行
/*
* Created on Jun 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.common.CodeLocation;
import isis.anp.common.ObjectTreeBuilderContext;
import isis.anp.common.ParserMessage;
import isis.anp.nesc.ot.types.FunctionType;
/**
* @author sallai
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class FunctionPort extends Port {
FunctionDeclaration functionDeclaration;
ObjectTreeBuilderContext ctx;
public FunctionPort(ObjectTreeBuilderContext ctx) {
this.ctx = ctx;
}
/* (non-Javadoc)
* @see parser.nesc.ot.Port#getPortName()
*/
public String getPortName() {
return getName();
}
public void setDeclaration(Declaration decln) {
if(decln instanceof FunctionDeclaration) {
functionDeclaration = (FunctionDeclaration) decln;
if(functionDeclaration.getNameNode()!=null) {
this.setNameNode(functionDeclaration.getNameNode());
}
} else {
TypeResolutionException tre = new TypeResolutionException("Port is not an interface nor a function declaration", decln.getDefNode());
ctx.addMsg(new ParserMessage(ParserMessage.ERROR, tre.getMessage(), new CodeLocation( decln.getDefNode()), tre));
}
}
public void outline(Outline o) {
o.addTabs();
if (direction == Port.Direction.USES) {
o.append("uses");
o.ensureSpace();
} else {
o.append("provides");
o.ensureSpace();
}
int tabs = o.getTabs();
o.setTabs(0);
functionDeclaration.outline(o);
o.append(';');
o.setTabs(tabs);
}
public String getTypeString() {
if(this.functionDeclaration == null) return null;
if(this.functionDeclaration.getType()==null) return null;
if(!(this.functionDeclaration.getType() instanceof FunctionType)) return null;
FunctionType t = (FunctionType)(this.functionDeclaration.getType());
// FIXME: this is a hack... types should be able to check for compatibility
Outline o = new Outline();
t.outline(o);
String typeString = o.toString();
// System.out.println("Type string is: " + typeString);
return typeString;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?