• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PsiClassImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.psi.impl.source.PsiClassImpl的典型用法代码示例。如果您正苦于以下问题:Java PsiClassImpl类的具体用法?Java PsiClassImpl怎么用?Java PsiClassImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PsiClassImpl类属于com.intellij.psi.impl.source包,在下文中一共展示了PsiClassImpl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: findEnclosingName

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Nullable
private static String findEnclosingName(final SourcePosition position) {
  PsiElement element = findElementAt(position);
  while (true) {
    element = PsiTreeUtil.getParentOfType(element, GrTypeDefinition.class, PsiClassImpl.class);
    if (element == null
        || (element instanceof GrTypeDefinition && !((GrTypeDefinition)element).isAnonymous())
        || (element instanceof PsiClassImpl && ((PsiClassImpl)element).getName() != null)
      ) {
      break;
    }
  }

  if (element != null) {
    return getClassNameForJvm((PsiClass)element);
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:SpringLoadedPositionManager.java


示例2: getOuterClassName

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Nullable
private static String getOuterClassName(final SourcePosition position) {
  AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();

  try {
    PsiElement element = findElementAt(position);
    if (element == null) return null;
    PsiElement sourceImage = PsiTreeUtil.getParentOfType(element, GrClosableBlock.class, GrTypeDefinition.class, PsiClassImpl.class);

    if (sourceImage instanceof PsiClass) {
      return getClassNameForJvm((PsiClass)sourceImage);
    }
    return null;
  }
  finally {
    accessToken.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SpringLoadedPositionManager.java


示例3: visitClass

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Override
public void visitClass(PsiClass aClass) {
    if (InspectionPsiUtil.isAbstactClass(aClass)) {
        return;
    }

    if (!(aClass instanceof PsiClassImpl)) {
        return;
    }

    Project project = aClass.getProject();
    PsiClass activityClass = InspectionPsiUtil.createPsiClass(QUALIFIED_NAME_OF_SUPER_CLASS, project);
    if (activityClass == null || !aClass.isInheritor(activityClass,
            true)) {
        return;
    }

    PsiMethod[] methods = aClass.getMethods();
    for (PsiMethod method : methods) {
        if (isTargetMethod(method)) {
            return;
        }
    }

    registerProblem(aClass);
}
 
开发者ID:shiraji,项目名称:create-intent-inspection,代码行数:27,代码来源:CreateIntentInspectionVisitor.java


示例4: visitClass

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Override
public void visitClass(PsiClass aClass) {
    if (InspectionPsiUtil.isAbstactClass(aClass)) {
        return;
    }

    if (!(aClass instanceof PsiClassImpl)) {
        return;
    }

    if (!isFragment(aClass)) {
        return;
    }

    PsiMethod[] methods = aClass.getMethods();

    for (PsiMethod method : methods) {
        if (isNewInstanceMethod(aClass, method)) {
            return;
        }
    }

    registerProblem(aClass);
}
 
开发者ID:shiraji,项目名称:new-instance-inspection,代码行数:25,代码来源:NewInstanceInspectionVisitor.java


示例5: TestIsImplicitUsageForClass

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Test
public void TestIsImplicitUsageForClass() throws Exception {
    ModuleHelper helper = mock(ModuleHelper.class);
    PsiClass c = mock(PsiClassImpl.class);
    PsiMethod method = mock(PsiMethod.class);
    PsiModifierList list = mock(PsiModifierList.class);
    PsiAnnotation annotation = mock(PsiAnnotation.class);
    when(annotation.getQualifiedName()).thenReturn(BeforeStep.class.getCanonicalName());
    when(list.getAnnotations()).thenReturn(new PsiAnnotation[]{annotation});
    when(method.getModifierList()).thenReturn(list);
    when(c.getMethods()).thenReturn(new PsiMethod[]{method});
    when(helper.isGaugeModule(c)).thenReturn(true);

    boolean isUsed = new ImplUsageProvider(null, helper).isImplicitUsage(c);

    assertTrue(isUsed);
}
 
开发者ID:getgauge,项目名称:Intellij-Plugin,代码行数:18,代码来源:ImplUsageProviderTest.java


示例6: getRootClassUnderOperation

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Nullable
private static PsiClassImpl getRootClassUnderOperation(PsiFile psiFile) {
    Optional<PsiClassImpl> javaClass = Stream.of(psiFile.getChildren())
            .filter(psiElement -> psiElement instanceof PsiClassImpl)
            .map(psiElement -> (PsiClassImpl) psiElement).findFirst();
    if (!javaClass.isPresent()) {
        return null;
    }
    PsiClassImpl psiJavaClass = javaClass.get();
    return psiJavaClass;
}
 
开发者ID:Ingwersaft,项目名称:ValueClassGenerator,代码行数:12,代码来源:GenerateValueClassHandler.java


示例7: createPsi

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Override
public PsiClass createPsi(@NotNull final ASTNode node) {
  if (node instanceof EnumConstantInitializerElement) {
    return new PsiEnumConstantInitializerImpl(node);
  }
  else if (node instanceof AnonymousClassElement) {
    return new PsiAnonymousClassImpl(node);
  }

  return new PsiClassImpl(node);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:JavaClassElementType.java


示例8: isEnumValuesMethodUsed

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
private static boolean isEnumValuesMethodUsed(@NotNull Project project,
                                              @NotNull PsiFile containingFile,
                                              @NotNull PsiMember member,
                                              @NotNull ProgressIndicator progress,
                                              @NotNull GlobalUsageHelper helper) {
  final PsiClass containingClass = member.getContainingClass();
  if (!(containingClass instanceof PsiClassImpl)) return true;
  final PsiMethod valuesMethod = ((PsiClassImpl)containingClass).getValuesMethod();
  return valuesMethod == null || isMethodReferenced(project, containingFile, valuesMethod, progress, helper);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:UnusedSymbolUtil.java


示例9: TestIsImplicitUsageForClassWithNoMethods

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Test
public void TestIsImplicitUsageForClassWithNoMethods() throws Exception {
    ModuleHelper helper = mock(ModuleHelper.class);
    PsiClass c = mock(PsiClassImpl.class);
    when(helper.isGaugeModule(c)).thenReturn(true);
    when(c.getMethods()).thenReturn(new PsiMethod[]{});

    boolean isUsed = new ImplUsageProvider(null, helper).isImplicitUsage(c);

    assertFalse(isUsed);
}
 
开发者ID:getgauge,项目名称:Intellij-Plugin,代码行数:12,代码来源:ImplUsageProviderTest.java


示例10: findEnclosingName

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Nullable
private static String findEnclosingName(final SourcePosition position) {
  PsiElement element = findElementAt(position);
  while (true) {
    element = PsiTreeUtil.getParentOfType(element, GrTypeDefinition.class, PsiClassImpl.class);
    if (element == null
        || (element instanceof GrTypeDefinition && !((GrTypeDefinition)element).isAnonymous())
        || (element instanceof PsiClassImpl && ((PsiClassImpl)element).getName() != null)
      ) {
      break;
    }
  }

  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:SpringLoadedPositionManager.java


示例11: createPsi

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Override
public PsiClass createPsi(@NotNull final ASTNode node)
{
	if(node instanceof EnumConstantInitializerElement)
	{
		return new PsiEnumConstantInitializerImpl(node);
	}
	else if(node instanceof AnonymousClassElement)
	{
		return new PsiAnonymousClassImpl(node);
	}

	return new PsiClassImpl(node);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:JavaClassElementType.java


示例12: isEnumValuesMethodUsed

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
private static boolean isEnumValuesMethodUsed(@NotNull Project project,
		@NotNull PsiFile containingFile,
		@NotNull PsiMember member,
		@NotNull ProgressIndicator progress,
		@NotNull GlobalUsageHelper helper)
{
	final PsiClass containingClass = member.getContainingClass();
	if(!(containingClass instanceof PsiClassImpl))
	{
		return true;
	}

	if(containingClass.isEnum())
	{
		PsiMethod[] methodsByName = containingClass.findMethodsByName(JavaEnumAugmentProvider.VALUES_METHOD_NAME,
				false);

		PsiMethod valuesMethod = null;
		for(PsiMethod psiMethod : methodsByName)
		{
			if(psiMethod.getParameterList().getParametersCount() == 0 && psiMethod.hasModifierProperty
					(PsiModifier.STATIC))
			{
				valuesMethod = psiMethod;
				break;
			}
		}
		return valuesMethod == null || isMethodReferenced(project, containingFile, valuesMethod, progress, helper);
	}
	else
	{
		return true;
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:35,代码来源:UnusedSymbolUtil.java


示例13: doExecute

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Override
protected void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
    System.out.println("doExecute called: editor = [" + editor + "], caret = [" + caret + "], " +
            "dataContext = [" + dataContext + "]");
    super.doExecute(editor, caret, dataContext);

    Project project = (Project) dataContext.getData(DataKeys.PROJECT.getName());
    if (project == null) return;

    PsiFile rootPsiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
    if (rootPsiFile == null) return;

    PsiClass sourceClassName = Stream.of(rootPsiFile.getChildren())
            .peek(psiElement -> System.out.println(psiElement.getClass()))
            .filter(psiElement -> psiElement instanceof PsiClass)
            .peek(System.out::println)
            .map(psiElement -> (PsiClass) psiElement)
            .collect(Collectors.toList()).get(0);
    SourceClass sourceClass = new SourceClass(sourceClassName.getName());

    List<Variable> extractedVariables = Stream.of(rootPsiFile.getChildren())
            .filter(psiElement -> psiElement instanceof PsiClassImpl)
            .map(PsiElement::getChildren)
            .flatMap(Arrays::stream)
            .filter(psiElement -> psiElement instanceof PsiVariable)
            .map(psiElement -> (PsiVariable) psiElement)
            .map(psiVariable -> new Variable(
                    new Type(psiVariable.getType().getCanonicalText()),
                    new Variable.Name(psiVariable.getName())))
            .peek(System.out::println)
            .collect(Collectors.toList());
    if (extractedVariables.isEmpty()) return;

    PsiClassImpl sourceJavaPsiClass = getRootClassUnderOperation(rootPsiFile);
    if (sourceJavaPsiClass == null) return;

    GeneratedValueWriter writeActionRunner = new GeneratedValueWriter(
            sourceJavaPsiClass, project, extractedVariables, sourceClass, rootPsiFile
    );
    WriteCommandAction.runWriteCommandAction(project, writeActionRunner);
}
 
开发者ID:Ingwersaft,项目名称:ValueClassGenerator,代码行数:42,代码来源:GenerateValueClassHandler.java


示例14: getPsiClass

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
public PsiClassImpl getPsiClass() {
    return psiClass;
}
 
开发者ID:zhengjunbase,项目名称:codehelper.generator,代码行数:4,代码来源:OnePojoInfo.java


示例15: setPsiClass

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
public void setPsiClass(PsiClassImpl psiClass) {
    this.psiClass = psiClass;
}
 
开发者ID:zhengjunbase,项目名称:codehelper.generator,代码行数:4,代码来源:OnePojoInfo.java


示例16: actionPerformed

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
public void actionPerformed(AnActionEvent event) {
        String projectPath = StringUtils.EMPTY;
        try {
            //todo need check if need module.
            UserConfigService.loadUserConfig(ProjectHelper.getProjectPath(event));
            projectPath = ProjectHelper.getProjectPath(event);
            Project project = event.getProject();
            Editor editor = event.getData(LangDataKeys.EDITOR);
            PsiFile currentFile = event.getData(LangDataKeys.PSI_FILE);
            CaretModel caretModel = editor.getCaretModel();
            LogicalPosition oldLogicPos = caretModel.getLogicalPosition();
            String text = currentFile.getText();
            List<String> lines = Splitter.on("\n").splitToList(text);
            PojoLine pojo = getCursorLine(lines, oldLogicPos);
            PsiDirectory containingDirectory = currentFile.getContainingDirectory();
//            HintManager.getInstance().showInformationHint(editor,"success");
            String dir = containingDirectory.getVirtualFile().getCanonicalPath() + GenCodeResponseHelper.getPathSplitter() + currentFile.getName();
            AutoCodingRequest request = new AutoCodingRequest();
            request.setRequestType("AutoCoding");
            request.setCodingType("Setter");
            ServerRequestHelper.fillCommonField(request);
            if (pojo != null) {
                request.setPojoName(pojo.getClassName());
                LogicalPosition newStatementPos = new LogicalPosition(pojo.getLineNumber() , pojo.getLineStartPos() + 1);
                LogicalPosition insertPos = new LogicalPosition(pojo.getLineNumber() + 1 , 0 );
                caretModel.moveToLogicalPosition(newStatementPos);
                PsiElement currentFileElement = event.getData(LangDataKeys.PSI_ELEMENT);
                if (currentFileElement instanceof PsiClassImpl || currentFileElement instanceof ClsClassImpl) {
                    //                    Integer trueOffSet = getOffset(pojo, dir);
                    //                    if(trueOffSet != 0){
                    //                       offset = trueOffSet;
                    //                    }
                    Document document = PsiDocumentManager.getInstance(event.getProject()).getDocument(currentFile);
                    caretModel.moveToLogicalPosition(insertPos);
                    Integer offset = caretModel.getOffset();
                    String insert = insertSetter(project, pojo, document, currentFileElement, offset);
                    request.setInsert(insert);
//                    SettingService.getSetting().setLastInsertPos(offset);
//                    SettingService.getSetting().setLastInsertLength(setter.length());
                }
            }
//            VirtualFileManager.getInstance().syncRefresh();
//            ApplicationManager.getApplication().saveAll();

            caretModel.moveToLogicalPosition(oldLogicPos);
            SendToServerService.post(project,request);
        } catch (Throwable ignored) {
            LOGGER.error("actionPerformed :{}", ignored);
        }finally {
            LoggerWrapper.saveAllLogs(projectPath);
            SettingService.updateLastRunTime();
        }

    }
 
开发者ID:zhengjunbase,项目名称:codehelper.generator,代码行数:55,代码来源:AutoCodingAction.java


示例17: parseIdeaFieldInfo

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
public static void parseIdeaFieldInfo(@NotNull OnePojoInfo onePojoInfo, GenCodeResponse response){
        String pojoName = onePojoInfo.getPojoName();
        String pojoFileShortName = pojoName + ".java";
        Project project = response.getRequest().getProject();
        PsiFile[] psiFile = FilenameIndex
                .getFilesByName(project, pojoFileShortName, GlobalSearchScope.projectScope(project));
        PsiElement firstChild = psiFile[0].getFirstChild();
        LOGGER.info("parseIdeaFieldInfo psiFile[0] path :{}", psiFile[0].getVirtualFile().getPath());
        PsiElement child = null;
        for (PsiFile each: psiFile){
            VirtualFile vf = each.getVirtualFile();
            LOGGER.info("parseIdeaFieldInfo :{}, :{}", vf.getPath(), onePojoInfo.getFullPojoPath());
            if (removeSplit(vf.getPath()).equals(removeSplit(onePojoInfo.getFullPojoPath()))){
                child = firstChild;
            }
        }

        List<PsiElement> elements = Lists.newArrayList();

//        i// Find Psi of class and package
        do {
            if (child instanceof PsiClassImpl) {
                elements.add(child);
            }
            if (child instanceof PsiPackageStatementImpl){
                onePojoInfo.setPojoPackage(((PsiPackageStatementImpl) child).getPackageName());
            }
            child = child.getNextSibling();
        }
        while (child != null);

        PsiClassImpl psiClass = (PsiClassImpl) elements.get(0);
        PsiElement context = psiClass.getContext();
        if(context == null){
            throw new RuntimeException("parse class error");
        }
        String text = context.getText();
        onePojoInfo.setPojoPackage(parsePackage(text));
        PsiField[] allFields = psiClass.getAllFields();
        List<PojoFieldInfo> fieldList = Lists.newArrayList();

        for (PsiField field : allFields) {
            if(isStaticField(field)){
                continue;
            }
            SupportFieldClass fieldClass = SupportFieldClass.fromDesc(field.getType().getCanonicalText());
            LOGGER.info("parseIdeaFieldInfo  canonicalText :{}", field.getType().getCanonicalText());
            if(fieldClass == SupportFieldClass.NONE){
                continue;
            }
            PojoFieldInfo fieldInfo = new PojoFieldInfo();
            fieldInfo.setFieldComment(parseComment(field));
            fieldInfo.setFieldName(field.getName());
            fieldInfo.setFieldClass(fieldClass);
            fieldInfo.setAnnotations(Lists.newArrayList());
            fieldList.add(fieldInfo);
        }
        onePojoInfo.setPojoFieldInfos(fieldList);
    }
 
开发者ID:zhengjunbase,项目名称:codehelper.generator,代码行数:60,代码来源:OnePojoInfoHelper.java


示例18: getReferencedTypes

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
@Override
public PsiClassType[] getReferencedTypes() {
  if (myTypes != null) return myTypes;
  if (myNames.length == 0) {
    myTypes = PsiClassType.EMPTY_ARRAY;
    return myTypes;
  }

  PsiClassType[] types = new PsiClassType[myNames.length];

  final boolean compiled = ((JavaClassReferenceListElementType)getStubType()).isCompiled(this);
  if (compiled) {
    for (int i = 0; i < types.length; i++) {
      types[i] = new PsiClassReferenceType(new ClsJavaCodeReferenceElementImpl(getPsi(), StringRef.toString(myNames[i])), null);
    }
  }
  else {
    final PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();

    int nullCount = 0;
    final PsiReferenceList psi = getPsi();
    for (int i = 0; i < types.length; i++) {
      PsiElement context = psi;
      if (getParentStub() instanceof PsiClassStub) {
        context = ((PsiClassImpl)getParentStub().getPsi()).calcBasesResolveContext(PsiNameHelper.getShortClassName(StringRef.toString(myNames[i])), psi);
      }

      try {
        final PsiJavaCodeReferenceElement ref = factory.createReferenceFromText(StringRef.toString(myNames[i]), context);
        ((PsiJavaCodeReferenceElementImpl)ref).setKindWhenDummy(PsiJavaCodeReferenceElementImpl.CLASS_NAME_KIND);
        types[i] = factory.createType(ref);
      }
      catch (IncorrectOperationException e) {
        types[i] = null;
        nullCount++;
      }
    }

    if (nullCount > 0) {
      PsiClassType[] newTypes = new PsiClassType[types.length - nullCount];
      int cnt = 0;
      for (PsiClassType type : types) {
        if (type != null) newTypes[cnt++] = type;
      }
      types = newTypes;
    }
  }

  myTypes = types;
  return types;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:PsiClassReferenceListStubImpl.java


示例19: isImplicitUsage

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
public boolean isImplicitUsage(PsiElement element) {
    if (element == null || !moduleHelper.isGaugeModule(element)) return false;
    if (element instanceof PsiClassImpl) return isClassUsed((PsiClassImpl) element);
    if (element instanceof PsiParameterImpl) return isParameterUsed((PsiParameterImpl) element);
    return isElementUsed(element);
}
 
开发者ID:getgauge,项目名称:Intellij-Plugin,代码行数:7,代码来源:ImplUsageProvider.java


示例20: isClassUsed

import com.intellij.psi.impl.source.PsiClassImpl; //导入依赖的package包/类
private boolean isClassUsed(PsiClassImpl element) {
    for (PsiMethod psiMethod : element.getMethods())
        if (StepUtil.getGaugeStepAnnotationValues(psiMethod).size() > 0 || HookUtil.isHook(psiMethod)) return true;
    return false;
}
 
开发者ID:getgauge,项目名称:Intellij-Plugin,代码行数:6,代码来源:ImplUsageProvider.java



注:本文中的com.intellij.psi.impl.source.PsiClassImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSVisitor类代码示例发布时间:2022-05-23
下一篇:
Java ShardRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap