use of org.eclipse.titan.designer.editors.T3Doc in project titan.EclipsePlug-ins by eclipse.
the class ASTNode method getT3Doc.
// FIXME: this does not belong here, ASTNodes in general don't have comments
public T3Doc getT3Doc(final Location location) {
if (this instanceof Def_ModulePar) {
final String st1 = this.getFullName().toString();
final String st = st1.substring(st1.lastIndexOf('.') + 1);
return new T3Doc(this.getCommentLocation(), st);
}
if (this.getCommentLocation() != null) {
return new T3Doc(this.getCommentLocation());
}
if (this instanceof ILocateableNode) {
final ILocateableNode iloc = (ILocateableNode) this;
// ToDo check scopes that do not matter
final Scope scope = this.getMyScope();
final Assignment assignment = scope.getModuleScope().getEnclosingAssignment(iloc.getLocation().getOffset());
if (assignment == null || assignment == this || assignment.getMyScope() instanceof Definitions) {
return null;
}
final T3Doc parentT3doc = assignment.getT3Doc(location);
if (parentT3doc != null) {
// if it is a type assignment/definition then detect if we are in a field
if (assignment.getAssignmentType() == Assignment_type.A_TYPE) {
final IType type = assignment.getType(CompilationTimeStamp.getBaseTimestamp());
if (type == null) {
return null;
}
// Reference finder - wonderful
final ReferenceFinder rf = new ReferenceFinder(assignment);
rf.scope = this.getMyScope().getModuleScope().getSmallestEnclosingScope(iloc.getLocation().getOffset());
rf.type = assignment.getType(CompilationTimeStamp.getBaseTimestamp());
type.getEnclosingField(location.getOffset(), rf);
String st = null;
if (rf.fieldId != null) {
st = rf.fieldId.getDisplayName();
} else {
final String st1 = this.getFullName().toString();
st = st1.substring(st1.lastIndexOf('.') + 1);
}
// Get member information if available
if (parentT3doc.getMembers() != null) {
final String desc = parentT3doc.getMembers().get(st);
if (desc != null) {
return new T3Doc(desc);
}
}
} else if (assignment.getAssignmentType() == Assignment_type.A_TEMPLATE) {
final String st1 = this.getFullName().toString();
final String st = st1.substring(st1.lastIndexOf('.') + 1);
String desc = null;
if (parentT3doc.getMembers() != null) {
desc = parentT3doc.getMembers().get(st);
}
if (parentT3doc.getParams() != null) {
desc = parentT3doc.getParams().get(st);
}
if (desc != null) {
return new T3Doc(desc);
}
} else if (assignment.getAssignmentType() == Assignment_type.A_FUNCTION || assignment.getAssignmentType() == Assignment_type.A_FUNCTION_RTEMP || assignment.getAssignmentType() == Assignment_type.A_FUNCTION_RVAL) {
final String st1 = this.getFullName().toString();
final String st = st1.substring(st1.lastIndexOf('.') + 1);
if (parentT3doc.getParams() != null) {
final String desc = parentT3doc.getParams().get(st);
if (desc != null) {
return new T3Doc(desc);
}
}
}
}
}
return null;
}
Aggregations