Search in sources :

Example 11 with EntryMessage

use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.

the class MethodSignatureVisitor method visitBaseType.

@Override
public void visitBaseType(char c) {
    final String baseType = ASMReflector.toPrimitive(c);
    final EntryMessage message = log.traceEntry("baseType={} parameterTypes={} c={}", baseType, this.parameterTypes, c);
    TypeInfo typeInfo = new TypeInfo(baseType, baseType);
    if (this.parent != null && this.isReturn) {
        // set return type
        this.parent.returnType = typeInfo;
        log.traceExit(message);
        return;
    }
    if (this.current == null) {
        this.current = typeInfo;
        this.visitEnd();
    }
    log.traceExit(message);
}
Also used : EntryMessage(org.apache.logging.log4j.message.EntryMessage)

Example 12 with EntryMessage

use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.

the class MethodSignatureVisitor method visitParameterType.

@Override
public SignatureVisitor visitParameterType() {
    final EntryMessage message = log.traceEntry("name={} current={}", this.name, this.current);
    MethodSignatureVisitor visitor = new MethodSignatureVisitor(this.name, this);
    visitor.isParameter = true;
    log.traceExit(message);
    return visitor;
}
Also used : EntryMessage(org.apache.logging.log4j.message.EntryMessage)

Example 13 with EntryMessage

use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.

the class FileUtils method getChecksum.

public static String getChecksum(final File file) throws IOException {
    final EntryMessage entryMessage = log.traceEntry("file={}", file);
    try {
        final MessageDigest md = MessageDigest.getInstance(ALGORITHM_SHA_512);
        try (final InputStream is = Files.newInputStream(file.toPath());
            DigestInputStream dis = new DigestInputStream(is, md)) {
            final byte[] buf = new byte[4096];
            while (dis.read(buf) != -1) {
            }
            final byte[] digest = md.digest();
            final StringBuilder sb = new StringBuilder(128);
            for (final int b : digest) {
                sb.append(Character.forDigit(b >> 4 & 0xF, 16));
                sb.append(Character.forDigit(b & 0xF, 16));
            }
            log.traceExit(entryMessage);
            return sb.toString();
        }
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }
}
Also used : DigestInputStream(java.security.DigestInputStream) FileInputStream(java.io.FileInputStream) DigestInputStream(java.security.DigestInputStream) InputStream(java.io.InputStream) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MessageDigest(java.security.MessageDigest) EntryMessage(org.apache.logging.log4j.message.EntryMessage)

Example 14 with EntryMessage

use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.

the class DeclarationSearcher method searchField.

private static Optional<Declaration> searchField(final Source source, final Integer line, final Integer col, final String symbol) {
    final EntryMessage entryMessage = log.traceEntry("line={} col={} symbol={}", line, col, symbol);
    final Optional<Declaration> result = source.searchFieldAccess(line, col, symbol).map(fa -> {
        String scope = fa.scope;
        if (scope != null && !scope.isEmpty()) {
            scope = scope + '.' + symbol;
        } else {
            scope = symbol;
        }
        return new Declaration(scope.trim(), fa.returnType, Declaration.Type.FIELD, fa.argumentIndex);
    });
    log.traceExit(entryMessage);
    return result;
}
Also used : EntryMessage(org.apache.logging.log4j.message.EntryMessage)

Example 15 with EntryMessage

use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.

the class DeclarationSearcher method searchReserved.

private static Optional<Declaration> searchReserved(@SuppressWarnings("unused") final Source source, final Integer line, final Integer col, final String symbol) {
    final EntryMessage entryMessage = log.traceEntry("line={} col={} symbol={}", line, col, symbol);
    Optional<Declaration> result = Optional.empty();
    if (symbol.equals("package") || symbol.equals("import") || symbol.equals("new") || symbol.equals("try") || symbol.equals("throw") || symbol.equals("finally") || symbol.equals("public") || symbol.equals("private") || symbol.equals("protected") || symbol.equals("return") || symbol.equals("static") || symbol.equals("final")) {
        result = Optional.of(new Declaration(symbol, "", Declaration.Type.OTHER, 0));
    }
    log.traceExit(entryMessage);
    return result;
}
Also used : EntryMessage(org.apache.logging.log4j.message.EntryMessage)

Aggregations

EntryMessage (org.apache.logging.log4j.message.EntryMessage)64 ArrayList (java.util.ArrayList)9 CachedASMReflector (meghanada.reflect.asm.CachedASMReflector)8 Test (org.junit.jupiter.api.Test)8 ClassScope (meghanada.analyze.ClassScope)5 MethodCall (meghanada.analyze.MethodCall)5 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Set (java.util.Set)3 ExecutionException (java.util.concurrent.ExecutionException)3 Variable (meghanada.analyze.Variable)3 Project (meghanada.project.Project)3 ClassIndex (meghanada.reflect.ClassIndex)3 ClassNameUtils (meghanada.utils.ClassNameUtils)3 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 SignatureReader (org.objectweb.asm.signature.SignatureReader)3