Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Version #1

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
34 changes: 34 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>lombok.eclipseplugin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
2 changes: 2 additions & 0 deletions .settings/org.eclipse.jdt.ui.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (C) 2009 The Project Lombok Authors.\r\n * \r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the "Software"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions\:\r\n * \r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n * \r\n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n */\r\n</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Lombok.eclipseplugin contributors:

Reinier Zwitserloot <[email protected]>
Rabea Gransberger <[email protected]>

By adding your name to this list, you grant full and irrevocable copyright and patent indemnity to Project Lombok and all use of Project Lombok, and you certify that you have the right to do so for all commits you add to Project Lombok.
19 changes: 19 additions & 0 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: lombok.eclipse;singleton:=true
Bundle-Version: 0.11.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-Activator: lombok.eclipse.internal.LombokEclipsePlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.jdt;bundle-version="3.6.0",
org.eclipse.jdt.core,
org.eclipse.jdt.core.manipulation,
org.eclipse.jdt.ui,
org.eclipse.text,
org.eclipse.ltk.core.refactoring,
org.eclipse.ltk.ui.refactoring
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

3 changes: 3 additions & 0 deletions OSGI-INF/l10n/bundle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Properties file for lombok.eclipse
Bundle-Name = Lombok Eclipse Plugin
refactor.action.label = Use Lombok Annotations...
7 changes: 5 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
Eclipse plugin for [Project Lombok](http://projectlombok.org)

Currently provides refactoring for simple getters and setters to Lombok Annotations.

build instructions:

`ant eclipse`
Import the project from this repository as Plug-In Project into Eclipse.

then import the directory as a project into eclipse.
Export from the Overview-Tab of the plugin.xml file and drop the exported file
into your Eclipse application or choose 'Launch an Eclipse application' for testing.

2 changes: 2 additions & 0 deletions articles.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
http://www.eclipse.org/articles/article.php?file=Article-Unleashing-the-Power-of-Refactoring/index.html
http://wiki.fernuni-hagen.de/eclipse/index.php/Eigenes_Refactoring-Tool_f%C3%BCr_Eclipse_schreiben
8 changes: 8 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
OSGI-INF/l10n/bundle.properties,\
OSGI-INF/

26 changes: 26 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ltk.core.refactoring.refactoringContributions">
<contribution
class="lombok.eclipse.refactoring.LombokRefactoringContribution"
id="lombok.eclipse.refactoring.tolombok">
</contribution>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="false"
id="lombok.eclipse.refactoring.contribution"
objectClass="org.eclipse.jdt.core.IJavaElement">
<action
class="lombok.eclipse.actions.LombokRefactorAction"
id="lombok.eclipse.refactoring.tolombok"
label="%refactor.action.label"
menubarPath="org.eclipse.jdt.ui.refactoring.menu/codingGroup"
style="push">
</action>
</objectContribution>
</extension>
</plugin>
111 changes: 111 additions & 0 deletions src/lombok/eclipse/actions/LombokRefactorAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Copyright (C) 2009 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package lombok.eclipse.actions;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import lombok.eclipse.i18n.Messages;
import lombok.eclipse.internal.LombokEclipsePlugin.Logger;
import lombok.eclipse.refactoring.LombokRefactoring;
import lombok.eclipse.refactoring.LombokRefactoringDescriptor;
import lombok.eclipse.refactoring.RefactoringElement;
import lombok.eclipse.wizards.LombokRefactoringWizard;

import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;

public class LombokRefactorAction implements IObjectActionDelegate {

private IWorkbenchPart activePart;
private final List<RefactoringElement> elements = new ArrayList<RefactoringElement>();

public void dispose() {
// Do nothing
}

@Override
public void run(IAction action) {
if (!this.elements.isEmpty()) {
LombokRefactoringDescriptor descriptor = new LombokRefactoringDescriptor();
descriptor.getArguments().setElements(this.elements);
LombokRefactoring refactoring = new LombokRefactoring(descriptor);
run(new LombokRefactoringWizard(refactoring), this.activePart.getSite().getShell(),
Messages.LombokRefactorAction_wizard_title);
}
}

public void run(RefactoringWizard wizard, Shell parent, String failedCheckDialogTitle) {
try {
RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wizard);
operation.run(parent, failedCheckDialogTitle);
} catch (InterruptedException exception) {
// if the initial condition checking got canceled by the user.
// do nothing, just return
}
}

@Override
public void selectionChanged(IAction action, ISelection selection) {
this.elements.clear();
if (selection instanceof IStructuredSelection) {
IStructuredSelection extended = (IStructuredSelection) selection;
for (Iterator<?> it = extended.iterator(); it.hasNext();) {
Object o = it.next();
checkAndAddSelectedElement(o);
}
}
action.setEnabled(!this.elements.isEmpty());
}

@Override
public void setActivePart(IAction action, IWorkbenchPart activePart) {
this.activePart = activePart;
}

private void checkAndAddSelectedElement(Object o) {
RefactoringElement element = isSupportedElement(o);
if (element != null) {
this.elements.add(element);
} else {
Logger.warn(MessageFormat.format(Messages.LombokRefactorAction_unsupported_element, o.getClass().getName()));
}
}

private RefactoringElement isSupportedElement(Object o) {
if (o instanceof IJavaElement) {
RefactoringElement supported = RefactoringElement.Factory.create((IJavaElement) o);
return supported;
} else {
return null;
}
}
}
47 changes: 47 additions & 0 deletions src/lombok/eclipse/i18n/Messages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package lombok.eclipse.i18n;

import org.eclipse.osgi.util.NLS;

public class Messages extends NLS {
private static final String BUNDLE_NAME = "lombok.eclipse.i18n.messages"; //$NON-NLS-1$
public static String LombokRefactorAction_unsupported_element;
public static String LombokRefactorAction_wizard_title;
public static String LombokRefactoringWizard_title;
public static String LombokRefactoringWizardPage_equals_hashcode_check;
public static String LombokRefactoringWizardPage_getter_check;
public static String LombokRefactoringWizardPage_message;
public static String LombokRefactoringWizardPage_setter_check;
public static String LombokRefactoringWizardPage_tostring_check;
public static String LombokRefactoring_change_comment_element;
public static String LombokRefactoring_change_comment_elements_title;
public static String LombokRefactoring_change_comment_equals_hashcode;
public static String LombokRefactoring_change_comment_getter;
public static String LombokRefactoring_change_comment_project;
public static String LombokRefactoring_change_comment_setter;
public static String LombokRefactoring_change_comment_tostring;
public static String LombokRefactoring_change_description;
public static String LombokRefactoring_create_change_monitor_begin;
public static String LombokRefactoring_final_condition_monitor_begin;
public static String LombokRefactoring_initial_condition_monitor_begin;
public static String LombokRefactoring_more_than_one_project;
public static String LombokRefactoring_no_types;
public static String LombokRefactoring_title;
public static String LombokRefactoringDescriptor_not_registered;
public static String RefactoringElement_does_not_match_type;
public static String RefactoringElement_impossible_binary;
public static String RefactoringElement_non_existing_type;
public static String RefactoringElement_not_consistent;
public static String RefactoringElement_type_name_compilation_unit;
public static String RefactoringElement_type_name_package;
public static String RefactoringElement_type_name_package_root;
public static String RefactoringElement_type_name_project;
public static String RefactoringElement_type_name_type;
public static String RefactoringElement_unknown_structure;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}

private Messages() {
}
}
Loading