public class SourceWriteUtil extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
SourceWriteUtil.Factory
Factory for
SourceWriteUtil . |
Modifier | Constructor and Description |
---|---|
protected |
SourceWriteUtil(GuiceUtil guiceUtil,
MemberCollector memberCollector,
MethodCallUtil methodCallUtil,
BindingIndex bindingIndex) |
Modifier and Type | Method and Description |
---|---|
SourceSnippet |
createFieldInjection(FieldLiteral<?> field,
String injecteeName,
NameGenerator nameGenerator,
List<InjectorMethod> methodsOutput)
Creates a field injecting method and returns a string that invokes the
written method.
|
SourceSnippet |
createFieldInjections(Iterable<FieldLiteral<?>> fields,
String injecteeName,
NameGenerator nameGenerator,
List<InjectorMethod> methodsOutput)
Appends a field injecting method for each passed field to the
sourceWriter and returns a string that invokes all written
methods. |
String |
createMemberInjection(TypeLiteral<?> type,
NameGenerator nameGenerator,
List<InjectorMethod> methodsOutput)
Generates all the required injector methods to inject members of the given
type, and a standard member-inject method that invokes them.
|
SourceSnippet |
createMethodInjections(Iterable<? extends MethodLiteral<?,?>> methods,
String injecteeName,
NameGenerator nameGenerator,
List<InjectorMethod> methodsOutput)
Creates a method injecting method and returns a string that invokes the new
method.
|
static CharSequence |
join(CharSequence delimiter,
Iterable<? extends CharSequence> list) |
void |
writeBindingContext(com.google.gwt.user.rebind.SourceWriter writer,
Context context)
Writes out a binding context, followed by a newline.
|
void |
writeBindingContextJavadoc(com.google.gwt.user.rebind.SourceWriter writer,
Context bindingContext,
Key<?> key)
Write the Javadoc for the binding of a particular key, showing the context
of the binding.
|
void |
writeBindingContextJavadoc(com.google.gwt.user.rebind.SourceWriter writer,
Context bindingContext,
String description)
Write a Javadoc comment for a binding, including its context.
|
void |
writeMethod(InjectorMethod method,
com.google.gwt.user.rebind.SourceWriter writer,
InjectorWriteContext writeContext)
Writes the given method to the given source writer.
|
void |
writeMethod(com.google.gwt.user.rebind.SourceWriter writer,
String signature,
String body)
Writes a method with the given signature and body to the source writer.
|
void |
writeMethods(Iterable<InjectorMethod> methods,
com.google.gwt.user.rebind.SourceWriter writer,
InjectorWriteContext writeContext)
Writes the given methods to the given source writer.
|
void |
writeNativeMethod(com.google.gwt.user.rebind.SourceWriter writer,
String signature,
String body)
Writes a native method with the given signature and body to the source
writer.
|
@Inject protected SourceWriteUtil(GuiceUtil guiceUtil, MemberCollector memberCollector, MethodCallUtil methodCallUtil, BindingIndex bindingIndex)
public SourceSnippet createFieldInjections(Iterable<FieldLiteral<?>> fields, String injecteeName, NameGenerator nameGenerator, List<InjectorMethod> methodsOutput) throws NoSourceNameException
sourceWriter
and returns a string that invokes all written
methods.fields
- fields to be injectedinjecteeName
- variable that references the object into which values
are injected, in the context of the returned call stringNoSourceNameException
public SourceSnippet createFieldInjection(FieldLiteral<?> field, String injecteeName, NameGenerator nameGenerator, List<InjectorMethod> methodsOutput) throws NoSourceNameException
field
- field to be injectedinjecteeName
- variable that references the object into which values
are injected, in the context of the returned call stringnameGenerator
- NameGenerator to be used for ensuring method name uniquenessNoSourceNameException
public SourceSnippet createMethodInjections(Iterable<? extends MethodLiteral<?,?>> methods, String injecteeName, NameGenerator nameGenerator, List<InjectorMethod> methodsOutput) throws NoSourceNameException
Ginjector
.
If the passed method collection contains only one actual method, the native
method will pass on (i.e. return) the result of the actual method's
invocation, if any.
The passed method collection can contain constructors (they'll be treated
correctly) if no injecteeName
is passed. The same applies for
static methods.
If a method without parameters is provided, that method will be called and
no parameters will be passed.methods
- methods to be called & injectedinjecteeName
- variable that references the object into which values
are injected, in the context of the returned call string. If
null
all passed methods are called as static/constructors.nameGenerator
- NameGenerator to be used for ensuring method name uniquenessmethodsOutput
- a list where all new methods created by this
call are addedNoSourceNameException
public void writeBindingContext(com.google.gwt.user.rebind.SourceWriter writer, Context context)
Binding contexts may contain newlines; this routine translates those for the SourceWriter to ensure that indents, Javadoc comments, etc are handled properly.
public void writeBindingContextJavadoc(com.google.gwt.user.rebind.SourceWriter writer, Context bindingContext, String description)
description
- The description of the binding printed before its
location, such as "Foo bound at: "writer
- The writer to use in displaying the context.bindingContext
- The context of the binding.public void writeBindingContextJavadoc(com.google.gwt.user.rebind.SourceWriter writer, Context bindingContext, Key<?> key)
key
- The bound key.writer
- The writer to use to write this comment.bindingContext
- The context of the binding.public void writeMethod(com.google.gwt.user.rebind.SourceWriter writer, String signature, String body)
writer
- writer that the method is written tosignature
- method's signaturebody
- method's bodypublic void writeNativeMethod(com.google.gwt.user.rebind.SourceWriter writer, String signature, String body)
writer
- writer that the method is written tosignature
- method's signaturebody
- method's bodypublic void writeMethod(InjectorMethod method, com.google.gwt.user.rebind.SourceWriter writer, InjectorWriteContext writeContext) throws NoSourceNameException
NoSourceNameException
public void writeMethods(Iterable<InjectorMethod> methods, com.google.gwt.user.rebind.SourceWriter writer, InjectorWriteContext writeContext) throws NoSourceNameException
methods
- the methods to writewriter
- the source writer to which the methods should be writtenwriteContext
- the context in which to write the methodsNoSourceNameException
public String createMemberInjection(TypeLiteral<?> type, NameGenerator nameGenerator, List<InjectorMethod> methodsOutput) throws NoSourceNameException
type
- type for which the injection is performednameGenerator
- the name generator used to create method namesmethodsOutput
- a list to which the new injection method and all its
helpers are addedNoSourceNameException
public static CharSequence join(CharSequence delimiter, Iterable<? extends CharSequence> list)
Copyright © 2008–2018. All rights reserved.