Search in sources :

Example 21 with Nullable

use of org.jetbrains.annotations.Nullable in project scss-lint-plugin by idok.

the class ThreadLocalActualFile method createFile.

@Nullable
private File createFile() {
    //        File retFile = new File(file.getParent().getPath(), file.getNameWithoutExtension() + "_jscs_tmp." + file.getExtension());
    File retFile = createFileAsSibling();
    if (retFile != null) {
        return retFile;
    }
    // try to create a temp file in temp folder
    File dir = getOrCreateTempDir();
    if (dir == null) {
        return null;
    }
    File file = new File(dir, this.baseName + this.extension);
    boolean created = false;
    if (!file.exists()) {
        try {
            created = file.createNewFile();
        } catch (IOException ignored) {
            LOG.warn("Can not create " + file.getAbsolutePath());
        }
    }
    if (!created) {
        try {
            file = FileUtil.createTempFile(dir, this.baseName, this.extension);
        } catch (IOException e) {
            LOG.warn("Can not create temp file", e);
            return null;
        }
    }
    file.deleteOnExit();
    return file;
}
Also used : IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 22 with Nullable

use of org.jetbrains.annotations.Nullable in project robolectric by robolectric.

the class ConfigMerger method cachedPackageConfig.

@Nullable
private Config cachedPackageConfig(String packageName) {
    synchronized (packageConfigCache) {
        Config config = packageConfigCache.get(packageName);
        if (config == null && !packageConfigCache.containsKey(packageName)) {
            config = buildPackageConfig(packageName);
            packageConfigCache.put(packageName, config);
        }
        return config;
    }
}
Also used : Config(org.robolectric.annotation.Config) Nullable(org.jetbrains.annotations.Nullable)

Example 23 with Nullable

use of org.jetbrains.annotations.Nullable in project jadx by skylot.

the class DexNode method deepResolveMethod.

@Nullable
private MethodNode deepResolveMethod(@NotNull ClassNode cls, String signature) {
    for (MethodNode m : cls.getMethods()) {
        if (m.getMethodInfo().getShortId().startsWith(signature)) {
            return m;
        }
    }
    MethodNode found;
    ArgType superClass = cls.getSuperClass();
    if (superClass != null) {
        ClassNode superNode = resolveClass(superClass);
        if (superNode != null) {
            found = deepResolveMethod(superNode, signature);
            if (found != null) {
                return found;
            }
        }
    }
    for (ArgType iFaceType : cls.getInterfaces()) {
        ClassNode iFaceNode = resolveClass(iFaceType);
        if (iFaceNode != null) {
            found = deepResolveMethod(iFaceNode, signature);
            if (found != null) {
                return found;
            }
        }
    }
    return null;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) Nullable(org.jetbrains.annotations.Nullable)

Example 24 with Nullable

use of org.jetbrains.annotations.Nullable in project jadx by skylot.

the class Deobfuscator method getAliasFromSourceFile.

@Nullable
private String getAliasFromSourceFile(ClassNode cls) {
    SourceFileAttr sourceFileAttr = cls.get(AType.SOURCE_FILE);
    if (sourceFileAttr == null) {
        return null;
    }
    String name = sourceFileAttr.getFileName();
    if (name.endsWith(".java")) {
        name = name.substring(0, name.length() - ".java".length());
    }
    if (NameMapper.isValidIdentifier(name) && !NameMapper.isReserved(name)) {
        // TODO: check if no class with this name exists or already renamed
        cls.remove(AType.SOURCE_FILE);
        return name;
    }
    return null;
}
Also used : SourceFileAttr(jadx.core.dex.attributes.nodes.SourceFileAttr) Nullable(org.jetbrains.annotations.Nullable)

Example 25 with Nullable

use of org.jetbrains.annotations.Nullable in project jadx by skylot.

the class Deobfuscator method getMethodAlias.

@Nullable
public String getMethodAlias(MethodNode mth) {
    MethodInfo methodInfo = mth.getMethodInfo();
    String alias = mthMap.get(methodInfo);
    if (alias != null) {
        return alias;
    }
    alias = deobfPresets.getForMth(methodInfo);
    if (alias != null) {
        mthMap.put(methodInfo, alias);
        methodInfo.setAliasFromPreset(true);
        return alias;
    }
    if (shouldRename(mth.getName())) {
        return makeMethodAlias(mth);
    }
    return null;
}
Also used : MethodInfo(jadx.core.dex.info.MethodInfo) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)4642 VirtualFile (com.intellij.openapi.vfs.VirtualFile)810 PsiElement (com.intellij.psi.PsiElement)485 File (java.io.File)399 Project (com.intellij.openapi.project.Project)396 PsiFile (com.intellij.psi.PsiFile)319 NotNull (org.jetbrains.annotations.NotNull)257 IOException (java.io.IOException)243 Module (com.intellij.openapi.module.Module)227 ArrayList (java.util.ArrayList)169 TextRange (com.intellij.openapi.util.TextRange)156 Document (com.intellij.openapi.editor.Document)124 List (java.util.List)111 ASTNode (com.intellij.lang.ASTNode)105 IElementType (com.intellij.psi.tree.IElementType)103 XmlTag (com.intellij.psi.xml.XmlTag)96 Editor (com.intellij.openapi.editor.Editor)94 Element (org.jdom.Element)93 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)86 XmlFile (com.intellij.psi.xml.XmlFile)78