Unresolved Reference API
The Unresolved Reference APIs are specifically designed to manage unresolved references in specific scopes.
The Unresolved Reference API is the entry point for accessing the unresolved references. It is available on IProject instances.
The
IUnresolvedReferenceApi provides the methods to access the different APIs
which are designed to manage unresolved references of specific scopes. For an example see the IEcucUnresolvedReferenceApi
IEcucUnresolvedReferenceApiEntryPoint.
IProjectApi.getUnresolvedReferences() allows accessing the IUnresolvedReferenceApi like a property.
scriptTask('AccessAsPropertyTask') {
code {
// IUnresolvedReferenceApi is available as unresolvedReferences property
def unresolvedReferencesApi = unresolvedReferences
}
}
IProjectApi.unresolvedReferences(Transformer) allows accessing the IUnresolvedReferenceApi in a scope-like way.
scriptTask('AccessLikeScopeTask') {
code {
unresolvedReferences {
// IUnresolvedReferenceApi is available inside this Closure
}
}
}
Active ECUC Unresolved Reference API
The ECUC Unresolved Reference Api is specifically designed to read and edit unresolved references of the active ECUC.
getActiveEcuc() allows accessing the IEcucUnresolvedReferenceApi like a property.
scriptTask('AccessApiAsPropertyTask') {
code {
def ecucUnresolvedReferenceApi = unresolvedReferences.activeEcuc
}
}
activeEcuc(Transformer) allows accessing the IEcucUnresolvedReferenceApi in a scope-like way.
scriptTask('AccessApiLikeScopeTask') {
code {
unresolvedReferences.activeEcuc {
// IEcucUnresolvedReferenceApi is available inside this Closure
}
}
}
Selecting unresolved references
select(Action) allows the selection of all unresolved references of the active ECUC
using predicates. The returned selection is read only. Use selectChangeable(Action) for changes. The selection is returned by an
IEcucUnresolvedReferenceSelection.
selectChangeable(Action) allows the selection of the
changeable unresolved references of the active ECUC using predicates. The selection is returned by an IChangeableEcucUnresolvedReferenceSelection.
Examples
scriptTask('SelectAllReferencesTask') {
code {
def selection = unresolvedReferences.activeEcuc.select {
// filters can be set here
}
}
}
scriptTask('SelectAllReferencesExampleTask') {
code {
def selection = unresolvedReferences.activeEcuc.select {
owner(~ ".*/Rte/Com/.*")
}
}
}
scriptTask('SelectChangeableTask') {
code {
def selection = unresolvedReferences.activeEcuc.selectChangeable {
// filters can be set here
}
}
}
Predicates
Predicates can be set by several methods. These can be used to filter the unresolved references.
-
reference(String)filters the unresolved references by the reference path as String. -
reference(Pattern)filters the unresolved references by the reference path as a pattern. -
owner(MIObject)filters the unresolved references by the owner object. -
owner(String)filters the unresolved references by the exact owner path string. -
owner(Pattern)filters the unresolved references by the owner as a pattern. -
container(MIContainer)filters the unresolved references by a container. This container contains the referenced elements of the filtered references.
Set changeable unresolved references
setCommonReferencePath(AsrPath) sets a common reference for all filtered unresolved references.
setReferencesByFunction(Function) sets a common reference for all filtered unresolved references by using a String
-> String function.
replaceInReferences(String, String) sets a new reference for all unresolved references of the selection by replacing an
included string.
replacePrefixInReferences(String, String) sets a new reference for all unresolved references of the selection by
replacing a prefix of the unresolved references.
Examples
scriptTask('SetChangeableTask'){
code{
def selection = unresolvedReferences.activeEcuc.selectChangeable {
// filters can be set here
}
transaction{
// this path is a created AsrPath as an example. Use a valid path instead.
def path = AsrPath.create("/Changed/Reference")
selection.setCommonReferencePath(path)
}
}
}
scriptTask('ReplaceInChangeableTask'){
code{
def selection = unresolvedReferences.activeEcuc.selectChangeable {
// filters can be set here
}
transaction{
selection.replaceInReferences("MICROSAR", "OTHER")
}
}
}
scriptTask('ReplacePrefixInChangeableTask'){
code{
def selection = unresolvedReferences.activeEcuc.selectChangeable {
// filters can be set here
}
transaction{
selection.replacePrefixInReferences("/MICROSAR", "/OTHER")
}
}
}