public abstract class JavaCodeFragmentFactory
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ALLOW_DISJUNCTION
Flag for createTypeCodeFragment(String, PsiElement, boolean, int) - allows disjunctive type.
|
static int |
ALLOW_ELLIPSIS
Flag for createTypeCodeFragment(String, PsiElement, boolean, int) - allows type with ellipsis.
|
static int |
ALLOW_INTERSECTION
Flag for createTypeCodeFragment(String, PsiElement, boolean, int) - allows conjunctive type.
|
static int |
ALLOW_VOID
Flag for createTypeCodeFragment(String, PsiElement, boolean, int) - allows void type.
|
Constructor and Description |
---|
JavaCodeFragmentFactory() |
Modifier and Type | Method and Description |
---|---|
abstract JavaCodeFragment |
createCodeBlockCodeFragment(java.lang.String text,
PsiElement context,
boolean isPhysical)
Creates a Java code fragment from the text of a Java code block.
|
abstract PsiExpressionCodeFragment |
createExpressionCodeFragment(java.lang.String text,
PsiElement context,
PsiType expectedType,
boolean isPhysical)
Creates a Java expression code fragment from the text of the expression.
|
abstract JavaCodeFragment |
createMemberCodeFragment(java.lang.String text,
PsiElement context,
boolean isPhysical)
Creates a Java code fragment from the text of a Java class member (field, method, class initializer, nested class).
|
abstract PsiJavaCodeReferenceCodeFragment |
createReferenceCodeFragment(java.lang.String text,
PsiElement context,
boolean isPhysical,
boolean isClassesAccepted)
Creates a Java reference code fragment from the text of a Java reference to a
package or class.
|
abstract PsiTypeCodeFragment |
createTypeCodeFragment(java.lang.String text,
PsiElement context,
boolean isPhysical)
Creates a Java type code fragment from the text of the name of a Java type (the name
of a primitive type, array type or class), with
void and ellipsis
not treated as a valid type. |
abstract PsiTypeCodeFragment |
createTypeCodeFragment(java.lang.String text,
PsiElement context,
boolean isPhysical,
int flags)
Creates a Java type code fragment from the text of the name of a Java type (the name
of a primitive type, array type or class).
void , ellipsis and disjunctive types are optionally treated as valid ones. |
static JavaCodeFragmentFactory |
getInstance(Project project) |
public static final int ALLOW_VOID
public static final int ALLOW_ELLIPSIS
public static final int ALLOW_DISJUNCTION
public static final int ALLOW_INTERSECTION
public static JavaCodeFragmentFactory getInstance(Project project)
public abstract PsiExpressionCodeFragment createExpressionCodeFragment(java.lang.String text, PsiElement context, PsiType expectedType, boolean isPhysical)
text
- the text of the expression to create.context
- the context for resolving references from the code fragment.expectedType
- expected type of the expression (does not have any effect on creation
but can be accessed as PsiExpressionCodeFragment.getExpectedType()
).isPhysical
- whether the code fragment is created as a physical element
(see PsiElement.isPhysical()
).public abstract JavaCodeFragment createCodeBlockCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical)
text
- the text of the code block to create.context
- the context for resolving references from the code fragment.isPhysical
- whether the code fragment is created as a physical element
(see PsiElement.isPhysical()
).public abstract PsiTypeCodeFragment createTypeCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical)
void
and ellipsis
not treated as a valid type.text
- the text of the Java type to create.context
- the context for resolving references from the code fragment.isPhysical
- whether the code fragment is created as a physical element
(see PsiElement.isPhysical()
).public abstract PsiTypeCodeFragment createTypeCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical, int flags)
void
, ellipsis and disjunctive types are optionally treated as valid ones.text
- the text of the Java type to create.context
- the context for resolving references from the code fragment.isPhysical
- whether the code fragment is created as a physical element
(see PsiElement.isPhysical()
).flags
- types allowed to present in text.public abstract PsiJavaCodeReferenceCodeFragment createReferenceCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical, boolean isClassesAccepted)
text
- the text of the reference to create.context
- the context for resolving the reference.isPhysical
- whether the code fragment is created as a physical element
(see PsiElement.isPhysical()
).isClassesAccepted
- if true then classes as well as packages are accepted as
reference target, otherwise only packages arepublic abstract JavaCodeFragment createMemberCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical)
text
- the text of the member to createcontext
- the context for resolving references from the memberisPhysical
- whether the code fragment is created as a physical element
(see PsiElement.isPhysical()
).