public class JavaCodeFragmentFactoryImpl extends JavaCodeFragmentFactory
ALLOW_DISJUNCTION, ALLOW_ELLIPSIS, ALLOW_INTERSECTION, ALLOW_VOID
Constructor and Description |
---|
JavaCodeFragmentFactoryImpl(Project project) |
Modifier and Type | Method and Description |
---|---|
JavaCodeFragment |
createCodeBlockCodeFragment(java.lang.String text,
PsiElement context,
boolean isPhysical)
Creates a Java code fragment from the text of a Java code block.
|
PsiExpressionCodeFragment |
createExpressionCodeFragment(java.lang.String text,
PsiElement context,
PsiType expectedType,
boolean isPhysical)
Creates a Java expression code fragment from the text of the expression.
|
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).
|
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.
|
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. |
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. |
getInstance
public JavaCodeFragmentFactoryImpl(Project project)
public PsiExpressionCodeFragment createExpressionCodeFragment(java.lang.String text, PsiElement context, PsiType expectedType, boolean isPhysical)
JavaCodeFragmentFactory
createExpressionCodeFragment
in class JavaCodeFragmentFactory
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 JavaCodeFragment createCodeBlockCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical)
JavaCodeFragmentFactory
createCodeBlockCodeFragment
in class JavaCodeFragmentFactory
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 PsiTypeCodeFragment createTypeCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical)
JavaCodeFragmentFactory
void
and ellipsis
not treated as a valid type.createTypeCodeFragment
in class JavaCodeFragmentFactory
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 PsiTypeCodeFragment createTypeCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical, int flags)
JavaCodeFragmentFactory
void
, ellipsis and disjunctive types are optionally treated as valid ones.createTypeCodeFragment
in class JavaCodeFragmentFactory
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 PsiJavaCodeReferenceCodeFragment createReferenceCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical, boolean isClassesAccepted)
JavaCodeFragmentFactory
createReferenceCodeFragment
in class JavaCodeFragmentFactory
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 JavaCodeFragment createMemberCodeFragment(java.lang.String text, PsiElement context, boolean isPhysical)
JavaCodeFragmentFactory
createMemberCodeFragment
in class JavaCodeFragmentFactory
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()
).