Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update plugin with new layout; Add Lombok support
- Loading branch information
Showing
26 changed files
with
1,268 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
target | ||
release_notes.md | ||
.idea | ||
rest-griffonPluginFixes.iml | ||
rest-griffonPlugins.iml | ||
rest.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
app.griffon.version=0.9.5-rc2 | ||
#Griffon Metadata file | ||
#Mon Dec 03 11:16:52 CET 2012 | ||
app.griffon.version=1.2.0-SNAPSHOT | ||
app.name=rest | ||
plugins.lombok=0.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/cli/META-INF/services/de.plushnikov.intellij.lombok.processor.LombokProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.intellij.processor.clazz.RestAwareProcessor |
1 change: 1 addition & 0 deletions
1
src/cli/META-INF/services/de.plushnikov.intellij.lombok.processor.clazz.LombokClassProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.intellij.processor.clazz.RestAwareProcessor |
1 change: 1 addition & 0 deletions
1
src/cli/META-INF/services/lombok.eclipse.EclipseAnnotationHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.eclipse.handlers.HandleRestAware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.javac.handlers.HandleRestAware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2012 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dsld | ||
|
||
/** | ||
* @author Andres Almiray | ||
*/ | ||
|
||
contribute(enclosingClass(annotatedBy('griffon.plugins.rest.RestAware'))) { | ||
provider = "Rest DSL" | ||
delegatesTo "griffon.plugins.rest.RestContributionHandler" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2012 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package gdsl | ||
|
||
/** | ||
* @author Andres Almiray | ||
*/ | ||
|
||
contributor(scope: annotatedScope(ctype: 'griffon.plugins.rest.RestAware')) { | ||
delegatesTo(findClass('griffon.plugins.rest.RestContributionHandler')) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2012 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package griffon.plugins.rest; | ||
|
||
import org.codehaus.groovy.transform.GroovyASTTransformationClass; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* <p>Annotates a class.</p> | ||
* | ||
* @author Andres Almiray | ||
* @see org.codehaus.griffon.ast.RestAwareASTTransformation | ||
*/ | ||
@Retention(RetentionPolicy.SOURCE) | ||
@Target(ElementType.TYPE) | ||
@GroovyASTTransformationClass("org.codehaus.griffon.ast.RestAwareASTTransformation") | ||
public @interface RestAware { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright 2012 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package lombok.core.handlers; | ||
|
||
import lombok.core.BaseConstants; | ||
import lombok.core.util.MethodDescriptor; | ||
|
||
import static lombok.core.util.MethodDescriptor.args; | ||
import static lombok.core.util.MethodDescriptor.type; | ||
import static lombok.core.util.MethodDescriptor.typeParams; | ||
|
||
/** | ||
* @author Andres Almiray | ||
*/ | ||
public interface RestAwareConstants extends BaseConstants { | ||
String REST_PROVIDER_TYPE = "griffon.plugins.rest.RestProvider"; | ||
String DEFAULT_REST_PROVIDER_TYPE = "griffon.plugins.rest.DefaultRestProvider"; | ||
String REST_CONTRIBUTION_HANDLER_TYPE = "griffon.plugins.rest.RestContributionHandler"; | ||
String REST_PROVIDER_FIELD_NAME = "this$restProvider"; | ||
String METHOD_GET_REST_PROVIDER = "getRestProvider"; | ||
String METHOD_SET_REST_PROVIDER = "setRestProvider"; | ||
String METHOD_WITH_ASYNC_HTTP = "withAsyncHttp"; | ||
String METHOD_WITH_REST = "withRest"; | ||
String METHOD_WITH_HTTP = "withHttp"; | ||
String PROVIDER = "provider"; | ||
|
||
MethodDescriptor[] METHODS = new MethodDescriptor[]{ | ||
MethodDescriptor.method( | ||
type(R), | ||
typeParams(R), | ||
METHOD_WITH_HTTP, | ||
args( | ||
type(JAVA_UTIL_MAP, JAVA_LANG_STRING, JAVA_LANG_OBJECT), | ||
type(GROOVY_LANG_CLOSURE, R)) | ||
), | ||
MethodDescriptor.method( | ||
type(R), | ||
typeParams(R), | ||
METHOD_WITH_REST, | ||
args( | ||
type(JAVA_UTIL_MAP, JAVA_LANG_STRING, JAVA_LANG_OBJECT), | ||
type(GROOVY_LANG_CLOSURE, R)) | ||
), | ||
MethodDescriptor.method( | ||
type(R), | ||
typeParams(R), | ||
METHOD_WITH_ASYNC_HTTP, | ||
args( | ||
type(JAVA_UTIL_MAP, JAVA_LANG_STRING, JAVA_LANG_OBJECT), | ||
type(GROOVY_LANG_CLOSURE, R)) | ||
), | ||
MethodDescriptor.method( | ||
type(R), | ||
typeParams(R), | ||
METHOD_WITH_HTTP, | ||
args( | ||
type(JAVA_UTIL_MAP, JAVA_LANG_STRING, JAVA_LANG_OBJECT), | ||
type(GRIFFON_UTIL_CALLABLEWITHARGS, R)) | ||
), | ||
MethodDescriptor.method( | ||
type(R), | ||
typeParams(R), | ||
METHOD_WITH_REST, | ||
args( | ||
type(JAVA_UTIL_MAP, JAVA_LANG_STRING, JAVA_LANG_OBJECT), | ||
type(GRIFFON_UTIL_CALLABLEWITHARGS, R)) | ||
), | ||
MethodDescriptor.method( | ||
type(R), | ||
typeParams(R), | ||
METHOD_WITH_ASYNC_HTTP, | ||
args( | ||
type(JAVA_UTIL_MAP, JAVA_LANG_STRING, JAVA_LANG_OBJECT), | ||
type(GRIFFON_UTIL_CALLABLEWITHARGS, R)) | ||
) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2012 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package lombok.core.handlers; | ||
|
||
import lombok.ast.Expression; | ||
import lombok.ast.IMethod; | ||
import lombok.ast.IType; | ||
|
||
import static lombok.ast.AST.*; | ||
|
||
/** | ||
* @author Andres Almiray | ||
*/ | ||
public abstract class RestAwareHandler<TYPE_TYPE extends IType<? extends IMethod<?, ?, ?, ?>, ?, ?, ?, ?, ?>> extends AbstractHandler<TYPE_TYPE> implements RestAwareConstants { | ||
private Expression<?> defaultRestProviderInstance() { | ||
return Call(Name(DEFAULT_REST_PROVIDER_TYPE), "getInstance"); | ||
} | ||
|
||
public void addRestProviderField(final TYPE_TYPE type) { | ||
addField(type, REST_PROVIDER_TYPE, REST_PROVIDER_FIELD_NAME, defaultRestProviderInstance()); | ||
} | ||
|
||
public void addRestProviderAccessors(final TYPE_TYPE type) { | ||
type.editor().injectMethod( | ||
MethodDecl(Type(VOID), METHOD_SET_REST_PROVIDER) | ||
.makePublic() | ||
.withArgument(Arg(Type(REST_PROVIDER_TYPE), PROVIDER)) | ||
.withStatement( | ||
If(Equal(Name(PROVIDER), Null())) | ||
.Then(Block() | ||
.withStatement(Assign(Field(REST_PROVIDER_FIELD_NAME), defaultRestProviderInstance()))) | ||
.Else(Block() | ||
.withStatement(Assign(Field(REST_PROVIDER_FIELD_NAME), Name(PROVIDER))))) | ||
); | ||
|
||
type.editor().injectMethod( | ||
MethodDecl(Type(REST_PROVIDER_TYPE), METHOD_GET_REST_PROVIDER) | ||
.makePublic() | ||
.withStatement(Return(Field(REST_PROVIDER_FIELD_NAME))) | ||
); | ||
} | ||
|
||
public void addRestContributionMethods(final TYPE_TYPE type) { | ||
delegateMethodsTo(type, METHODS, Field(REST_PROVIDER_FIELD_NAME)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2012 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package lombok.eclipse.handlers; | ||
|
||
import griffon.plugins.rest.RestAware; | ||
import lombok.core.AnnotationValues; | ||
import lombok.core.handlers.RestAwareConstants; | ||
import lombok.core.handlers.RestAwareHandler; | ||
import lombok.eclipse.EclipseAnnotationHandler; | ||
import lombok.eclipse.EclipseNode; | ||
import lombok.eclipse.handlers.ast.EclipseType; | ||
import org.eclipse.jdt.internal.compiler.ast.Annotation; | ||
|
||
import static lombok.core.util.ErrorMessages.canBeUsedOnClassAndEnumOnly; | ||
|
||
/** | ||
* @author Andres Almiray | ||
*/ | ||
public class HandleRestAware extends EclipseAnnotationHandler<RestAware> { | ||
private final EclipseRestAwareHandler handler = new EclipseRestAwareHandler(); | ||
|
||
@Override | ||
public void handle(AnnotationValues<RestAware> annotation, Annotation source, EclipseNode annotationNode) { | ||
EclipseType type = EclipseType.typeOf(annotationNode, source); | ||
if (type.isAnnotation() || type.isInterface()) { | ||
annotationNode.addError(canBeUsedOnClassAndEnumOnly(RestAware.class)); | ||
return; | ||
} | ||
|
||
EclipseUtil.addInterface(type.get(), RestAwareConstants.REST_CONTRIBUTION_HANDLER_TYPE, source); | ||
handler.addRestProviderField(type); | ||
handler.addRestProviderAccessors(type); | ||
handler.addRestContributionMethods(type); | ||
type.editor().rebuild(); | ||
} | ||
|
||
private static class EclipseRestAwareHandler extends RestAwareHandler<EclipseType> { | ||
} | ||
} |
Oops, something went wrong.