How to import MathTool in Velocity in file template in IntelliJ - intellij-idea

I am working on adding a file template of a Java class in IntelliJ using Apache Velocity. I want to use pow() function in the template but I don't know how to import it. According to the official guide https://velocity.apache.org/tools/1.4/generic/MathTool.html#pow() I need to add
<tool>
<key>math</key>
<scope>application</scope>
<class>org.apache.velocity.tools.generic.MathTool</class>
</tool>
But I don't know where to put this xml file. File template is just a single class template file created in .idea directory which has no application structure. Does anyone know how to import this?

IntelliJ IDEA doesn't support this kind of imports. Feature request is welcome.

Related

How to add/import a .kt file as a source in main.kt file in idle kotlin (gradle build) project

I'm learning kotlin recently and have experience with python and pycharm. I'm having some problems on importing a file as a source root in IntelliJ IDE.
my problems are,
If I keep my custom .kt file say calculation.kt in the same folder as main.kt i.e..$project$/src/main/kotlin/main.kt file directory I don't have to import or add calculation.kt in main.kt. All functions within the calculation.kt works fine, maybe being implicitly imported.
But if I keep the file in another folder i.e $project$/src/others/calculation.kt and mark the "others" folder as the source root, yet the calculation.kt doesn't get implicitly imported. Maybe I need to do an explicit import of calculation.kt in my main.kt. I need to know how to do that
Do I have to do any addition to build.gradle.kts file? I think I have to do some inclusion in there, please share an example on that.
Thank you.

In IntelliJ, using xquery, how do I set up my references?

IntelliJ IDEA 2021.2.1 Ultimate
Plugin XQuery and XSLT v1.9.1.212
I can't seem to work out how to get IntelliJ to find the module declarations I've set up in my .xqy modules. The MarkLogic server can find the location, but not IntelliJ. How do I adjust the options of IntelliJ to properly find the references to my modules?
In the "modules" database, the module is at "/code/test/testRecord.xqy"
The modules declaration is thus:
import module namespace testRecord = "testRecord.xqy" at "/code/test/testRecord.xqy"
Locally, the file is located at c:/project/src/main/xquery/testRecord.xqy
Again, the import module works fine in QConsole and when running the module doing the import, but IntelliJ just says "cannot find declaration to go to"
The plugin is using the at path hint to locate the file. That is, it is looking for a path that ends in /code/test/testRecord.xqy. Therefore, you need to ensure that the filesystem path matches, e.g. c:/project/src/main/xquery/code/test/testRecord.xqy.
If the file importing testRecord.xqy is located anywhere under /xquery, you shouldn't need to do anything else -- the plugin should be able to locate the file.
If you are using ml-gradle or roxy to manage the project, the plugin should automatically look in the specified module source root path for those files.
Note: If you want to get the plugin to recognize /MarkLogic paths, you can go to the "Languages & Frameworks > XQuery and XSLT > Modules and Paths" Settings page and set the "Database installation path:" to the root MarkLogic path, e.g. "C:\Program Files\MarkLogic".
If you want to customize this you can specify IntelliJ modules as described in https://rhdunn.github.io/xquery-intellij-plugin/tutorials/module-paths.html.

How to include local script files in Vue

I have a basic project in VS code, and quite a simple task. I want to include an old javascript file in my project the correct way, so it gets loaded in the browser.
The file should be located in src\assets\scripts\oldLegacyScript.js
I tried this hack: How to add external JS scripts to VueJS Components which injects a <source> tag in the document on runtime. This only works if I put the .js file in the generated public folder in where the compiled files will be. If the file is not in the public folder the browser tries to download the index.html file, which I cannot understand:
If i follow this solution: Importing javascript file for use within vue component I get syntax errors on the import statement:
So how the heck do I overcome this simple task of importing a simple javascript file in my Vue project?
Import like this
<script>
import * as myKey from '.src/..';
export default {
}
</script>

How to import a sass theming module from node_modules folder

I created a small vue.js library that is using scss for styling and published that as npm package. It works well with a default theme included into the package. But what if I would like to provide a custom theme from the application that consumes that npm package, how would you do that?
The source for a very basic version of the library is here: https://github.com/gwildu/gwi-vue-components
The idea is, that you would copy paste the styling folder somewhere (e.g., into your application directory or into another npm package) and configure the library package to import from that copyied directory.
I did some investigation myself and found that there is a big discussion about having dynamic imports in sass since years. This issue (open since 2013) claims to add such a feature (they call it load). Not sure, how actively sass is still developed and when this feature will be supported. For now I see 3 possible solutions:
move to LESS as it supports dynamic imports. Semantic UI gives you a hint about how theming could be done in LESS
It is possible to import from relative paths in SASS. That way you are also able to import from a parent directory of your package root directory (your application directory) like, e.g., #import '../../theme/index';. You would support somewhere in your package an example of a theme that the consumer then would have to copy to, e.g., the root directory of his application and adjust it to his needs. In your package you would then import the theme from that directory in the consumers application folder. The downside is, that the package would not work out of the box
You have a default theme in your package and you add some instructions into the readme how the user can override that theme in a build script. The consumer would have to copy the default theme to his application directory, adjust it to his needs and in the build script he would replace the theme in, e.g., node_modules/your-library-package-folder/theme/ by the theme in your application folder.
To be complete here is the approach with a dynamic import (that is not yet supported by SASS):
In your main theme file in the library package (that would be imported by the components) you would do a relative import of kind of a config file from the consumers application folder like in approach 2 (see above) but that config file yould not contain the theme but only the import path of the theme in a variable. that variable then would be used by the package main theme file to import the theme. For making the library work out of the box, I guess there would be a way to have a default theme as backup if the config file in the consumers directory would not exist (not tested)
Update:
I tried approach 3 but failed to get something useful. The issue with that approach is that you would have to somehow sync your custome theme with the default theme when you update the library to a higher version which might get too complex to handle in a reasonable way. Then I tried to use the overwrite feature of SASS as described here: How to overwrite SCSS variables when compiling to CSS which led me to approach
In your library component you first import a file with possible custom variables and you declare your variables in the library as default.
The issue with that approach is that SASS does not support optional imports. The file with the custom variables have to exist somewhere. So if the library updates you again have to sync your custom theme files for each component / file that was changed in the library. Apparently SASS also don't want to support such a feature in the future: https://github.com/sass/sass/issues/779 which is sad, as it seems to me an essential feature for being able to do theming without a highly complex build step.
Overall, it seems SASS itself is making every effort to prevent a simple theming approach which makes me think of moving back to LESS again. Not having a simple way for static theming in SASS in my opinion outweight the cons of not having an easy way to define custom functions in LESS.

IntelliJ-IDEA: how to enforce same code style

We are using IntelliJ IDEA 10.5. How can we ensure that everyone is using the same code style and Rearranger configuration? What files should be put under version control?
You should share most of the files in .idea directory when using the directory based format, check the FAQ.
In the Code style settings make the current scheme project specific, it will be stored in .idea/codeStyleSettings.xml (or project .ipr file when using the legacy format).
Rearranger is a third-party plug-in and as far as I know doesn't store its configuration inside the project. It has options to import configuration from a file and export it to a file which you can use to maintain the same configuration by putting this file in the version control.
Note that IDEA 12 will bundle a new Rearranger plug-in which will have better configuration management (similar to the code style settings, or a part of it).