Phpstorm: add copyright information / licence header to files in project - ide

My existing files miss copyright info. I want to add a licence header to severals files in a project with Phpstorm / other JetBrains IDE.
This page doesn't help: https://www.jetbrains.com/idea/help/topicId609815.html
Anyone know the process please?

In 2016 JetBrains added a Copyright tool exactly for this purpose.
See https://blog.jetbrains.com/phpstorm/2016/01/managing-copyright-notices-in-phpstorm/ for more information.

I have the same requirement, but the closest thing I could get is to use the Live Templates feature. Basically I added a new Template under the PHP Group with the abbreviation copyright and the following text
/**************************************************************************
* Copyright (C) $user$, Inc - All Rights Reserved
*
* <omitted copyright blah>
*
* #file $file$
* #author $user$
* #site <my website>
* #date $date$
*/
Unfortunately it seems impossible to use Template Variables such as ${NAME} in the context of a Live Template, so you are forced to stick with the provided expressions. In this case I used fileName(), user() and date() which were enough for my case.
Finally you can type copyright and press Tab to generate the header.

Related

Adding package name to copyright profile in IntelliJ IDEA

I'm using Intellij idea. I need to add copyright for package name across the project
tried with ${PACKAGE_NAME} and $pacakage.name but no luck. Also, tried with
$file.qualifiedClassName
but it gets the package along with class name. Let me know the possible variable for getting the package name in copyright.
Copyright profiles are using Apache Velocity engine under the hood. You can try something like:
#set( $dot = "." )
#set( $final=$dot + $file.className)
$file.qualifiedClassName.replace($final, "")

Intellij IDEA has changed EVERY description in all classes. How? And how to avoid this "feature"?

I checked out the project from a Git repository inside Intellij IDEA. All the files are now blue (modified).
A quick investigation shows that all the (automatic) comments were translated, like here:
git diff Login.java
/**
- * <p>Java-Klasse für login complex type.
+ * <p>Java class for login complex type.
*
- * <p>Das folgende Schemafragment gibt den erwarteten Content an, der in dieser Klasse enthalten ist.
+ * <p>The following schema fragment specifies the expected content contained within this class.
*
...
It is a cool feature, but how to turn it OFF permanently?
(Intellij IDEA 2021.2)

VSCode - IntelliSense with custom languages

Hello VS Code Community!
I'm currently extending the VS Code editor with a own / custom language. This is easier as I thought but now I'm getting problems with IntelliSense.
As you can see, VS Code is suggesting me the content of comments and strings and that's the big problem for me.
I'm inexperienced to this and learning by trying ;) I guess it has to do with tokenizer but I have no idea how to specify / exclude comments and variable values.
Normally only declared variables and the given keywords should be suggested
Here the relevant code: (only for learning purposes, no copyright infringement intended)
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
/// <reference path="../../declares.d.ts" />
'use strict';
define(["require", "exports", '../sqfDef', 'monaco-testing'], function (require, exports, languageDef, T) {
var tokenizationSupport = T.createTokenizationSupport(languageDef.language);
var tokenize = T.createTokenizeFromSupport(tokenizationSupport);
var assertTokens = T.assertTokens;
T.module('Syntax Highlighting - SQF');
}
Are there any docs or can someone explain me please how to exclude this from the suggested list?
EDIT:
Ok, I realised that you can define object types in the Def.js so defining them in the Tests.js is not necessary. yet my problem persists.
Since there is currently no documentation for writing custom plugins we all gather our information by reverse engineering.
Take a look at resources\app\plugins\vs.language.typescript\features\suggestSupport.js. In line 10 you find this this.excludeTokens = ['string', 'comment', 'numeric'];.
So you need to write your own suggestSupport.js and register it in your languageMain.js.
You find an example setting it up in resources\app\plugins\vs.language.typescript\typescriptMain.js in line 58:
var suggestSupport = new SuggestSupport(ctx, client);
monaco.Modes.SuggestSupport.register(MODE_ID, suggestSupport);
return Configuration.load(MODE_ID, ctx.configurationService).then(function (config) {
suggestSupport.setConfiguration(config);
});

Can someone please provide step-by-step instructions for using jfreechart in an IntelliJ project

I cannot get JFreeChart to work in IntelliJ.
What I have done so far:
Using Win 7, IntelliJ 13.1.4 and Java 1.7
I am relatively new to IntelliJ
Started a new project in IntelliJ which creates the default directories root\out and root\src
Added my own directory root\lib
Put external libraries in there as .jar and .zip files (jcommon-1.0.23.zip, jfreechart-1.0.19.zip, junit-4.7.jar)
In IntelliJ, opened the "Project Structure" dialog (Ctrl+Alt+Shift+S)
In the left panel, selected "Modules"
In the middle panel selected this project (the only thing that was there)
In the right panel, on the "Sources" tab, selected the "src" directory
Switched to the "Dependencies" tab
Clicked on the green "+" button on the right
Selected "2 Library... > Java"
Navigated to root\lib and selected one of the .zip / .jar files
A "Detected Roots" dialog pops up - I just clicked OK
A "Configure Library" dialog pops up - I gave the library a sensible name and clicked OK
The library appears in the Dependencies tab with a symbol next to it that looks like some books and is the same symbol as next to the "External Libraries" node in the project tool window (so I'm guessing this is the library symbol)
Repeat for the other two libraries
In a source file for the project, I have tried typing "import org.jfree.*;" but while typing the "jfree" bit is red and when I hit enter at the end of the line the line disappears.
I have also tried typing "JFreeChart jFreeChart = new JFreeChart();" but the JFreeChart is red and when I click on it I don't get the option to import; only create class, interface, enum, etc.
Incidentally, running jUnit tests works fine
Also incidentally, the "External Libraries" node in the project tool window does show < 1.7 > (i.e. the JDK) but does not show jUnit, jCommon, or jFreeChart.
I have seen similar questions and the answers seem to indicate that what I have done is correct. I have also checked the IntelliJ documentation and that also indicated that what I have done is correct. However, it's clearly not working for me. Maybe I've misunderstood something.
Can someone help me to get JFreeChart working please?
Thanks
EDIT: jUnit was working but now it's not. D'oh!
I've never used IntelliJ before, but I downloaded it and immediately created a new project called JFreeChartExample File -> New Project. Next I clicked File -> Project Structure... and selected the Libraries entry then clicked the + to add both jcommon-1.0.23.jar and jfreechart-1.0.19.jar (which I had on my local file system after unzipping the JFreeChart distribution). Then in the src/ directory I created a new Java file BarChartDemo.java (see later). Now my project looks like this:
BarChartDemo1.java is as follows:
/* ==================
* BarChartDemo1.java
* ==================
*
* Copyright (c) 2005-2014, Object Refinery Limited.
* All rights reserved.
*
* http://www.jfree.org/jfreechart/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 09-Mar-2005 : Version 1 (DG);
* 11-Mar-2014 : Use new ChartFactory method (DG);
* 25-Jun-2014 : Update to use real data (DG);
*
*/
import java.awt.Color;
import java.awt.Dimension;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.block.BlockBorder;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
/**
* A simple demonstration application showing how to create a bar chart.
*/
public class BarChartDemo extends ApplicationFrame {
private static final long serialVersionUID = 1L;
static {
// set a theme using the new shadow generator feature available in
// 1.0.14 - for backwards compatibility it is not enabled by default
ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow",
true));
}
/**
* Creates a new demo instance.
*
* #param title the frame title.
*/
public BarChartDemo(String title) {
super(title);
CategoryDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartPanel chartPanel = new ChartPanel(chart, false);
chartPanel.setBackground(null);
chartPanel.setFillZoomRectangle(true);
chartPanel.setMouseWheelEnabled(true);
chartPanel.setDismissDelay(Integer.MAX_VALUE);
chartPanel.setPreferredSize(new Dimension(500, 270));
setContentPane(chartPanel);
}
/**
* Returns a sample dataset.
*
* #return The dataset.
*/
private static CategoryDataset createDataset() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(7445, "JFreeSVG", "Warm-up");
dataset.addValue(24448, "Batik", "Warm-up");
dataset.addValue(4297, "JFreeSVG", "Test");
dataset.addValue(21022, "Batik", "Test");
return dataset;
}
/**
* Creates a sample chart.
*
* #param dataset the dataset.
*
* #return The chart.
*/
private static JFreeChart createChart(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart(
"Performance: JFreeSVG vs Batik", null /* x-axis label*/,
"Milliseconds" /* y-axis label */, dataset);
chart.addSubtitle(new TextTitle("Time to generate 1000 charts in SVG "
+ "format (lower bars = better performance)"));
chart.setBackgroundPaint(null);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setBackgroundPaint(null);
// ******************************************************************
// More than 150 demo applications are included with the JFreeChart
// Developer Guide...for more information, see:
//
// > http://www.object-refinery.com/jfreechart/guide.html
//
// ******************************************************************
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
chart.getLegend().setFrame(BlockBorder.NONE);
return chart;
}
/**
* Starting point for the demonstration application.
*
* #param args ignored.
*/
public static void main(String[] args) {
BarChartDemo demo = new BarChartDemo("JFreeChart: BarChartDemo1.java");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
I can right click this file in the project and run it to get this:
I spent a couple of hours figuring out this problem and I finally got it to work.
You have to download the .jar files
You download the zipped files form the JFreeChart website.
the link both the files are given below.
http://mvnrepository.com/artifact/org.jfree/jcommon/1.0.23
http://mvnrepository.com/artifact/org.jfree/jfreechart/1.0.19

Branching with clearcase remote client

I am trying to branch a file in ClearCase Remote Client.
I have the branch set up and the config spec is updated to handle the branch.
But I can't find the option, and the googling isn't helping much.
The way I understand your question, it sounds like you want to somehow select a command from a Clearcase RC menu(s) and have the branch explicitly created(?)
Clearcase has no explicit "Generate Branch for this File" command; you would want the "Checkout" command in this case. Branching is indirect and is a result of checking out a version of a file in a view that has a config spec with the '-mkbranch ' operation in it. I.e. the following config spec will create the dev_1.0_branch once I check it out (for any and all vobs and files):
element * CHECKEDOUT
element * .../dev_1.0_branch/LATEST
element * /main/LATEST -mkbranch dev_1.0_branch
The first line is standard for views in which you are doing development, line 2 will assure that I see any file that has a dev_1.0_branch (particularly important for the checkout+mkbranch to work as expected :-), and line 3 will select the latest version of any file that does not have a dev_1.0_branch and will create the branch if (and only if) the file version selected by that rule is checked out.
Please let me know if any of the above sounds greek to you, particularly any of the config spec rules. Having worked with ClearCase for a long time, I assume and use a lot of its terminology and concepts as if it's common knowledge :-P.
One thing of note: if you checkout the file, then immediately uncheckout the file, you will leave an empty branch on that file (i.e. in the above you would have a file with a version such as: foo.c##/main/dev_1.0_branch/0, but no /main/dev_1.0_branch/1 version). Many sites prefer to keep the version tree clean and remove empty branches (one can be found in this IBM Rational Technical article)
Just to be clear, I'm familiar with ClearCase Base & ClearCase MultiSite, but have not worked with the Remote Client yet.
--- 2009-Jun-29 Update
In response to Paul's comment below, if you want to be selective in what files are branched, you can modify the "*" to be more specific. For example, if you want to only branch foo.c in the FOODEV VOB, but leave everything else on main:
UNIX config spec:
element * CHECKOUT
element * .../my_dev_branch/LATEST
element /vobs/FOODEV/src/foo.c -mkbranch my_dev_branch
element * /main/LATEST
(For windows, you would want to use Windows conventions. I.e. \FOODEV\src\foo.c).
You can also select a directory and all elements below the directory (again UNIX config spec):
element * CHECKOUT
element * .../my_dev_branch/LATEST
element /vobs/FOODEV/src/mycomponent/... -mkbranch my_dev_branch
element * /main/LATEST
The main page for config_spec (cleartool man config_spec from the command line on windows or unix) provides decent guidance in the "Pattern" section for how to write the element/version selector (2nd column).
You can do a lot of complex version selection with the config specs. Please let me know if you would like more details or specifics.
Here's a config spec that I used for fixing a particular bug, with names changed to disguise some of the guilty.
element * CHECKEDOUT
element * .../TEMP.bugnum171238.jleffler/LATEST
mkbranch -override TEMP.bugnum171238.jleffler
include /clearcase/cspecs/project/version-1.23.45
To create the branch, in each VOB, I used a command:
ct mkbrtype -c 'Branch for bug 171238' TEMP.bugnum171238.jleffler#/vobs/project
Previously, we used config specs with -mkbranch rules appended to the various element lines.