I am implementing a language where name of the file needs to be the same as name of the class.
How can I get name of the file in validator?
If I can't do that, is there any other way to do what I want?
you can as any EObject for its eResource() and that for its getURI(). That will allow you to get the file name (lastSegment). you may want to trimFileExtension() first.
Related
In validator I would like to get uri of all model files.
I can get name only of current file (e.g myDsl1.mydsl) but I would like to get uri of other files too (e.g myDsl2.mydsl, myDsl3.mydsl).
Can this be done in validator or I should create new classes/methods for seeing this files?
You can access the Xtext index IResourceDescriptions via IResourceDescriptionsProvider. You can ask IResourceDescriptions for getAllResourceDescriptions which you may have to filter for project.
to use std visibility meachinsm check out IContainer.Manager with getVisibleContainers/getContainer and IContainer.getResourceDescriptions´. Check out DefaultGlobalScopeProvider` for sample usage.
I'm writing some validation code for a bazel build rule and I need to do some path validation. I need to check that a certain file exists in the same directory as the BUILD file. I notice that there's a context attribute build_file_path which points to the BUILD file. I'd like to extract the parent directory from this.
It looks like I can't create a new path object - I don't see a constructor/initializer. It also seems like Starlark doesn't support os.path like python because imports aren't supported.
What's the canonical way to get the parent directory of a string object representing a path in Starlark?
I can't answer your final question, but hopefully the following will help with the initial problem:
You could use the Label of the target for which this instance of the rule is being built and find its package. This will give you a string representing the parent directory of the BUILD file.
i.e. ctx.label.package
load("#bazel_skylib//lib:paths.bzl", "paths")
paths.dirname(path_str)
See https://github.com/bazelbuild/bazel-skylib/blob/main/docs/paths_doc.md
I need to have access to my properties file from GSP file to get one of it's values.
I tried to find example over the web, but I couldn't.
This is a file which I created and not Grails.
Thanks!
From grails controller and gsp file, you can access your yml file properties using GrailsApplication object:
${grailsApplication.config.get('YOUR_PROPERTY_NAME)}
you can access aaplicationContext from the GSP ... so you can access any configuration property.
Just look at this entry from Mr. Haki:
http://mrhaki.blogspot.com.es/2011/11/grails-goodness-get-grailsapplication.html
If the properties file is under grails-app/i18n/ (it can be your own properties file, doesn't have to be one of the default ones) then you can access property values from the property file in a GSP using the message tag. See http://grails.org/doc/latest/ref/Tags/message.html.
If you are reading simple properties it sounds like what you want is externalized configuration
To use it in a GSP (if you really need to, but not recommended from a GSP):
${Holders.config.myPropertyKey}
I have a custom external XJB file that has the schema name within it as follows :
jxb:bindings schemaLocation="completeCheck.xsd" node="/xs:schema"
Just wondering, is there a way to substitute the schema name at runtime within the XJB file using ANT(using ANT XJC) OR have a xjb binding file written such that I do not have to hardcode the schema name in it. Basically, I am trying to see if I can use a single xjb file for multiple XSDs.
Currently, I have the same xjb file all over the place with a different hardcoded schema name referred all over the place in build.xml. Any pointers are highly appreciated. I am using JAXB 2.x
Make a template from your xjb file by replacing the value of your schemaLocation attribute with some sort of marker (e.g. !!!) and save it using some other name/extension. Define a macro with an attribute such as schema-name that will use ant's replace to change the marker in the template file with your schema name and save that as the binding file to be subsequently used by xjc.
Normally, in the latest versions of XJC, you can use schema component designator. More info here :
https://jaxb.java.net/nonav/2.2.1/docs/vendorCustomizations.html#scd and https://jaxb.java.net/guide/Using_SCD_for_customizations.html
I am creating a resource file using
ResourceBundle _resources = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
Now i want to create another Resource file in that same class.
Can i do it in the same way like for first Resource file ?
The interface ResourceFile.java is an auto-generated file. Then how to view it ?
You need to edit the resource file (ResourceFile.rrc) in the BlackBerry JDE directly - from there you can add new key/value pairs. I don't think there's a way to iterate through all available keys in the code.