Commit 657fde77 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: handling class member visibility location; value ref tests (issue #427)


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent ac753823
......@@ -346,6 +346,16 @@ type class CorrectWithProperty {
}
}
// 'value' manipulation
private var integer @property valManip {
@get => 10;
@set {
if (value > 42) {
value := -value;
heightVal := value;
}
}
}
}
/***************************
......
......@@ -37,6 +37,7 @@ import org.eclipse.titan.designer.AST.IType;
import org.eclipse.titan.designer.AST.Identifier;
import org.eclipse.titan.designer.AST.Location;
import org.eclipse.titan.designer.AST.MarkerHandler;
import org.eclipse.titan.designer.AST.NULL_Location;
import org.eclipse.titan.designer.AST.Reference;
import org.eclipse.titan.designer.AST.ReferenceFinder;
import org.eclipse.titan.designer.AST.ReferenceFinder.Hit;
......@@ -87,6 +88,7 @@ public abstract class Definition extends Assignment implements IAppendableSyntax
/** The visibility modifier of the definition */
private VisibilityModifier visibilityModifier;
private Location visibilityLocation = NULL_Location.INSTANCE;
protected String genName = "";
......@@ -139,12 +141,16 @@ public abstract class Definition extends Assignment implements IAppendableSyntax
super(identifier);
}
/**
* Sets the visibility modifier of this definition.
*
* @param modifier
* the modifier to be set
* */
/** Sets the visibility modifier of this definition.
*
* @param modifier
* @param location
*/
public final void setVisibility(final VisibilityModifier modifier, Location location) {
visibilityModifier = modifier;
visibilityLocation = location;
}
public final void setVisibility(final VisibilityModifier modifier) {
visibilityModifier = modifier;
}
......@@ -159,6 +165,13 @@ public abstract class Definition extends Assignment implements IAppendableSyntax
return visibilityModifier;
}
/**
* @return the location of the visibility modifier
*/
public final Location getVisibilityModifierLocation() {
return visibilityLocation;
}
/**
* Sets the with attributes for this definition if it has any. Also
......
......@@ -378,7 +378,7 @@ public final class ClassTypeBody extends TTCN3Scope implements IReferenceChainEl
if (! (def instanceof Def_Function)) {
final VisibilityModifier visibility = def.getVisibilityModifier();
if (visibility != VisibilityModifier.Private && visibility != VisibilityModifier.Protected) {
def.getLocation().reportSemanticError(VISIBILITYPRIVATEPROTECTED);
def.getVisibilityModifierLocation().reportSemanticError(VISIBILITYPRIVATEPROTECTED);
}
}
}
......
......@@ -9237,9 +9237,13 @@ pr_ClassMember returns[List<Definition> definitions]
@init {
$definitions = null;
VisibilityModifier visibility = VisibilityModifier.Protected;
Location visibilityLocation = null;
}:
(
( vis = pr_OopVisibility { visibility = $vis.visibility; } )?
( vis = pr_OopVisibility {
visibility = $vis.visibility;
visibilityLocation = getLocation( $vis.start, $vis.stop );
} )?
( var = pr_VarInstance { $definitions = $var.definitions; }
| timer = pr_TimerInstance { $definitions = $timer.definitions; }
| con = pr_ConstDef { $definitions = $con.array; }
......@@ -9280,7 +9284,7 @@ pr_ClassMember returns[List<Definition> definitions]
if ($definitions != null) {
for(int i = 0; i < $definitions.size(); i++) {
Definition definition = $definitions.get(i);
definition.setVisibility(visibility);
definition.setVisibility(visibility, visibilityLocation);
definition.setCumulativeDefinitionLocation(getLocation( $start, getLastVisibleToken()));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment