本文整理汇总了Java中com.intellij.psi.impl.source.jsp.jspJava.JspClass类的典型用法代码示例。如果您正苦于以下问题:Java JspClass类的具体用法?Java JspClass怎么用?Java JspClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JspClass类属于com.intellij.psi.impl.source.jsp.jspJava包,在下文中一共展示了JspClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addReferencesInRange
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
private static void addReferencesInRange(List<ASTNode> array, ASTNode parent, int startOffset, int endOffset) {
if (parent.getElementType() == JavaElementType.JAVA_CODE_REFERENCE || parent.getElementType() == JavaElementType.REFERENCE_EXPRESSION) {
array.add(parent);
return;
}
if (parent.getPsi() instanceof PsiFile) {
JspFile jspFile = JspPsiUtil.getJspFile(parent.getPsi());
if (jspFile != null) {
JspClass jspClass = (JspClass)jspFile.getJavaClass();
if (jspClass != null) {
addReferencesInRange(array, jspClass.getNode(), startOffset, endOffset);
}
return;
}
}
addReferencesInRangeForComposite(array, parent, startOffset, endOffset);
}
示例2: getClassPosition
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
public static int getClassPosition(final PsiClass aClass) {
if (aClass == null || !aClass.isValid()) {
return 0;
}
try {
int pos = aClass instanceof JspClass ? ElementPresentationUtil.CLASS_KIND_JSP : ElementPresentationUtil.getClassKind(aClass);
//abstract class before concrete
if (pos == ElementPresentationUtil.CLASS_KIND_CLASS || pos == ElementPresentationUtil.CLASS_KIND_EXCEPTION) {
boolean isAbstract = aClass.hasModifierProperty(PsiModifier.ABSTRACT) && !aClass.isInterface();
if (isAbstract) {
pos --;
}
}
return pos;
}
catch (IndexNotReadyException e) {
return 0;
}
}
示例3: invoke
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
int offset = editor.getCaretModel().getOffset();
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
PsiElement element = file.findElementAt(offset);
while (true) {
if (element == null || element instanceof PsiFile) {
String message = RefactoringBundle.getCannotRefactorMessage(
RefactoringBundle.message("the.caret.should.be.positioned.inside.a.class.to.push.members.from"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MEMBERS_PUSH_DOWN);
return;
}
if (element instanceof PsiClass || element instanceof PsiField || element instanceof PsiMethod) {
if (element instanceof JspClass) {
RefactoringMessageUtil.showNotSupportedForJspClassesError(project, editor, REFACTORING_NAME, HelpID.MEMBERS_PUSH_DOWN);
return;
}
invoke(project, new PsiElement[]{element}, dataContext);
return;
}
element = element.getParent();
}
}
示例4: tryToMove
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
public boolean tryToMove(final PsiElement element, final Project project, final DataContext dataContext, final PsiReference reference,
final Editor editor) {
if (isNonStaticInnerClass(element) && !JavaMoveClassesOrPackagesHandler.isReferenceInAnonymousClass(reference)) {
PsiClass aClass = (PsiClass) element;
FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.move.moveInner");
final PsiClass containingClass = aClass.getContainingClass();
if (containingClass instanceof JspClass) {
CommonRefactoringUtil.showErrorHint(project, editor, RefactoringBundle.message("move.nonstatic.class.from.jsp.not.supported"),
RefactoringBundle.message("move.title"), null);
return true;
}
MoveInnerImpl.doMove(project, new PsiElement[]{aClass}, null, LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext));
return true;
}
return false;
}
示例5: addReferencesInRange
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
private static void addReferencesInRange(List<ASTNode> array, ASTNode parent, int startOffset, int endOffset) {
if (parent.getElementType() == JavaElementType.JAVA_CODE_REFERENCE || parent.getElementType() == JavaElementType.REFERENCE_EXPRESSION) {
array.add(parent);
return;
}
if (parent.getPsi() instanceof PsiFile) {
JspFile jspFile = JspPsiUtil.getJspFile(parent.getPsi());
if (jspFile != null) {
JspClass jspClass = (JspClass)jspFile.getJavaClass();
addReferencesInRange(array, jspClass.getNode(), startOffset, endOffset);
return;
}
}
addReferencesInRangeForComposite(array, parent, startOffset, endOffset);
}
示例6: canImplementOverride
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
private static boolean canImplementOverride(final MethodHierarchyNodeDescriptor descriptor, final MethodHierarchyBrowser methodHierarchyBrowser, final boolean toImplement) {
final PsiClass psiClass = descriptor.getPsiClass();
if (psiClass == null || psiClass instanceof JspClass) return false;
final PsiMethod baseMethod = methodHierarchyBrowser.getBaseMethod();
if (baseMethod == null) return false;
final MethodSignature signature = baseMethod.getSignature(PsiSubstitutor.EMPTY);
Collection<MethodSignature> allOriginalSignatures = toImplement
? OverrideImplementUtil.getMethodSignaturesToImplement(psiClass)
: OverrideImplementUtil.getMethodSignaturesToOverride(psiClass);
for (final MethodSignature originalSignature : allOriginalSignatures) {
if (originalSignature.equals(signature)) {
return true;
}
}
return false;
}
示例7: invalid4Move
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
public static boolean invalid4Move(PsiElement element) {
PsiFile parentFile;
if (element instanceof PsiClassOwner) {
final PsiClass[] classes = ((PsiClassOwner)element).getClasses();
if (classes.length == 0) return true;
for (PsiClass aClass : classes) {
if (aClass instanceof JspClass) return true;
}
parentFile = (PsiFile)element;
}
else {
if (element instanceof JspClass) return true;
if (!(element instanceof PsiClass)) return true;
if (element instanceof PsiAnonymousClass) return true;
if (((PsiClass)element).getContainingClass() != null) return true;
parentFile = element.getContainingFile();
}
return parentFile instanceof PsiJavaFile && ProjectRootsUtil.isOutsideSourceRoot(parentFile);
}
示例8: getContextClass
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
@Nullable
public static PsiClass getContextClass(Project project, Editor editor, PsiFile file, boolean allowInterface) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
int offset = editor.getCaretModel().getOffset();
PsiElement element = file.findElementAt(offset);
do {
element = PsiTreeUtil.getParentOfType(element, PsiClass.class);
}
while (element instanceof PsiTypeParameter);
final PsiClass aClass = (PsiClass)element;
if (aClass instanceof JspClass) return null;
return aClass == null || !allowInterface && aClass.isInterface() ? null : aClass;
}
示例9: visitClass
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
@Override
public void visitClass(PsiClass aClass) {
super.visitClass(aClass);
if (aClass instanceof JspClass) return;
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkInterfaceMultipleInheritance(aClass));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkDuplicateTopLevelClass(aClass));
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkEnumMustNotBeLocal(aClass));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkImplicitThisReferenceBeforeSuper(aClass, myJavaSdkVersion));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkClassAndPackageConflict(aClass));
}
示例10: checkCreateInnerClassFromStaticContext
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
@Nullable
public static HighlightInfo checkCreateInnerClassFromStaticContext(PsiElement element,
PsiElement placeToSearchEnclosingFrom,
PsiClass aClass) {
if (aClass == null || !PsiUtil.isInnerClass(aClass)) return null;
PsiClass outerClass = aClass.getContainingClass();
if (outerClass == null) return null;
if (outerClass instanceof JspClass || hasEnclosingInstanceInScope(outerClass, placeToSearchEnclosingFrom, true, false)) return null;
return reportIllegalEnclosingUsage(placeToSearchEnclosingFrom, aClass, outerClass, element);
}
示例11: isAvailable
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
private static boolean isAvailable(PsiField field) {
PsiClass containingClass = field == null ? null : field.getContainingClass();
return field != null
&& field.getManager().isInProject(field)
&& !field.hasModifierProperty(PsiModifier.STATIC)
&& containingClass != null
&& !(containingClass instanceof JspClass)
&& containingClass.getName() != null;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:CreateConstructorParameterFromFieldFix.java
示例12: isAvailable
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
if (element instanceof PsiCompiledElement) return false;
final PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class, false, PsiMember.class, PsiCodeBlock.class, PsiDocComment.class);
if (field == null || hasUnsuitableModifiers(field)) return false;
if (!field.hasInitializer()) return false;
PsiClass psiClass = field.getContainingClass();
return psiClass != null && !psiClass.isInterface() && !(psiClass instanceof PsiAnonymousClass) && !(psiClass instanceof JspClass);
}
示例13: buildChildren
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
private void buildChildren(final ArrayList<Block> result, final Alignment childAlignment, final Wrap childWrap) {
ASTNode child = myNode.getFirstChildNode();
int state = BEFORE_FIRST;
if (myNode.getPsi() instanceof JspClass) {
state = INSIDE_BODY;
}
while (child != null) {
if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getTextLength() > 0) {
final Indent indent = calcCurrentIndent(child, state);
state = calcNewState(child, state);
if (child.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT) {
child = processCaseAndStatementAfter(result, child, childAlignment, childWrap, indent);
}
else if (myNode.getElementType() == JavaElementType.CLASS && child.getElementType() == JavaTokenType.LBRACE) {
child = composeCodeBlock(result, child, getCodeBlockExternalIndent(), myChildrenIndent, null);
}
else if (myNode.getElementType() == JavaElementType.CODE_BLOCK && child.getElementType() == JavaTokenType.LBRACE
&& myNode.getTreeParent().getElementType() == JavaElementType.METHOD)
{
child = composeCodeBlock(result, child, indent, myChildrenIndent, childWrap);
}
else {
child = processChild(result, child, chooseAlignment(child, childAlignment), childWrap, indent);
}
}
if (child != null) {
child = child.getTreeNext();
}
}
}
示例14: getQualifiedName
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
@Nullable
@RequiredReadAction
@Override
public String getQualifiedName()
{
PsiClassStub<JspClass> stub = getGreenStub();
if(stub != null)
{
return stub.getQualifiedName();
}
VirtualFile virtualFile = getContainingFile().getVirtualFile();
if(virtualFile == null)
{
return getName();
}
VirtualFile parent = virtualFile.getParent();
if(parent == null)
{
return null;
}
String packageName = ProjectFileIndex.getInstance(getProject()).getPackageNameByDirectory(parent);
if(StringUtil.isEmpty(packageName))
{
return getName();
}
return packageName + "." + getName();
}
示例15: invoke
import com.intellij.psi.impl.source.jsp.jspJava.JspClass; //导入依赖的package包/类
public void invoke(@NotNull final Project project, @NotNull final PsiElement[] elements, final DataContext dataContext) {
if (elements.length != 1 || !(elements[0] instanceof PsiMethod)) return;
final PsiMethod method = (PsiMethod)elements[0];
String message = null;
if (!method.getManager().isInProject(method)) {
message = "Move method is not supported for non-project methods";
} else if (method.isConstructor()) {
message = RefactoringBundle.message("move.method.is.not.supported.for.constructors");
} else if (method.getLanguage()!= JavaLanguage.INSTANCE) {
message = RefactoringBundle.message("move.method.is.not.supported.for.0", method.getLanguage().getDisplayName());
}
else {
final PsiClass containingClass = method.getContainingClass();
if (containingClass != null && PsiUtil.typeParametersIterator(containingClass).hasNext() && TypeParametersSearcher.hasTypeParameters(method)) {
message = RefactoringBundle.message("move.method.is.not.supported.for.generic.classes");
}
else if (method.findSuperMethods().length > 0 ||
OverridingMethodsSearch.search(method, true).toArray(PsiMethod.EMPTY_ARRAY).length > 0) {
message = RefactoringBundle.message("move.method.is.not.supported.when.method.is.part.of.inheritance.hierarchy");
}
else {
final Set<PsiClass> classes = MoveInstanceMembersUtil.getThisClassesToMembers(method).keySet();
for (PsiClass aClass : classes) {
if (aClass instanceof JspClass) {
message = RefactoringBundle.message("synthetic.jsp.class.is.referenced.in.the.method");
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MOVE_INSTANCE_METHOD);
break;
}
}
}
}
if (message != null) {
showErrorHint(project, dataContext, message);
return;
}
final List<PsiVariable> suitableVariables = new ArrayList<PsiVariable>();
message = collectSuitableVariables(method, suitableVariables);
if (message != null) {
final String unableToMakeStaticMessage = MakeStaticHandler.validateTarget(method);
if (unableToMakeStaticMessage != null) {
showErrorHint(project, dataContext, message);
}
else {
final String suggestToMakeStaticMessage = "Would you like to make method \'" + method.getName() + "\' static and then move?";
if (Messages
.showYesNoCancelDialog(project, message + ". " + suggestToMakeStaticMessage,
REFACTORING_NAME, Messages.getErrorIcon()) == Messages.YES) {
MakeStaticHandler.invoke(method);
}
}
return;
}
new MoveInstanceMethodDialog(
method,
suitableVariables.toArray(new PsiVariable[suitableVariables.size()])).show();
}