Commit c3ea0a92 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ data label improvements

parent db485bef
......@@ -28,13 +28,12 @@ TDLSpec returns Package:
DataUse returns DataUse:
DynamicDataUse | StaticDataUse;
StaticDataUse returns StaticDataUse:
SpecialValueUse | DataInstanceUse;
SpecialValueUse | DataInstanceUse | LiteralValueUse;
DynamicDataUse returns DynamicDataUse:
VariableUse| FunctionCall | FormalParameterUse | TimeLabelUse;
VariableUse| FunctionCall | PredefinedFunctionCall | FormalParameterUse | TimeLabelUse;
SpecialValueUse returns StaticDataUse:
NoneValue | AnyValue | AnyNoneValue
......@@ -46,12 +45,38 @@ EString returns ecore::EString:
DataInstanceUse returns DataInstanceUse:
dataInstance=[DataInstance|NumberAsIdentifier] |
( dataInstance=[DataInstance|EString]
('(' argument+=ParameterBinding ( "," argument+=ParameterBinding)* ')' )?
('.' reduction+=MemberReference)*
{DataInstanceUse}
(
( dataInstance=[DataInstance|NumberAsIdentifier] |
dataInstance=[DataInstance|EString]
)
(
(unassignedMember=UnassignedMemberTreatment)?
('(' argument+=ParameterBinding ( "," argument+=ParameterBinding)* ')' )?
('.' reduction+=MemberReference)*
)?
)
|
(
dataType=[StructuredDataType|EString]
(unassignedMember=UnassignedMemberTreatment)?
('(' argument+=ParameterBinding ( "," argument+=ParameterBinding)* ')' )
)
|
(
(unassignedMember=UnassignedMemberTreatment)?
('(' argument+=ParameterBinding ( "," argument+=ParameterBinding)* ')' )
)
|
{DataInstanceUse}
(
(dataType=[CollectionDataType|EString])?
(unassignedMember=UnassignedMemberTreatment)?
'{'
(item+=StaticDataUse ("," item+=StaticDataUse)*)?
'}'
)
//TODO: if for some reason the data instance use does have a name
//it will cause problems... same applies for other scenarios
//TODO: create a more elegant way to handle that gracefully)
......@@ -61,6 +86,16 @@ DataInstanceUse returns DataInstanceUse:
NumberAsIdentifier returns ecore::EString:
'-'? INT ('.' INT)?;
enum UnassignedMemberTreatment returns UnassignedMemberTreatment:
AnyValue = '?' | AnyValueOrOmit = '*';
LiteralValueUse returns LiteralValueUse:
{LiteralValueUse}
value=String0
(
':' dataType=[DataType|EString]
)?
;
MemberReference returns MemberReference:
member=[Member|EString]
......@@ -90,6 +125,8 @@ VariableUse returns VariableUse:
;
TimeLabelUse returns TimeLabelUse:
//TODO: need to add kind
//TODO: need to add predefined function
timeLabel=[TimeLabel|EString]
;
......@@ -654,6 +691,49 @@ Assertion returns Assertion:
('otherwise' otherwise=DataUse)?
;
PredefinedFunctionCall returns PredefinedFunctionCall:
PredefinedFunctionCallSize | PredefinedFunctionCallNot | PredefinedFunctionCallBinary
;
PredefinedFunctionCallSize returns PredefinedFunctionCall:
function=[PredefinedFunction|PredefinedIdentifierSize]
'('
actualParameters+=DataUse
')'
;
PredefinedFunctionCallNot returns PredefinedFunctionCall:
function=[PredefinedFunction|PredefinedIdentifierNot]
'('
actualParameters+=DataUse
')'
;
PredefinedFunctionCallBinary returns PredefinedFunctionCall:
'('
actualParameters+=DataUse
function=[PredefinedFunction|PredefinedIdentifierBinary]
actualParameters+=DataUse
')'
;
PredefinedIdentifierBinary returns ecore::EString:
'+' | '-' | '*' | '/' | 'mod'
| '>' | '<' | '>=' | '<=' | '>='
| '==' | '!=' | 'and' | 'or' | 'xor'
;
PredefinedIdentifierNot returns ecore::EString:
'not'
;
PredefinedIdentifierSize returns ecore::EString:
'size'
;
TimerStart returns TimerStart:
'start'
componentInstance=[ComponentInstance|EString]
......
......@@ -29,10 +29,21 @@ public class DataFormatter extends AbstractFormatter2 {
c.setLinewrap(1).before(pair.getSecond());
c.setLinewrap(1).after(pair.getSecond());
}
System.out.println("formatting?");
for (Pair<Keyword, Keyword> pair : extensions.findKeywordPairs("(", ")")) {
c.setIndentation(pair.getFirst(), pair.getSecond());
c.setLinewrap(1).after(pair.getFirst());
c.setLinewrap(1).before(pair.getSecond());
c.setLinewrap(1).after(pair.getSecond());
}
for (Keyword comma : extensions.findKeywords(",")) {
// c.setNoLinewrap().before(comma);
// c.setNoSpace().before(comma);
// c.setNoLinewrap().after(comma);
c.setNoLinewrap().before(comma);
c.setNoSpace().before(comma);
c.setNoLinewrap().after(comma);
c.setLinewrap(1).after(comma);
}
c.setLinewrap(0, 1, 2).before(extensions.getSL_COMMENTRule());
c.setLinewrap(0, 1, 2).before(extensions.getML_COMMENTRule());
......
......@@ -106,14 +106,17 @@ public class ContextAwareLinkingService extends DefaultLinkingService {
tdlPackage.eINSTANCE.getFunctionCall(),
tdlPackage.eINSTANCE.getPredefinedFunctionCall(),
tdlPackage.eINSTANCE.getVariableUse(),
tdlPackage.eINSTANCE.getFormalParameterUse()
tdlPackage.eINSTANCE.getFormalParameterUse(),
tdlPackage.eINSTANCE.getTimeLabelUse()
};
dataUseContexts.references = new EReference[]{
//TODO: extend with remaining kinds
tdlPackage.eINSTANCE.getDataInstanceUse_DataInstance(),
tdlPackage.eINSTANCE.getFunctionCall_Function(),
tdlPackage.eINSTANCE.getPredefinedFunctionCall_Function(),
tdlPackage.eINSTANCE.getVariableUse_Variable(),
tdlPackage.eINSTANCE.getFormalParameterUse_Parameter()
tdlPackage.eINSTANCE.getFormalParameterUse_Parameter(),
tdlPackage.eINSTANCE.getTimeLabelUse_TimeLabel()
};
alternativeContexts.put(tdlPackage.eINSTANCE.getDataUse(), dataUseContexts);
}
......@@ -122,6 +125,7 @@ public class ContextAwareLinkingService extends DefaultLinkingService {
if (alternativeClass.isInstance(contextObject))
return alternativeContexts.get(alternativeClass);
System.out.println(contextObject);
return null;
}
......
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