use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkToClause.
/**
* Checks a to clause reference to see if it really references valid
* component type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param source
* the source statement of this check.
* @param portType
* the type of the port used in the statement. Used to
* find the address type in effect.
* @param toClause
* the to clause to check
*/
public static void checkToClause(final CompilationTimeStamp timestamp, final Statement source, final Port_Type portType, final IValue toClause) {
if (toClause == null) {
return;
}
IType addressType = null;
if (portType != null) {
addressType = portType.getPortBody().getAddressType(timestamp);
} else if (source != null) {
final Module module = source.getMyStatementBlock().getModuleScope();
if (module != null && module_type.TTCN3_MODULE.equals(module.getModuletype())) {
addressType = ((TTCN3Module) module).getAddressType(timestamp);
}
}
if (addressType == null) {
checkComponentReference(timestamp, source, toClause, true, true);
} else {
// detect possible enumerated values (address may be an
// enumerated type)
final IValue temp = addressType.checkThisValueRef(timestamp, toClause);
// try to figure out whether the argument is a component
// reference or an SUT address
boolean isAddress;
final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (governor == null) {
isAddress = !Type_type.TYPE_COMPONENT.equals(temp.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE));
} else {
isAddress = addressType.isCompatible(timestamp, governor, null, null, null);
}
if (isAddress) {
addressType.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
} else {
checkComponentReference(timestamp, source, temp, true, true);
}
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class ContentAssistProcessor method computeCompletionProposals.
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, final int offset) {
IDocument doc = viewer.getDocument();
IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
ASN1ReferenceParser refParser = new ASN1ReferenceParser();
Reference ref = refParser.findReferenceForCompletion(file, offset, doc);
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
TITANDebugConsole.println("parsed the reference: " + ref);
}
if (ref == null || ref.getSubreferences().isEmpty()) {
return new ICompletionProposal[] {};
}
Scope scope = null;
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
Module tempModule = projectSourceParser.containedModule(file);
if (tempModule != null) {
scope = tempModule.getSmallestEnclosingScope(refParser.getReplacementOffset());
ref.setMyScope(scope);
ref.detectModid();
}
TemplateContextType contextType = new TemplateContextType(ASN1CodeSkeletons.CONTEXT_IDENTIFIER, ASN1CodeSkeletons.CONTEXT_NAME);
ProposalCollector propCollector = new ProposalCollector(Identifier_type.ID_ASN, ASN1CodeSkeletons.CONTEXT_IDENTIFIER, contextType, doc, ref, refParser.getReplacementOffset());
if (scope != null) {
scope.addProposal(propCollector);
propCollector.sortTillMarked();
propCollector.markPosition();
}
if (ref.getSubreferences().size() != 1) {
return propCollector.getCompletitions();
}
if (scope == null) {
propCollector.addProposal(CodeScanner.TAGS, null, KEYWORD);
} else {
ASN1CodeSkeletons.addSkeletonProposals(doc, refParser.getReplacementOffset(), propCollector);
}
propCollector.sortTillMarked();
propCollector.markPosition();
propCollector.addProposal(CodeScanner.VERBS, null, KEYWORD);
propCollector.addProposal(CodeScanner.COMPARE_TYPES, null, KEYWORD);
propCollector.addProposal(CodeScanner.STATUS_TYPE, null, KEYWORD);
propCollector.addProposal(CodeScanner.KEYWORDS, null, KEYWORD);
propCollector.addProposal(CodeScanner.STORAGE, null, KEYWORD);
propCollector.addProposal(CodeScanner.MODIFIER, null, KEYWORD);
propCollector.addProposal(CodeScanner.ACCESS_TYPE, null, KEYWORD);
propCollector.sortTillMarked();
String sortingpolicy = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.CONTENTASSISTANT_PROPOSAL_SORTING);
if (PreferenceConstantValues.SORT_ALPHABETICALLY.equals(sortingpolicy)) {
propCollector.sortAll();
}
return propCollector.getCompletitions();
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class AbstractOfType method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (myScope != null) {
final Module module = myScope.getModuleScope();
if (module != null && module.getSkippedFromSemanticChecking()) {
lastTimeChecked = timestamp;
return;
}
}
componentInternal = false;
isErroneous = false;
parseAttributes(timestamp);
if (ofType == null) {
setIsErroneous(true);
} else {
ofType.setGenName(getGenNameOwn(), "0");
ofType.setParentType(this);
ofType.check(timestamp);
if (!isAsn()) {
ofType.checkEmbedded(timestamp, ofType.getLocation(), true, "embedded into another type");
}
componentInternal = ofType.isComponentInternal(timestamp);
}
if (constraints != null) {
constraints.check(timestamp);
}
checkSubtypeRestrictions(timestamp);
if (myScope != null) {
checkEncode(timestamp);
checkVariants(timestamp);
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class EnumItem method getDeclaration.
@Override
public /**
* {@inheritDoc}
*/
Declaration getDeclaration() {
if (getMyScope() == null) {
return null;
}
final Module module = getMyScope().getModuleScope();
final Assignment assignment = module.getEnclosingAssignment(getLocation().getOffset());
final IType type = assignment.getType(CompilationTimeStamp.getBaseTimestamp());
if (type instanceof ITypeWithComponents) {
final Identifier id = ((ITypeWithComponents) type).getComponentIdentifierByName(getId());
return Declaration.createInstance(assignment, id);
}
return null;
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class UnusedGlobalDefinition method process.
@Override
protected void process(IProject project, Problems problems) {
TITANDebugConsole.println("Unused global definition");
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(project);
final Set<String> knownModuleNames = projectSourceParser.getKnownModuleNames();
final List<Module> modules = new ArrayList<Module>();
final Set<Assignment> unused = new HashSet<Assignment>();
for (final String moduleName : new TreeSet<String>(knownModuleNames)) {
Module module = projectSourceParser.getModuleByName(moduleName);
modules.add(module);
final GlobalDefinitionCheck chek = new GlobalDefinitionCheck();
module.accept(chek);
unused.addAll(chek.getDefinitions());
}
for (Module module : modules) {
final GlobalUsedDefinitionCheck chekUsed = new GlobalUsedDefinitionCheck();
module.accept(chekUsed);
unused.removeAll(chekUsed.getDefinitions());
}
for (Assignment ass : unused) {
final String name = ass.getIdentifier().getDisplayName();
final String msg = MessageFormat.format("The {0} `{1}'' seems to be never used globally", ass.getAssignmentName(), name);
problems.report(ass.getIdentifier().getLocation(), msg);
}
}
Aggregations