com.intellij.psi.PsiNameHelper Java Examples

The following examples show how to use com.intellij.psi.PsiNameHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaConverterFactory.java    From json2java4idea with Apache License 2.0 5 votes vote down vote up
@Inject
public JavaConverterFactory(@Nonnull Provider<PsiNameHelper> nameHelperProvider,
                            @Nonnull @Named("FieldName") Provider<NamePolicy> fieldNamePolicyProvider,
                            @Nonnull @Named("MethodName") Provider<NamePolicy> methodNamePolicyProvider,
                            @Nonnull @Named("ParameterName") Provider<NamePolicy> parameterNamePolicyProvider) {
    this.nameHelperProvider = nameHelperProvider;
    this.fieldNamePolicyProvider = fieldNamePolicyProvider;
    this.methodNamePolicyProvider = methodNamePolicyProvider;
    this.parameterNamePolicyProvider = parameterNamePolicyProvider;
}
 
Example #2
Source File: ClassSuffixValidatorTest.java    From json2java4idea with Apache License 2.0 5 votes vote down vote up
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    final Project project = getProject();
    final Json2JavaBundle bundle = Json2JavaBundle.getInstance();
    final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);
    underTest = new ClassSuffixValidator(bundle, nameHelper);
}
 
Example #3
Source File: ClassPrefixValidatorTest.java    From json2java4idea with Apache License 2.0 5 votes vote down vote up
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    final Project project = getProject();
    final Json2JavaBundle bundle = Json2JavaBundle.getInstance();
    final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);
    underTest = new ClassPrefixValidator(bundle, nameHelper);
}
 
Example #4
Source File: ClassNamePolicyTest.java    From json2java4idea with Apache License 2.0 5 votes vote down vote up
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    final Project project = getProject();
    nameHelper = PsiNameHelper.getInstance(project);
}
 
Example #5
Source File: GenerateAction.java    From RIBs with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if a Java package exists for a directory.
 *
 * @param directory to check.
 * @return {@code true} when a package exists, {@code false} when it does not.
 */
private boolean checkPackageExists(PsiDirectory directory) {
  PsiPackage pkg = JavaDirectoryService.getInstance().getPackage(directory);
  if (pkg == null) {
    return false;
  }

  String name = pkg.getQualifiedName();
  return StringUtil.isEmpty(name)
      || PsiNameHelper.getInstance(directory.getProject()).isQualifiedName(name);
}
 
Example #6
Source File: ClassPrefixValidator.java    From json2java4idea with Apache License 2.0 4 votes vote down vote up
@Inject
public ClassPrefixValidator(@NotNull Json2JavaBundle bundle, @NotNull PsiNameHelper nameHelper) {
    this.bundle = bundle;
    this.nameHelper = nameHelper;
}
 
Example #7
Source File: ClassSuffixValidator.java    From json2java4idea with Apache License 2.0 4 votes vote down vote up
@Inject
public ClassSuffixValidator(@NotNull Json2JavaBundle bundle, @NotNull PsiNameHelper nameHelper) {
    this.bundle = bundle;
    this.nameHelper = nameHelper;
}
 
Example #8
Source File: NameValidator.java    From json2java4idea with Apache License 2.0 4 votes vote down vote up
@Inject
public NameValidator(@Nonnull Json2JavaBundle bundle, @Nonnull PsiNameHelper nameHelper) {
    this.bundle = bundle;
    this.nameHelper = nameHelper;
}
 
Example #9
Source File: ClassNamePolicy.java    From json2java4idea with Apache License 2.0 4 votes vote down vote up
@Inject
public ClassNamePolicy(@Nonnull PsiNameHelper nameHelper, @Nonnull String prefix, @Nonnull String suffix) {
    this.nameHelper = nameHelper;
    this.prefix = prefix;
    this.suffix = suffix;
}
 
Example #10
Source File: ProjectModule.java    From json2java4idea with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Provides
@Singleton
public PsiNameHelper provideNameHelper(@Nonnull Project project) {
    return PsiNameHelper.getInstance(project);
}
 
Example #11
Source File: NameValidatorTest.java    From json2java4idea with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    final Project project = fixture.getProject();
    bundle = spy(new Json2JavaBundle());
    underTest = new NameValidator(bundle, PsiNameHelper.getInstance(project));
}
 
Example #12
Source File: HaxeResolver.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
private List<? extends PsiElement> doResolve(@NotNull HaxeReference reference, boolean incompleteCode) {
  if (LOG.isTraceEnabled()) LOG.trace(traceMsg("-----------------------------------------"));
  if (LOG.isTraceEnabled()) LOG.trace(traceMsg("Resolving reference: " + reference.getText()));

  isExtension.set(false);

  if (reportCacheMetrics) {
    resolves.incrementAndGet();
  }

  List<? extends PsiElement> result = checkIsType(reference);
  if (result == null) result = checkIsFullyQualifiedStatement(reference);
  if (result == null) result = checkIsSuperExpression(reference);
  if (result == null) result = checkIsClassName(reference);
  if (result == null) result = checkIsChain(reference);
  if (result == null) result = checkIsAccessor(reference);
  if (result == null) result = checkByTreeWalk(reference);
  if (result == null) {
    // try super field
    List<? extends PsiElement> superElements =
      resolveByClassAndSymbol(PsiTreeUtil.getParentOfType(reference, HaxeClass.class), reference);
    if (!superElements.isEmpty()) {
      LogResolution(reference, "via super field.");
      return superElements;
    }

    HaxeFileModel fileModel = HaxeFileModel.fromElement(reference);
    if (fileModel != null) {
      String className = reference.getText();

      PsiElement target = HaxeResolveUtil.searchInSameFile(fileModel, className);
      if (target == null) target = HaxeResolveUtil.searchInImports(fileModel, className);
      if (target == null) target = HaxeResolveUtil.searchInSamePackage(fileModel, className);

      if (target != null) {
        return asList(target);
      }
    }

    if (PsiNameHelper.getInstance(reference.getProject()).isQualifiedName(reference.getText())) {
      List<HaxeModel> resolvedPackage =
        HaxeProjectModel.fromElement(reference).resolve(new FullyQualifiedInfo(reference.getText()), reference.getResolveScope());
      if (resolvedPackage != null && !resolvedPackage.isEmpty() && resolvedPackage.get(0) instanceof HaxePackageModel) {
        LogResolution(reference, "via project qualified name.");
        return Collections.singletonList(resolvedPackage.get(0).getBasePsi());
      }
    }
  }

  LogResolution(reference, "failed after exhausting all options.");
  return result == null ? ContainerUtil.emptyList() : result;
}