A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Things lacking in Eclipse for Perl

Using EPIC
  • You can't fold code on 'if' blocks, or any arbitrary block (only on subs and perldocs).
  • Word wrap causes the line numbers to be wrong (a single wrapped line has more than one line number)
  • Syntax highlighting is not a perfect fit (perhaps this or these might help):
    • POD and heredoc are both marked as 'Comment2' and so can't be different colours
    • Even though there is a 'Markup' entry, it doesn't seem to be used for POD
    • The colour of dollar signs can't be changed (it's the same as the variable name in vim)
    • Neither variables nor special characters change colour within interpolated strings (as in vim)

Create Eclipse project with existing files

  • Have your workspace as the directory above the directory containing your files.
  • Create the project with a name that is the same as your files directory.
The problem is, if there are lots of (unrelated) files, Eclipse will take a long time to load up.

There are other options, i.e.:

  • Create a new folder
  • Click the 'Advanced' button
  • Link to an external folder

Eclipse features

  • Syntax highlighting
  • Code folding
  • Go to source of library
  • Look up Javadoc/Perldoc
  • Automatic refactoring
  • File navigator

3rd party javadocs in Eclipse

  • Download and unzip the 3rd party package's source
  • Open the Package Explorer view in Eclipse
  • Navigate to [your project] | Referenced libraries | [3rd party library] | right-click | Properties
  • Enter the source directory in the Java Source Attachment | Location path
There is also a Javadoc Location field that accepts a URL (didn't work for XMLUnit or JUnit though)

How to run a Selenium/JUnit test

  • Install Eclipse 3.5
  • Download JUnit
  • Download Selenium RC
  • Run java -jar selenium-server-1.0.3/selenium-server.jar
  • Create a Java project in Eclipse
  • Right-click on the project name and go to Properties | Java Build Path | Add External JARs
    • add JUnit JAR
    • all the Selenium Server JARs
    • all the Selenium Java JARs
  • Run a program like this (This one doesn't actually work; the assertion fails)
    package com.example;
    
    import junit.framework.TestCase;
    import com.thoughtworks.selenium.DefaultSelenium;
    import com.thoughtworks.selenium.Selenium;
    
    public class GoogleTest extends TestCase {
     private static Selenium selenium;
     protected void setUp() {
      selenium = new DefaultSelenium("localhost" , 4444 , "*firefox", "http://www.google.com");
      selenium.start();
      selenium.setSpeed("2000");
     }
     public final void testTitle() {
      selenium.open("http://www.google.com");
      selenium.type("//input[@title='Google Search']", "I am using selenium");
      selenium.click("//input[@value = 'Google Search']");
      assertTrue(selenium.isElementPresent("/html/head/title"));
     }
     protected void tearDown() {
      selenium.stop();
     }
    } 

    oXygen Eclipse plugin

    oXygen XML/XSLT: http://www.oxygenxml.com/download_oxygenxml_editor.html#Eclipse
    • it's not all that, but step-through-debugging does work
    • have to manually set the file association defaults to Oxygen types
    • unreadable default colour scheme for Oxygen filetypes. It is difficult to import syntax-highlighting preferences in Eclipse. You're better off setting them yourself.
    • to use step-through debugging, you need to:
      • 'Configure Transformation Scenario' (under XML/XSL menu - it appears when you open an XML or XSL file)
      • open the 'Debug Scenario' perspective in the XML/XSL menu
    • setting the input parameters for debugging is fiddly
    • the XML file being used as input must be "part of the project"

    Eclipse notes

    • File associations are under Preferences | General | Editors | File Associations
    • Background colour is under: Preferences | General | Editors | Text editors 
      • and Preferences | oXygen | Editor
    • Syntax highlighting is under: Preferences | XML | XML Files | Editor | Syntax Coloring
      • and Preferences | oXygen | Editor | Syntax highlighting
    • Eclipse plugins site: http://eclipse-plugins.info/eclipse/
    • How to import/export syntax highlighting colours
    • No word wrap!

      Eclipse plugins

      Eclipse 3.5
          • Target Management (Remote file browsing, via SSH): http://www.eclipse.org/dsdp/tm/
            • works great (but sshfs is simpler)
            • Instead of that, see also http://wills-tech-notes.blogspot.com/2010/07/remote-file-browsing.html
          • XSLT: http://www.eclipse.org/webtools/
            • can't download through update manager, it's too slow
            • supposed to offer XML/XSL features, but I can't see any
          • Oxygen XML/XSLT: http://www.oxygenxml.com/download_oxygenxml_editor.html#Eclipse
            • Works. To use step-through debugging,you need to open the 'Debug Scenario' in the XML or XSL menu (it appears when you open an XML or XSL file)
          • vim -- why not use vim editor inside Eclipse? No good solution, apparently (none of these were tested):
            • http://www.viplugin.com/viplugin/ (2009 - costs a few pounds)
            • http://eclim.org/vim/ (recent)
            • http://vrapper.sourceforge.net/ (recent)
            • http://sourceforge.net/projects/vimplugin/ (2007, but states it supports syntax files)
          • Full Screen: http://code.google.com/p/eclipse-fullscreen/ (just works) 
          • P4WSAD: Perforce plugin: http://www.perforce.com/perforce/products/p4wsad.html (had to download zip file from FTP site and install manually, as automatic install URL was too slow)
            • Plugin can be slow to use if you browse the repository directly, but is faster if you check out, then do right-click | Import as project, and use the standard Eclipse Navigator or Project tab to work with the files.