Commit 41e160f0 authored by balaskoa's avatar balaskoa
Browse files

Merge github.com:eclipse/titan.EclipsePlug-ins

parents dddbc0a9 45458f97
......@@ -206,6 +206,9 @@ public final class SubsetMatch_Template extends CompositeTemplate {
for (int v = 0; v < variables.size(); v++) {
TTCN3Template template = templates.getTemplateByIndex(variables.get(v));
// the template must be all from
if ( template instanceof All_From_Template ) {
template = ((All_From_Template)template).getAllFrom();
}
IValue value = ((SpecificValue_Template) template).getValue();
Reference reference;
if (value.getValuetype() == Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE) {
......@@ -243,7 +246,7 @@ public final class SubsetMatch_Template extends CompositeTemplate {
break;
}
setType.append(".n_elem()");
setType.append(".n_elem().getInt()");
}
source.append(preamble);
......@@ -257,8 +260,12 @@ public final class SubsetMatch_Template extends CompositeTemplate {
switch (template.getTemplatetype()) {
case ALL_FROM: {
// the template must be all from
template.setLoweridToReference(CompilationTimeStamp.getBaseTimestamp());
IValue value = ((SpecificValue_Template) template).getValue();
TTCN3Template template2 = template;
if ( template instanceof All_From_Template ) {
template2 = ((All_From_Template)template).getAllFrom();
}
template2.setLoweridToReference(CompilationTimeStamp.getBaseTimestamp());
IValue value = ((SpecificValue_Template) template2).getValue();
Reference reference;
if (value.getValuetype() == Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE) {
//value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), null);
......@@ -290,12 +297,12 @@ public final class SubsetMatch_Template extends CompositeTemplate {
break;
}
source.append(MessageFormat.format("for (int i_i = 0, i_lim = {0}.n_elem(); i_i < i_lim; ++i_i ) '{'\n", expression.expression));
source.append(MessageFormat.format("for (int i_i = 0, i_lim = {0}.n_elem().getInt(); i_i < i_lim; ++i_i ) '{'\n", expression.expression));
String embeddedName = MessageFormat.format("{0}.setItem({1}{2} + i_i)", name, i, shifty);
((All_From_Template) template).generateCodeInitAllFrom(aData, source, embeddedName);
source.append("}\n");
shifty.append(MessageFormat.format("-1 + {0}.n_elem()", expression.expression));
shifty.append(MessageFormat.format("-1 + {0}.n_elem().getInt()", expression.expression));
break;
}
default:
......
......@@ -188,7 +188,11 @@ public final class SupersetMatch_Template extends CompositeTemplate {
for (int v = 0; v < variables.size(); v++) {
TTCN3Template template = templates.getTemplateByIndex(variables.get(v));
// the template must be all from
IValue value = ((SpecificValue_Template) template).getValue();
TTCN3Template template2 = template;
if ( template instanceof All_From_Template ) {
template2 = ((All_From_Template)template).getAllFrom();
}
IValue value = ((SpecificValue_Template) template2).getValue();
Reference reference;
if (value.getValuetype() == Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE) {
reference = ((Undefined_LowerIdentifier_Value) value).getAsReference();
......@@ -225,7 +229,7 @@ public final class SupersetMatch_Template extends CompositeTemplate {
break;
}
setType.append(".n_elem()");
setType.append(".n_elem().getInt()");
}
source.append(preamble);
......@@ -239,8 +243,12 @@ public final class SupersetMatch_Template extends CompositeTemplate {
switch (template.getTemplatetype()) {
case ALL_FROM: {
// the template must be all from
template.setLoweridToReference(CompilationTimeStamp.getBaseTimestamp());
IValue value = ((SpecificValue_Template) template).getValue();
TTCN3Template template2 = template;
if ( template instanceof All_From_Template ) {
template2 = ((All_From_Template)template).getAllFrom();
}
template2.setLoweridToReference(CompilationTimeStamp.getBaseTimestamp());
IValue value = ((SpecificValue_Template) template2).getValue();
Reference reference;
if (value.getValuetype() == Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE) {
//value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), null);
......@@ -272,12 +280,12 @@ public final class SupersetMatch_Template extends CompositeTemplate {
break;
}
source.append(MessageFormat.format("for (int i_i = 0, i_lim = {0}.n_elem(); i_i < i_lim; ++i_i ) '{'\n", expression.expression));
source.append(MessageFormat.format("for (int i_i = 0, i_lim = {0}.n_elem().getInt(); i_i < i_lim; ++i_i ) '{'\n", expression.expression));
String embeddedName = MessageFormat.format("{0}.setItem({1}{2} + i_i)", name, i, shifty);
((All_From_Template) template).generateCodeInitAllFrom(aData, source, embeddedName);
source.append("}\n");
shifty.append(MessageFormat.format("-1 + {0}.n_elem()", expression.expression));
shifty.append(MessageFormat.format("-1 + {0}.n_elem().getInt()", expression.expression));
break;
}
default:
......
......@@ -571,13 +571,13 @@ public final class Template_List extends CompositeTemplate {
break;
}
setSize.append(".n_elem()");
body.append(MessageFormat.format("for (int i_i = 0, i_lim = {0}.n_elem(); i_i < i_lim; ++i_i ) '{'\n", bodyExpression.expression));
setSize.append(".n_elem().getInt()");
body.append(MessageFormat.format("for (int i_i = 0, i_lim = {0}.n_elem().getInt(); i_i < i_lim; ++i_i ) '{'\n", bodyExpression.expression));
String embeddedName = MessageFormat.format("{0}.setItem({1} + i_i)", name, counter);
((All_From_Template) template).generateCodeInitAllFrom(aData, body, embeddedName);
body.append("}\n");
body.append(MessageFormat.format("{0} += {1}.n_elem();\n", counter, bodyExpression.expression));
body.append(MessageFormat.format("{0} += {1}.n_elem().getInt();\n", counter, bodyExpression.expression));
} else if (template.getTemplatetype() == Template_type.PERMUTATION_MATCH) {
int numPermutations = ((PermutationMatch_Template) template).getNofTemplates();
String permutationStart = aData.getTemporaryVariableName();
......@@ -618,14 +618,14 @@ public final class Template_List extends CompositeTemplate {
break;
}
setSize.append(".n_elem()");
body.append(MessageFormat.format("for (int i_i = 0, i_lim = {0}.n_elem(); i_i < i_lim; ++i_i ) '{'\n", bodyExpression.expression));
setSize.append(".n_elem().getInt()");
body.append(MessageFormat.format("for (int i_i = 0, i_lim = {0}.n_elem().getInt(); i_i < i_lim; ++i_i ) '{'\n", bodyExpression.expression));
String embeddedName = MessageFormat.format("{0}.setItem({1} + i_i)", name, counter);
((All_From_Template) template2).generateCodeInitAllFrom(aData, body, embeddedName);
body.append("}\n");
body.append(MessageFormat.format("{0} += {1}.n_elem();\n", counter, bodyExpression.expression));
body.append(MessageFormat.format("{0} += {1}.n_elem().getInt();\n", counter, bodyExpression.expression));
template2.lastTimeBuilt = aData.buildTimestamp;
} else {
fixedPart++;
......
......@@ -43,6 +43,7 @@ import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template;
import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Template_type;
import org.eclipse.titan.designer.AST.TTCN3.templates.IndexedTemplate;
import org.eclipse.titan.designer.AST.TTCN3.templates.Indexed_Template_List;
import org.eclipse.titan.designer.AST.TTCN3.templates.PermutationMatch_Template;
import org.eclipse.titan.designer.AST.TTCN3.templates.Template_List;
import org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimension;
import org.eclipse.titan.designer.AST.TTCN3.values.Array_Value;
......@@ -596,6 +597,16 @@ public final class Array_Type extends Type implements IReferenceableElement {
template.getLocation().reportSemanticWarning(REDUNDANTLENGTHRESTRICTION);
}
break;
case PERMUTATION_MATCH: {
final int nofComponents = ((PermutationMatch_Template) template).getNofTemplates();
for (int i = 0; i < nofComponents; i++) {
ITTCN3Template templateComponent = ((PermutationMatch_Template) template).getTemplateByIndex(i);
templateComponent.setMyGovernor(elementType);
templateComponent = elementType.checkThisTemplateRef(timestamp, templateComponent);
selfReference = templateComponent.checkThisTemplateGeneric(timestamp, elementType, isModified, false, true, true, false, lhs);
}
break;
}
case TEMPLATE_LIST: {
ITTCN3Template baseTemplate = template.getBaseTemplate();
int nofBaseComponents = 0;
......@@ -626,12 +637,18 @@ public final class Array_Type extends Type implements IReferenceableElement {
templateComponent.setBaseTemplate(((Template_List) baseTemplate).getTemplateByIndex(i));
}
templateComponent = elementType.checkThisTemplateRef(timestamp, templateComponent);
if (Template_type.TEMPLATE_NOTUSED.equals(templateComponent.getTemplatetype())) {
switch (templateComponent.getTemplatetype()) {
case PERMUTATION_MATCH:
selfReference = templateComponent.checkThisTemplateGeneric(timestamp, this, isModified, false, true, true, implicitOmit, lhs);
break;
case TEMPLATE_NOTUSED:
if (!isModified) {
templateComponent.getLocation().reportSemanticError(NOTUSEDNOTALLOWED);
}
} else {
break;
default:
selfReference = templateComponent.checkThisTemplateGeneric(timestamp, elementType, isModified, false, true, true, implicitOmit, lhs);
break;
}
}
break;
......
......@@ -498,7 +498,7 @@ public class RecordOfGenerator {
source.append("\t\tif (index_value < 0) {\n");
source.append( MessageFormat.format( "\t\t\tthrow new TtcnError( \"Accessing an element of type {0} using a negative index: \"+index_value+\".\");\n", displayName ) );
source.append("\t\t}\n");
source.append("\t\tfinal int nofElements = getNofElements().getInt();\n");
source.append("\t\tfinal int nofElements = n_elem().getInt();\n");
source.append("\t\tif ( index_value >= nofElements ) {\n");
source.append( MessageFormat.format( "\t\t\tthrow new TtcnError( \"Index overflow in a value of type {0}: The index is \"+index_value+\", but the value has only \"+nofElements+\" elements.\" );\n", displayName ) );
source.append("\t\t}\n");
......@@ -521,7 +521,7 @@ public class RecordOfGenerator {
source.append("\t}\n");
source.append('\n');
source.append("\tpublic TitanInteger getNofElements() {\n");
source.append("\tpublic TitanInteger n_elem() {\n");
source.append("\t\treturn sizeOf();\n");
source.append("\t}\n");
......
......@@ -638,6 +638,8 @@ public final class SequenceOf_Type extends AbstractOfType implements IReferencea
switch (component.getTemplatetype()) {
case PERMUTATION_MATCH:
selfReference = component.checkThisTemplateGeneric(timestamp, this, isModified, false, true, true, implicitOmit, lhs);
break;
case SUPERSET_MATCH:
case SUBSET_MATCH:
//FIXME: for Complement??? case COMPLEMENTED_LIST: ???
......
......@@ -13,9 +13,11 @@ import org.eclipse.titan.designer.AST.ASTVisitor;
import org.eclipse.titan.designer.AST.Assignment;
import org.eclipse.titan.designer.AST.INamedNode;
import org.eclipse.titan.designer.AST.IReferenceChain;
import org.eclipse.titan.designer.AST.Module;
import org.eclipse.titan.designer.AST.IType;
import org.eclipse.titan.designer.AST.IType.Type_type;
import org.eclipse.titan.designer.AST.IType.ValueCheckingOptions;
import org.eclipse.titan.designer.AST.IValue;
import org.eclipse.titan.designer.AST.Module;
import org.eclipse.titan.designer.AST.ReferenceFinder;
import org.eclipse.titan.designer.AST.ReferenceFinder.Hit;
import org.eclipse.titan.designer.AST.Scope;
......@@ -170,6 +172,36 @@ public final class StringConcatenationExpression extends Expression_Value {
}
}
@Override
/** {@inheritDoc} */
public IType getExpressionGovernor(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
if (myGovernor != null) {
return myGovernor;
}
}
final IType v1_gov = value1.getExpressionGovernor(timestamp, expectedValue);
final IType v2_gov = value2.getExpressionGovernor(timestamp, expectedValue);
if (v1_gov != null) {
if (v2_gov != null) {
if (v1_gov.isCompatible(timestamp, v2_gov, null, null, null)) {
return v1_gov;
} else {
return v2_gov;
}
} else {
return v1_gov;
}
} else {
if (v2_gov != null) {
return v2_gov;
} else {
return null;
}
}
}
@Override
/** {@inheritDoc} */
public boolean isUnfoldable(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue,
......@@ -212,6 +244,8 @@ public final class StringConcatenationExpression extends Expression_Value {
final IReferenceChain referenceChain) {
Type_type tempType1 = null;
Type_type tempType2 = null;
boolean v1_string = false;
boolean v2_string = false;
if (value1 != null) {
value1.setLoweridToReference(timestamp);
......@@ -223,6 +257,9 @@ public final class StringConcatenationExpression extends Expression_Value {
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
v1_string = true;
value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_SEQUENCE_OF:
case TYPE_SET_OF:
value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
......@@ -247,12 +284,14 @@ public final class StringConcatenationExpression extends Expression_Value {
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
v2_string = true;
value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_SEQUENCE_OF:
case TYPE_SET_OF:
value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(SECONDOPERANDERROR);
......@@ -267,9 +306,37 @@ public final class StringConcatenationExpression extends Expression_Value {
return;
}
if (!((Type_type.TYPE_CHARSTRING.equals(tempType1) && Type_type.TYPE_UCHARSTRING.equals(tempType2)) || (Type_type.TYPE_CHARSTRING
.equals(tempType2) && Type_type.TYPE_UCHARSTRING.equals(tempType1))) && tempType1 != tempType2) {
location.reportSemanticError(SAMEOPERANDERROR);
if (v1_string && v2_string) {
if (!((Type_type.TYPE_CHARSTRING.equals(tempType1) && Type_type.TYPE_UCHARSTRING.equals(tempType2))
|| (Type_type.TYPE_CHARSTRING.equals(tempType2) && Type_type.TYPE_UCHARSTRING.equals(tempType1))) && tempType1 != tempType2) {
location.reportSemanticError(SAMEOPERANDERROR);
setIsErroneous(true);
}
return;
}
final IType v1_gov = value1.getExpressionGovernor(timestamp, expectedValue);
IType v2_gov = value2.getExpressionGovernor(timestamp, expectedValue);
if (v1_gov == null) {
getLocation().reportSemanticError("Cannot determine the type of the left operand of `&' operation");
setIsErroneous(true);
return;
} else {
final IValue tempValue = v1_gov.checkThisValueRef(timestamp, value1);
v1_gov.checkThisValue(timestamp, tempValue, null, new ValueCheckingOptions(expectedValue, false, false,
true, false, false));
}
if (v2_gov == null) {
v2_gov = v1_gov;
value2.setMyGovernor(v1_gov);
}
final IValue tempValue = v2_gov.checkThisValueRef(timestamp, value2);
v2_gov.checkThisValue(timestamp, tempValue, null, new ValueCheckingOptions(expectedValue, false, false,
true, false, false));
// 7.1.2 says that we shouldn't allow type compatibility.
if (!v1_gov.isCompatible(timestamp, v2_gov, null, null, null)
&& !v2_gov.isCompatible(timestamp, v1_gov, null, null, null)) {
getLocation().reportSemanticError("The operands of `&' operation should be of compatible types");
setIsErroneous(true);
}
}
......
......@@ -376,7 +376,7 @@ public class AST_tests {
 
private ArrayList<MarkerToCheck> expression_tests_ttcn_initializer() {
//expression_tests.ttcn
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(10471);
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(1514);
int lineNum = 122;
int i = 0;
for (i = 0; i < 8; i++) {
......@@ -895,7 +895,7 @@ public class AST_tests {
}
lineNum += 1;
for (i = 0; i < 4; i++) {
markersToCheck.add(new MarkerToCheck("The operands of operation `&' should be of the same type", lineNum++, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("The operands of `&' operation should be of compatible types", lineNum++, IMarker.SEVERITY_ERROR));
}
lineNum += 32;
markersToCheck.add(new MarkerToCheck("Type mismatch: `@expression_tests.c11.f1' of type `@expression_tests.c1' and `@expression_tests.recR.rof' of type `@expression_tests.recofR' are not compatible: The optionality of fields in record/SEQUENCE types must be the same", lineNum, IMarker.SEVERITY_ERROR));
......@@ -987,7 +987,9 @@ public class AST_tests {
markersToCheck.add(new MarkerToCheck("Type mismatch: `integer[4]' and `integer[1]' are not compatible: Array types should have the same dimension", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("Type mismatch: `integer[1]' and `integer[4]' are not compatible: Array types should have the same dimension", ++lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("Type mismatch: `integer[4]' and `integer[1]' are not compatible: Array types should have the same dimension", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 15;
lineNum += 11;
markersToCheck.add(new MarkerToCheck("Cannot determine the type of the left operand of `&' operation", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 4;
for (i = 0; i < 2; i++) {
markersToCheck.add(new MarkerToCheck("The first and fourth operands of operation `replace' should be of the same type", lineNum, IMarker.SEVERITY_ERROR));
}
......@@ -997,7 +999,7 @@ public class AST_tests {
}
lineNum += 1;
for (i = 0; i < 2; i++) {
markersToCheck.add(new MarkerToCheck("The operands of operation `&' should be of the same type", lineNum++, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("The operands of `&' operation should be of compatible types", lineNum++, IMarker.SEVERITY_ERROR));
}
lineNum += 23;
for (i = 0; i < 2; i++) {
......@@ -174,13 +174,7 @@ public abstract class Base_Template {
public abstract Base_Template assign(final Base_Template otherValue);
public abstract TitanBoolean match(final Base_Type otherValue, final boolean legacy);
public abstract Base_Type valueOf();
public void log(){
//do nothing for now.
// TODO once the logging is implemented for all classes this function should become abstract
TtcnLogger.log_event_str( "//TODO: " );
TtcnLogger.log_event_str( getClass().getSimpleName() );
TtcnLogger.log_event_str( ".log() is not implemented!\n" );
}
public abstract void log();
public void log_match(final Base_Type match_value, final boolean legacy) {
//do nothing for now.
......
......@@ -27,11 +27,5 @@ public abstract class Base_Type {
public abstract TitanBoolean operatorEquals(final Base_Type otherValue);
public abstract Base_Type assign( final Base_Type otherValue );
public void log(){
//do nothing for now.
// TODO once the logging is implemented for all classes this function should become abstract
TtcnLogger.log_event_str( "//TODO: " );
TtcnLogger.log_event_str( getClass().getSimpleName() );
TtcnLogger.log_event_str( ".log() is not implemented!\n" );
}
public abstract void log();
}
......@@ -271,11 +271,11 @@ public class TitanTemplateArray<Tvalue extends Base_Type,Ttemplate extends Base_
copy_template(otherValue);
}
public TitanTemplateArray(final Class<Tvalue> classValue, final Class<Ttemplate> classTemplate , final int size, final int offset) {
this.classValue = classValue;
this.classTemplate = classTemplate;
indexOffset = offset;
setSize(size);
}
......
......@@ -112,6 +112,7 @@ public final class StaticData {
final Map<CodeSmellType, BaseProjectCodeSmellSpotter[]> pm = new HashMap<CodeSmellType, BaseProjectCodeSmellSpotter[]>();
pm.put(CodeSmellType.CIRCULAR_IMPORTATION, new BaseProjectCodeSmellSpotter[] { new CircularImportation() });
pm.put(CodeSmellType.UNUSED_IMPORTS_PROJECT, new BaseProjectCodeSmellSpotter[] { new UnusedImportsProject() });
pm.put(CodeSmellType.LANGUAGE_MIXING, new BaseProjectCodeSmellSpotter[]{ new LanguageMixing() });
return Collections.unmodifiableMap(pm);
......
/******************************************************************************
* Copyright (c) 2000-2017 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************/
package org.eclipse.titanium.markers.spotters.implementation;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.eclipse.core.resources.IProject;
import org.eclipse.titan.designer.AST.ASTVisitor;
import org.eclipse.titan.designer.AST.Assignment;
import org.eclipse.titan.designer.AST.IVisitableNode;
import org.eclipse.titan.designer.AST.Module;
import org.eclipse.titan.designer.AST.Reference;
import org.eclipse.titan.designer.AST.Scope;
import org.eclipse.titan.designer.AST.TTCN3.definitions.ImportModule;
import org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module;
import org.eclipse.titan.designer.consoles.TITANDebugConsole;
import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
import org.eclipse.titan.designer.parsers.GlobalParser;
import org.eclipse.titan.designer.parsers.ProjectSourceParser;
import org.eclipse.titanium.markers.spotters.BaseProjectCodeSmellSpotter;
import org.eclipse.titanium.markers.types.CodeSmellType;
/**
*
* @author Farkas Izabella Ingrid
*/
public class UnusedImportsProject extends BaseProjectCodeSmellSpotter{
private Set<TTCN3Module> setOfModules = new HashSet<TTCN3Module>();
private Set<TTCN3Module> setOfImportModules = new HashSet<TTCN3Module>();
public UnusedImportsProject() {
super(CodeSmellType.UNUSED_IMPORTS_PROJECT);
}
@Override
protected void process(IProject project, Problems problems) {
TITANDebugConsole.print("Unused import in project called");
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(project);
final Set<String> knownModuleNames = projectSourceParser.getKnownModuleNames();
final List<TTCN3Module> modules = new ArrayList<TTCN3Module>();
for (final String moduleName : new TreeSet<String>(knownModuleNames)) {
Module module = projectSourceParser.getModuleByName(moduleName);
if (module instanceof TTCN3Module) {
modules.add((TTCN3Module) module);
}
}
for (TTCN3Module module : modules) {
setOfModules.clear();
setOfImportModules.clear();
for (Module impMod : module.getImportedModules()) {
if (impMod instanceof TTCN3Module) {
setOfImportModules.add((TTCN3Module)impMod);
}
}
ImportsCheck check = new ImportsCheck();
module.accept(check);
setOfImportModules.removeAll(setOfModules);
for (ImportModule mod : module.getImports()){
for (TTCN3Module m : setOfImportModules) {
if(m.getIdentifier().equals(mod.getIdentifier())) {
problems.report(mod.getLocation(), "Possibly unused importation");
}
}
}
}
}
class ImportsCheck extends ASTVisitor {
public int visit(final IVisitableNode node){
if (node instanceof Reference) {
if(((Reference) node).getIsErroneous(CompilationTimeStamp.getBaseTimestamp())) {
return V_CONTINUE;
}
final Assignment assignment = ((Reference) node).getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false, null);
if(assignment != null ) {
final Scope scope = assignment.getMyScope();
if (scope != null) {
final Module module = scope.getModuleScope();
if (module instanceof TTCN3Module){
TTCN3Module mod = (TTCN3Module)module;
setOfModules.add(mod);
}
}
return V_CONTINUE;
}
}
return V_CONTINUE;
}
}
}
......@@ -19,6 +19,7 @@ import org.eclipse.titanium.Activator;
public enum CodeSmellType implements ProblemType{
ALTSTEP_COVERAGE("Altstep coverage", 1.0, 5.0, 76.0),
CIRCULAR_IMPORTATION("Circular importation", 2.0, 12.0, 80.0),
UNUSED_IMPORTS_PROJECT("Unused import in project", 0.0, 0.5, 1.0),
LANGUAGE_MIXING("Language mixing", 2.0, 12.0, 80.0),
CONSECUTIVE_ASSIGNMENTS("Consecutive assignments", 0.0, 1.0, 6.0),
CONVERT_TO_ENUM("Convert to enumeration", 0.5, 3.0, 8.0),
......
......@@ -28,6 +28,7 @@ public class RiskFactorCalculator {
TaskType.FIXME,
TaskType.TODO,
CodeSmellType.CIRCULAR_IMPORTATION,
CodeSmellType.UNUSED_IMPORTS_PROJECT,
CodeSmellType.LANGUAGE_MIXING,
CodeSmellType