use of org.eclipse.titan.designer.AST.Scope in project titan.EclipsePlug-ins by eclipse.
the class Def_Altstep method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
isUsed = false;
runsOnType = null;
lastTimeChecked = timestamp;
T3Doc.check(this.getCommentLocation(), KIND);
if (runsOnRef != null) {
runsOnType = runsOnRef.chkComponentypeReference(timestamp);
if (runsOnType != null) {
final Scope formalParlistPreviosScope = formalParList.getParentScope();
if (formalParlistPreviosScope instanceof RunsOnScope && ((RunsOnScope) formalParlistPreviosScope).getParentScope() == myScope) {
((RunsOnScope) formalParlistPreviosScope).setComponentType(runsOnType);
} else {
final Scope tempScope = new RunsOnScope(runsOnType, myScope);
formalParList.setMyScope(tempScope);
}
}
}
if (formalParList.hasNotusedDefaultValue()) {
formalParList.getLocation().reportSemanticError(DASHALLOWEDONLYFORTEMPLATES);
}
boolean canSkip = false;
if (myScope != null) {
final Module module = myScope.getModuleScope();
if (module != null) {
if (module.getSkippedFromSemanticChecking()) {
canSkip = true;
}
}
}
if (!canSkip) {
formalParList.reset();
}
formalParList.check(timestamp, getAssignmentType());
if (canSkip) {
return;
}
NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_ALTSTEP, identifier, this);
NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
if (block != null) {
block.check(timestamp);
block.setCodeSection(CodeSectionType.CS_INLINE);
}
if (altGuards != null) {
altGuards.setIsAltstep();
altGuards.setMyAltguards(altGuards);
altGuards.setMyLaicStmt(altGuards, null);
altGuards.check(timestamp);
altGuards.setCodeSection(CodeSectionType.CS_INLINE);
}
if (withAttributesPath != null) {
withAttributesPath.checkGlobalAttributes(timestamp, false);
withAttributesPath.checkAttributes(timestamp);
}
if (block != null) {
block.postCheck();
}
if (altGuards != null) {
altGuards.postCheck();
}
}
use of org.eclipse.titan.designer.AST.Scope in project titan.EclipsePlug-ins by eclipse.
the class TableConstraint method getOpenTypeAlternativeName.
// Original titan.core version: t_type->get_otaltname(is_strange);
private Identifier getOpenTypeAlternativeName(final CompilationTimeStamp timestamp, final Type type, final AtomicBoolean isStrange) {
StringBuffer sb = new StringBuffer();
// TODO: if (is_tagged() || is_constrained() || hasRawAttrs()) {
if (!type.getIsErroneous(timestamp) && type.isConstrained()) {
sb.append(type.getGenNameOwn());
isStrange.set(true);
} else if (!type.getIsErroneous(timestamp) && type instanceof Referenced_Type) {
Reference t_ref = ((Referenced_Type) type).getReference();
if (t_ref != null) {
final Identifier id = t_ref.getId();
final String dn = id.getDisplayName();
int i = dn.indexOf('.');
if (i >= 0 && i < dn.length()) {
// id is not regular because t_ref is a parameterized reference
sb.append(id.getName());
isStrange.set(true);
} else {
Assignment as = t_ref.getRefdAssignment(timestamp, true);
if (as == null) {
return null;
}
Scope assScope = as.getMyScope();
if (assScope.getParentScope() == assScope.getModuleScope()) {
sb.append(id.getName());
isStrange.set(false);
} else {
// t_ref is a dummy reference in a parameterized assignment
// (i.e. it points to a parameter assignment of an instantiation)
// perform the same examination recursively on the referenced type
// (which is the actual parameter)
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
IType referencedType = ((Referenced_Type) type).getTypeRefd(timestamp, chain);
chain.release();
return getOpenTypeAlternativeName(timestamp, (Type) referencedType, isStrange);
}
}
} else {
// the type comes from an information object [class]
// examine the referenced type recursively
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
IType referencedType = ((Referenced_Type) type).getTypeRefd(timestamp, chain);
chain.release();
return getOpenTypeAlternativeName(timestamp, (Type) referencedType, isStrange);
}
} else {
Identifier tmpId1 = new Identifier(Identifier_type.ID_NAME, type.getFullName());
String s = tmpId1.getDisplayName();
// module name will be cut off:
if (s.startsWith("@") && s.indexOf('.') > 0) {
s = s.substring(s.indexOf('.') + 1);
}
Identifier tmpId2 = new Identifier(Identifier_type.ID_ASN, s);
sb.append(tmpId2.getTtcnName());
}
// conversion to lower case initial:
sb.replace(0, 1, sb.substring(0, 1).toLowerCase());
// trick:
Identifier tmpId = new Identifier(Identifier_type.ID_NAME, sb.toString());
return new Identifier(Identifier_type.ID_ASN, tmpId.getAsnName());
}
use of org.eclipse.titan.designer.AST.Scope in project titan.EclipsePlug-ins by eclipse.
the class Object_FieldSpecification method setMyObjectClass.
@Override
public /**
* {@inheritDoc}
*/
void setMyObjectClass(final ObjectClass_Definition objectClass) {
super.setMyObjectClass(objectClass);
final Scope scope = myObjectClass.getMyScope();
objectClass.setMyScope(scope);
if (null != defaultObject) {
defaultObject.setMyScope(scope);
}
}
use of org.eclipse.titan.designer.AST.Scope 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.Scope in project titan.EclipsePlug-ins by eclipse.
the class Altstep_Type method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
runsOnType = null;
lastTimeChecked = timestamp;
isErroneous = false;
parseAttributes(timestamp);
if (runsOnRef != null) {
runsOnType = runsOnRef.chkComponentypeReference(timestamp);
if (runsOnType != null) {
final Scope formalParlistPreviosScope = formalParList.getParentScope();
if (formalParlistPreviosScope instanceof RunsOnScope && ((RunsOnScope) formalParlistPreviosScope).getParentScope() == myScope) {
((RunsOnScope) formalParlistPreviosScope).setComponentType(runsOnType);
} else {
final Scope tempScope = new RunsOnScope(runsOnType, myScope);
formalParList.setMyScope(tempScope);
}
}
}
formalParList.reset();
formalParList.check(timestamp, Assignment_type.A_ALTSTEP);
formalParList.checkNoLazyParams();
checkSubtypeRestrictions(timestamp);
if (myScope != null) {
checkEncode(timestamp);
checkVariants(timestamp);
}
}
Aggregations