use of org.eclipse.titan.designer.parsers.CompilationTimeStamp in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclaration method doOpenDeclaration.
private final void doOpenDeclaration() {
if (targetEditor == null || !(targetEditor instanceof TTCN3Editor)) {
return;
}
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null);
IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(FILENOTIDENTIFIABLE);
return;
}
if (!TITANNature.hasTITANNature(file.getProject())) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(TITANNature.NO_TITAN_FILE_NATURE_FOUND);
return;
}
if (ResourceExclusionHelper.isExcluded(file)) {
MessageDialog.openError(null, "Open Declaration does not work within excluded resources", "This module is excluded from build. To use the Open Declaration " + "feature please click on the 'Toggle exclude from build state' in the context menu of the Project Explorer. ");
return;
}
IPreferencesService prefs = Platform.getPreferencesService();
boolean reportDebugInformation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
int offset;
if (selection instanceof TextSelection && !selection.isEmpty() && !"".equals(((TextSelection) selection).getText())) {
if (reportDebugInformation) {
TITANDebugConsole.println("text selected: " + ((TextSelection) selection).getText());
}
TextSelection tSelection = (TextSelection) selection;
offset = tSelection.getOffset() + tSelection.getLength();
} else {
offset = ((TTCN3Editor) targetEditor).getCarretOffset();
}
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
final Module module = projectSourceParser.containedModule(file);
if (module == null) {
if (reportDebugInformation) {
TITANDebugConsole.println("The file " + file.getLocation() + "does not seem to contain a valid module.");
CompilationTimeStamp timestamp = projectSourceParser.getLastTimeChecked();
if (timestamp == null) {
TITANDebugConsole.println("The project " + file.getProject() + " was not yet analyzed semantically");
} else {
TITANDebugConsole.println("The project " + file.getProject() + " was last checked in " + projectSourceParser.getLastTimeChecked().toString());
}
}
return;
}
IdentifierFinderVisitor visitor = new IdentifierFinderVisitor(offset);
module.accept(visitor);
final Declaration decl = visitor.getReferencedDeclaration();
if (decl == null) {
if (reportDebugInformation) {
TITANDebugConsole.println("No visible elements found");
}
return;
}
selectAndRevealDeclaration(decl.getIdentifier().getLocation());
return;
}
use of org.eclipse.titan.designer.parsers.CompilationTimeStamp in project titan.EclipsePlug-ins by eclipse.
the class SpecialASN1Module method createSpecAsss.
/**
* Creates the special assignments by parsing the strings as if they
* were coming from an internal file and creating a module around them.
*
* @return the module of the special assignments created.
*/
private static ASN1Module createSpecAsss() {
if (null != specialAssignmentsModule) {
return specialAssignmentsModule;
}
final ASN1Assignments parsedAssignments = new ASN1Assignments();
ASN1Assignment actualAssignment;
for (String[] assignment : INTERNAL_ASSIGNMENTS) {
actualAssignment = SpecialASN1Module.parseSpecialInternalAssignment(assignment[1], new Identifier(Identifier_type.ID_ASN, assignment[0]));
parsedAssignments.addAssignment(actualAssignment);
}
// null as a project might not be a good idea
specialAssignmentsModule = new ASN1Module(new Identifier(Identifier_type.ID_ASN, INTERNAL_MODULE), null, Tag_types.AUTOMATIC_TAGS, false);
specialAssignmentsModule.setExports(new Exports(true));
specialAssignmentsModule.setImports(new Imports());
specialAssignmentsModule.setAssignments(parsedAssignments);
specialAssignmentsModule.setLocation(NULL_Location.INSTANCE);
specialAssignmentsModule.setScopeName(INTERNAL_MODULE);
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
final ModuleImportationChain referenceChain = new ModuleImportationChain(ModuleImportationChain.CIRCULARREFERENCE, false);
specialAssignmentsModule.checkImports(timestamp, referenceChain, new ArrayList<Module>());
specialAssignmentsModule.check(timestamp);
return specialAssignmentsModule;
}
use of org.eclipse.titan.designer.parsers.CompilationTimeStamp in project titan.EclipsePlug-ins by eclipse.
the class Def_Type_Visit_Handler method handleDefTypeNodes.
public void handleDefTypeNodes(IVisitableNode node) {
Def_Type typeNode = (Def_Type) node;
CompilationTimeStamp compilationCounter = CompilationTimeStamp.getNewCompilationCounter();
myASTVisitor.currentFileName = typeNode.getIdentifier().toString();
Type type = typeNode.getType(compilationCounter);
if (type.getTypetype().equals(TYPE_TTCN3_SEQUENCE)) {
// record
Def_Type_Record_Writer recordNode = new Def_Type_Record_Writer(typeNode);
// add component fields
recordNode.add(compFieldTypes, compFieldNames);
String[] typeArray = (String[]) compFieldTypes.toArray(new String[compFieldTypes.size()]);
String[] nameArray = (String[]) compFieldNames.toArray(new String[compFieldNames.size()]);
myASTVisitor.nodeNameChildrenTypesHashMap.put(parentName, typeArray);
myASTVisitor.nodeNameChildrenNamesHashMap.put(parentName, nameArray);
compFieldTypes.clear();
compFieldNames.clear();
myASTVisitor.visualizeNodeToJava(recordNode.getJavaSource());
} else if (type.getTypetype().equals(TYPE_TTCN3_SET)) {
// set
Def_Type_Set_Writer setNode = new Def_Type_Set_Writer(typeNode);
// add component fields
setNode.add(compFieldTypes, compFieldNames);
String[] typeArray = (String[]) compFieldTypes.toArray(new String[compFieldTypes.size()]);
String[] nameArray = (String[]) compFieldNames.toArray(new String[compFieldNames.size()]);
myASTVisitor.nodeNameChildrenTypesHashMap.put(parentName, typeArray);
myASTVisitor.nodeNameChildrenNamesHashMap.put(parentName, nameArray);
compFieldTypes.clear();
compFieldNames.clear();
myASTVisitor.visualizeNodeToJava(setNode.getJavaSource());
} else if (type.getTypetype().equals(TYPE_TTCN3_CHOICE)) {
// union
Def_Type_Union_Writer union_writer = new Def_Type_Union_Writer(typeNode);
// add component fields
union_writer.add(compFieldTypes, compFieldNames);
String[] typeArray = compFieldTypes.toArray(new String[compFieldTypes.size()]);
String[] nameArray = compFieldNames.toArray(new String[compFieldNames.size()]);
myASTVisitor.nodeNameChildrenTypesHashMap.put(parentName, typeArray);
myASTVisitor.nodeNameChildrenNamesHashMap.put(parentName, nameArray);
compFieldTypes.clear();
compFieldNames.clear();
myASTVisitor.visualizeNodeToJava(union_writer.getJavaSource());
} else if (type instanceof Integer_Type) {
Def_Type_Integer_Writer integerNode = Def_Type_Integer_Writer.getInstance(typeNode);
integerNode.clearLists();
myASTVisitor.visualizeNodeToJava(integerNode.getJavaSource());
} else if (type instanceof CharString_Type) {
Def_Type_Charstring_Writer charstringNode = Def_Type_Charstring_Writer.getInstance(typeNode);
charstringNode.clearLists();
charstringNode.addCharStringValue(charstringValue);
charstringValue = null;
myASTVisitor.visualizeNodeToJava(charstringNode.getJavaSource());
} else if (type instanceof TTCN3_Enumerated_Type) {
Def_Type_Enum_Writer enumTypeNode = Def_Type_Enum_Writer.getInstance(typeNode);
enumTypeNode.clearLists();
enumTypeNode.enumItems.addAll(enumItems);
enumTypeNode.enumItemValues.addAll(enumItemValues);
enumItemValues.clear();
enumItems.clear();
myASTVisitor.visualizeNodeToJava(enumTypeNode.getJavaSource());
} else if (type.getTypetype().equals(TYPE_SET_OF)) {
Def_Type_Set_Of_Writer setOfNode = new Def_Type_Set_Of_Writer(typeNode);
setOfNode.setFieldType(setOfFieldType);
setOfFieldType = null;
myASTVisitor.visualizeNodeToJava(setOfNode.getJavaSource());
} else if (type.getTypetype().equals(TYPE_SEQUENCE_OF)) {
Def_Type_Record_Of_Writer writer = new Def_Type_Record_Of_Writer(typeNode);
writer.setFieldType(recordOfFieldType);
myASTVisitor.visualizeNodeToJava(writer.getJavaSource());
} else if (type.getTypetype().equals(TYPE_PORT)) {
Def_Type_Port_Writer portNode = Def_Type_Port_Writer.getInstance(typeNode);
portNode.clearLists();
portNode.inMessageName.addAll(inMessageName);
portNode.outMessageName.addAll(outMessageName);
portNode.inOutMessageName.addAll(inOutMessageName);
portNode.setPortTypeAReferencedType(isPortTypeAReferencedType);
waitingForPortAttriburtes = false;
isPortTypeAReferencedType = false;
inMessageName.clear();
outMessageName.clear();
inOutMessageName.clear();
myASTVisitor.visualizeNodeToJava(portNode.getJavaSource());
} else if (type.getTypetype().equals(TYPE_COMPONENT)) {
Def_Type_Component_Writer compNode = Def_Type_Component_Writer.getInstance(typeNode);
compNode.clearLists();
// add component fields
compNode.compFieldPortTypes.addAll(componentPortTypes);
compNode.compFieldPortNames.addAll(componentPortNames);
compNode.compFieldVarTypes.addAll(componentVarTypes);
compNode.compFieldVarNames.addAll(componentVarNames);
componentPortTypes.clear();
componentPortNames.clear();
componentVarTypes.clear();
componentVarNames.clear();
waitForCompReference = false;
myASTVisitor.visualizeNodeToJava(compNode.getJavaSource());
}
parentName = null;
}
use of org.eclipse.titan.designer.parsers.CompilationTimeStamp in project titan.EclipsePlug-ins by eclipse.
the class RunsOnScopeReduction method process.
@Override
protected void process(IVisitableNode node, Problems problems) {
final Set<Identifier> definitions = new HashSet<Identifier>();
final Identifier componentIdentifier;
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
final Identifier identifier;
boolean isTestCase = false;
if (node instanceof Def_Function) {
final Def_Function variable = (Def_Function) node;
final Component_Type componentType = variable.getRunsOnType(timestamp);
if (componentType == null) {
return;
}
componentIdentifier = componentType.getComponentBody().getIdentifier();
identifier = variable.getIdentifier();
} else if (node instanceof Def_Altstep) {
final Def_Altstep variable = (Def_Altstep) node;
final Component_Type componentType = variable.getRunsOnType(timestamp);
if (componentType == null) {
return;
}
componentIdentifier = componentType.getComponentBody().getIdentifier();
identifier = variable.getIdentifier();
} else {
final Def_Testcase variable = (Def_Testcase) node;
final Component_Type componentType = variable.getRunsOnType(timestamp);
if (componentType == null) {
return;
}
componentIdentifier = componentType.getComponentBody().getIdentifier();
identifier = variable.getIdentifier();
isTestCase = true;
}
final ReferenceCheck chek = new ReferenceCheck();
node.accept(chek);
definitions.addAll(chek.getIdentifiers());
if (definitions.isEmpty()) {
if (isTestCase) {
problems.report(identifier.getLocation(), MessageFormat.format("The runs on component `{0}'' seems to be never used. Use empty component.", componentIdentifier.getDisplayName()));
} else {
problems.report(identifier.getLocation(), MessageFormat.format("The runs on component `{0}'' seems to be never used, can be removed.", componentIdentifier.getDisplayName()));
}
} else if (!definitions.contains(componentIdentifier)) {
ArrayList<Identifier> list = new ArrayList<Identifier>(definitions);
if (definitions.size() == 1) {
problems.report(identifier.getLocation(), MessageFormat.format("The runs on component `{0}'' seems to be never used. Use `{1}'' component.", componentIdentifier.getName(), list.get(0).getDisplayName()));
} else {
// FIXME: implement other cases
problems.report(identifier.getLocation(), MessageFormat.format("The runs on component `{0}'' seems to be never used.", componentIdentifier.getDisplayName()));
}
}
}
use of org.eclipse.titan.designer.parsers.CompilationTimeStamp in project titan.EclipsePlug-ins by eclipse.
the class UnusedStartedFuncRetVal method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof Start_Component_Statement) {
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
final Start_Component_Statement s = (Start_Component_Statement) node;
final Component_Type compType = Port_Utility.checkComponentReference(timestamp, s, s.getComponent(), false, false);
final Assignment assignment = s.getFunctionInstanceReference().getRefdAssignment(timestamp, false);
if (assignment == null) {
return;
}
switch(assignment.getAssignmentType()) {
case A_FUNCTION:
case A_FUNCTION_RTEMP:
case A_FUNCTION_RVAL:
break;
default:
return;
}
final Def_Function function = (Def_Function) assignment;
final IType runsOnType = function.getRunsOnType(timestamp);
if (compType == null || runsOnType == null || !function.isStartable()) {
return;
}
switch(function.getAssignmentType()) {
case A_FUNCTION_RTEMP:
break;
case A_FUNCTION_RVAL:
IType type = function.getType(timestamp);
boolean returnTypeCorrect = false;
while (!returnTypeCorrect) {
if (type.hasDoneAttribute()) {
returnTypeCorrect = true;
break;
}
if (type instanceof IReferencingType) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType refd = ((IReferencingType) type).getTypeRefd(timestamp, refChain);
refChain.release();
if (type != refd) {
type = refd;
} else {
break;
}
} else {
break;
}
}
if (!returnTypeCorrect) {
final String msg = MessageFormat.format(PROBLEM, function.getDescription(), function.getType(timestamp).getTypename());
problems.report(s.getFunctionInstanceReference().getLocation(), msg);
}
break;
default:
break;
}
}
}
Aggregations