-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add customized qualified name for cross references for specifications…
…, e.g., TopicSpec
- Loading branch information
Showing
4 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
plugins/de.fraunhofer.ipa.ros.xtext/src/de/fraunhofer/ipa/ros/RosQNP.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package de.fraunhofer.ipa.ros; | ||
|
||
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider | ||
import org.eclipse.emf.ecore.EObject | ||
import ros.TopicSpec | ||
import ros.ServiceSpec | ||
import ros.ActionSpec | ||
|
||
class RosQNP extends DefaultDeclarativeQualifiedNameProvider{ | ||
|
||
override getFullyQualifiedName(EObject obj) { | ||
if (obj instanceof TopicSpec) { | ||
val topic_spec_name = obj.name | ||
val pkg_name = obj.package.name | ||
return getConverter().toQualifiedName(pkg_name + "/msg/" + topic_spec_name); | ||
} | ||
if (obj instanceof ServiceSpec) { | ||
val service_spec_name = obj.name | ||
val pkg_name = obj.package.name | ||
return getConverter().toQualifiedName(pkg_name + "/srv/" + service_spec_name); | ||
} | ||
if (obj instanceof ActionSpec) { | ||
val action_spec_name = obj.name | ||
val pkg_name = obj.package.name | ||
return getConverter().toQualifiedName(pkg_name + "/action/" + action_spec_name); | ||
} | ||
return super.qualifiedName(obj); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
plugins/de.fraunhofer.ipa.ros.xtext/src/de/fraunhofer/ipa/ros/scoping/RosSP.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package de.fraunhofer.ipa.ros.scoping | ||
|
||
import org.eclipse.emf.ecore.EObject | ||
import org.eclipse.emf.ecore.EReference | ||
import org.eclipse.xtext.EcoreUtil2 | ||
import org.eclipse.xtext.scoping.Scopes | ||
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider | ||
import ros.RosPackage | ||
import ros.SpecBase | ||
|
||
class RosSP extends AbstractDeclarativeScopeProvider { | ||
|
||
override getScope(EObject context, EReference reference) { | ||
if (context instanceof SpecBase) { | ||
if (reference == RosPackage.Literals.SPEC_BASE) { | ||
val candidates = EcoreUtil2.getAllContentsOfType(context.package, SpecBase); | ||
return Scopes.scopeFor(candidates) | ||
} | ||
} | ||
return super.getScope(context, reference); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters