Unnoticeable Lesscss Compiler in Eclipse Pdt

unnoticeable lesscss compiler in eclipse pdt

To automatically transpile LESS to CSS in Eclipse, I explain two possible ways.

  1. Using a Plugin
  2. How to do it manually

(I edited this post after I wrote the plugin, so the manual way is the old way, that the original post contained over some time, which you may have seen here a while ago)

Requirements

For either solution you need to install node and lessc (the less-compiler).

Installing lessc through npm with the following commands:

npm install -g less-compiler
npm install -g less

1. Install the Eclipse Transpiler Plugin

I wrote an eclipse plugin to handle transpiling in eclipse. Just install it and follow the instructions on the project readme to configure transpiling for your project.

-> https://github.com/gossi/eclipse-transpiler-plugin

2. Manually install a builder

I wrote myself a little shell script that runs lessc after every save on a .less file. However, eclipse keeps its own environment, thus no %PATH variables are available in eclipse. So, you need the full path to the lessc command, which you can find with which lessc:

$ which lessc
/usr/local/bin/lessc

Also, because lessc runs on a node environment:

$ head -n1 /usr/local/bin/lessc
#!/usr/bin/env node

You cannot run this directly, because eclipse doesn't know about your environment. You need to prepend the node command, to achieve a lessc call in eclipse:

$ which node
/usr/local/bin/node

The shell script with the full path to lessc is:

#!/bin/bash

/usr/local/bin/node /usr/local/bin/lessc css/*.less > css/*.css

You may adjust the input and output sources according to your project. In order to make that run in eclipse we need to make it run as a builder. Here you go:

  1. Rightclick on your project > Properties > Builders.
  2. Click New, choose Programm and give it a cool name
  3. "Main" Tab

    • Location: Choose the shell script here
    • Working Directory: I choosed the project folder
  4. "Refresh" Tab

    • [x] Refresh resources upon completion
    • [x] Specific resources
    • Click on "Specify Resources..."
    • Check the resources that you want to be refreshed after the compilation, typically the css files
    • Recursively include sub-folders depends on you and your project
  5. "Build Options"

    • [  ] Allocate Console (uncheck, we want it silent, turn it on for debugging)
    • [x] Launch in Background
    • Run the Builder

      • [  ] After a "clean"
      • [x] During manual builds
      • [x] During auto builds
      • [  ] During a "clean"
    • [x] Specify working set of relevant resources
    • Click "Specify Resources..."
    • Choose the resources you want to compile, typically your .less files. A Note, don't select the folder with css files here, that gets refreshed after the build, anyway your eclipse might get catched in a never-ending-loop here. So .less files will be enough.

Now, open a .less file, do some changes and save. Open the compiled .css file - tada :)

Windows:

I think this will work on windows too, with an according .bat file.

Have fun

Eclipse: On Save execute a program

I think all you need is to define a custom Builder for your project. That way, you can run a program or an ant script whenever certain files change.

Right click on the project -> Properties -> Builders -> New

Only show errors from compilation in Eclipse CDT

The errors from internal parsing are shown by Eclipse CDT's CodAn (Code Analysis) component, which can be configured in Preferences | C/C++ | Code Analysis.

On that preference page, you can uncheck the category Syntax and Semantic Errors if you don't want to see CodAn errors, and the category Potential Programming Problems if you don't want to see CodAn warnings either.

Eclipse as an IDE - What do you find missing as a beginner in Java?

Missing in Eclipse are:

Software visualization, as for example System Complexity View [Lanza 2003]

And also by Lanza, the Class Blueprint [Ducasse 2005]

Post Scriptum: Software visualization in Eclipse: X-Ray provides System Complexity View of Java projects, http://xray.inf.usi.ch/xray.php (via @anjaguzzi and Paul Lammertsma)

Software Visualization

And then collaborative filtering "other developers that edited this method before also edited" [Zimmermann 2005]

And the collection of browsable examples, and autocompletion at the level of these examples. That is, for example if your write

ByteBuffer buf = file.

and hit autocompletion it should search the codebase and the interwebs for examples that convert files to bytebuffers and insert that 10-20 lines there.

  • Parseweb supports developers by recommending method invocation sequences that yield a required
    destination data type from given input parameter types. http://doi.acm.org/10.1145/1453101.1453129
  • Prospector supports developers by recommending method invocation sequences that yield a required
    destination data type from given input parameter types.http://doi.acm.org/10.1145/1064978.1065018
  • Strathcona provides source code examples and structural con-
    text for the code fragment under development. http://lsmr.cpsc.ucalgary.ca/papers/holmes-icse-2005.pdf
  • Rascal recommends how and when to call the methods of objects from common libraries such as Java Swing, based on an analysis of existing classes. It uses collaborative filtering. http://dx.doi.org/10.1007/s10462-005-9012-8

And of course also the feature that I can write a Unit test and then the IDE searches the interwebs for classes that pass the test. Yes, this can be done!

  • CodeGenie is an Eclipse plugin that allows you to write unit tests and then uses the Sourcerer source code search engine to find passing classes. http://doi.acm.org/10.1145/1529282.1529384
  • CodeConjurer which is based on Merobase also offers that feature, see http://dx.doi.org/10.1109/MS.2008.110

This list could go on and on, good starting points for more work are the proceedings of past

  • Conference on Mining Software Repositories (MSR)
  • Workshop on Search-driven Software Engineering (SUITE)
  • Workshop on Recommendation Systems for Software Engineering (RSSE)

which are all under the umbrella of the ICSE conference.

Only show errors from compilation in Eclipse CDT

The errors from internal parsing are shown by Eclipse CDT's CodAn (Code Analysis) component, which can be configured in Preferences | C/C++ | Code Analysis.

On that preference page, you can uncheck the category Syntax and Semantic Errors if you don't want to see CodAn errors, and the category Potential Programming Problems if you don't want to see CodAn warnings either.

Eclipse interface icons very small on high resolution screen in Windows 8.1

I have looked up solutions for this issue for the last month, but I have not found an ideal solution yet. It seems there should be a way around it, but I just can't find it.

I use a laptop with a 2560x1600 screen with the 200% magnification setting in Windows 8.1 (which makes it looking like a 1280x800 screen but clearer).

Applications that support such "HiDPI" mode look just gorgeous, but the ones that don't (e.g. Eclipse) show tiny icons that are almost unreadable.

I also use an outdated version of Visual Studio. That has not been updated for HiDPI (obviously MS wants me to use a newer version of VS), but it still works kind of ok with HiDPI screens since it just scales things up twice -- the sizes of icons and letters are normal but they look lower-resolution.

After I saw how VS works, I began looking up a way to launch Eclipse in the same mode since it would not be technically very hard to just scale things up like how VS does. I thought there would be an option I could set to launch Eclipse in that mode. I couldn't find it though.

After all, I ended up lowering the screen resolution to 1/4 (from 2560x1600 to 1280x800) with no magnification (from 200% to 100%) and not taking advantage of the high-resolution screen until Eclipse gets updated to support it since I had to do some work, but I am desparately waiting for an answer to this issue.

How to specify .NET Anonymous object return type in Linq using FuncT,Q?

In this case all you really want is as int... so just change your select to:

select DataAccessUtil.GetInt32(row, "ParentNodeID"));

And change your foreach to:

foreach (var nodeInfo in orderByLevelDesc(ds))
{
if (fromNodeIds.Contains(nodeInfo))
return nodeInfo;
}

Parse javac compilation errors

I think JavaCompiler and Diagnostic classes are something you want to check.

Here is some code from one of my early projects

public String compile(String source, Object... options) {
String className = getMainClassName(source);

if (className == null) {
throw new WrongSourceStructureException("No public class which implements 'Solution'");
}

javax.tools.JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

if (compiler == null)
throw new BadEnvironmentException("You should specify path to JDK in your JDK_HOME and JAVA_HOME");

Writer err = new StringWriter();
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
List<String> compilerOptions = new ArrayList<String>();

String[] opts = new String[options.length - 1];
System.arraycopy(options, 1, opts, 0, opts.length);

if (options != null) {
compilerOptions.addAll(Arrays.asList(opts));
}

compilerOptions.add("-d");
compilerOptions.add("./tmp/classes/");

JavaFileObject codeSolution = new JavaSourceFromString(className, source);

Iterable<? extends JavaFileObject> units = Arrays.asList(codeSolution);
javax.tools.JavaCompiler.CompilationTask task = compiler.getTask(err, null, diagnostics, compilerOptions, null, units);

boolean success = task.call();

if (!success) {
StringBuilder errorMessages = new StringBuilder();
for (Diagnostic diagnostic : diagnostics.getDiagnostics()) {
errorMessages.append(diagnostic.getMessage(null)).append("\n");
}
throw new NotCompiledException(errorMessages.toString());
}

String aPackage = getPackage(source);

return ".tmp/classes/" + options[0] + aPackage.replace(".", "/") + "/" + className + ".class";
}

Also, there is commons-jci, it may be more clear than standard JavaCompiler.



Related Topics



Leave a reply



Submit