Search in sources :

Example 21 with EntryMessage

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

the class ExpressionScope method getExpressionReturn.

public Optional<AccessSymbol> getExpressionReturn() {
    EntryMessage em = log.traceEntry("expressionReturn={}", this.expressionReturn);
    Optional<Variable> var = this.variables.stream().filter(Variable::isDecl).findFirst();
    if (var.isPresent()) {
        return log.traceExit(em, Optional.empty());
    }
    Optional<AccessSymbol> aReturn = Optional.ofNullable(this.expressionReturn);
    return log.traceExit(em, aReturn);
}
Also used : EntryMessage(org.apache.logging.log4j.message.EntryMessage)

Example 22 with EntryMessage

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

the class Source method dump.

public void dump() {
    final EntryMessage entryMessage = log.traceEntry("{}", Strings.repeat("*", 100));
    for (final ClassScope cs : classScopes) {
        cs.dump();
    }
    log.trace("unused={}", this.unused);
    log.trace("unknown={}", this.unknown);
    log.traceExit(entryMessage);
}
Also used : EntryMessage(org.apache.logging.log4j.message.EntryMessage)

Example 23 with EntryMessage

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

the class ReferenceSearcher method searchFieldAccessCondition.

private static Optional<SearchCondition> searchFieldAccessCondition(Source source, int line, int col, String symbol) {
    EntryMessage msg = log.traceEntry("line={} col={} symbol={}", line, col, symbol);
    Optional<SearchCondition> result = source.searchFieldAccess(line, col, symbol).map(fa -> new SearchCondition(fa.declaringClass, fa.name, SearchCondition.Type.FIELD));
    log.traceExit(msg);
    return result;
}
Also used : EntryMessage(org.apache.logging.log4j.message.EntryMessage)

Example 24 with EntryMessage

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

the class ReferenceSearcher method searchMemberCondition.

private static Optional<SearchCondition> searchMemberCondition(Source source, int line, int col, String symbol) {
    EntryMessage msg = log.traceEntry("line={} col={} symbol={}", line, col, symbol);
    for (ClassScope classScope : source.getClassScopes()) {
        for (Variable variable : classScope.getVariables()) {
            if (variable.isField) {
                Position pos = variable.range.begin;
                String name = variable.name;
                if (pos.line == line && name.equals(symbol)) {
                    String clazz = classScope.getFQCN();
                    SearchCondition condition = new SearchCondition(clazz, name, SearchCondition.Type.FIELD);
                    return Optional.of(condition);
                }
            }
        }
        for (BlockScope blockScope : classScope.getScopes()) {
            if (blockScope instanceof MethodScope) {
                MethodScope methodScope = ((MethodScope) blockScope);
                Position pos = methodScope.getNameRange().begin;
                String name = methodScope.getName();
                if (pos.line == line && name.equals(symbol)) {
                    String clazz = classScope.getFQCN();
                    SearchCondition condition = new SearchCondition(clazz, name, SearchCondition.Type.METHOD, methodScope.getParameters());
                    return Optional.of(condition);
                }
            }
        }
    }
    log.traceExit(msg);
    return Optional.empty();
}
Also used : Variable(meghanada.analyze.Variable) Position(meghanada.analyze.Position) BlockScope(meghanada.analyze.BlockScope) MethodScope(meghanada.analyze.MethodScope) EntryMessage(org.apache.logging.log4j.message.EntryMessage) ClassScope(meghanada.analyze.ClassScope)

Example 25 with EntryMessage

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

the class MethodDescriptor method renderTypeParameters.

@Override
protected String renderTypeParameters(final String template, final boolean formalType) {
    final EntryMessage entryMessage = log.traceEntry("template={}, formalType={} typeParameterMap={} typeParameters={}", template, formalType, typeParameterMap, typeParameters);
    String temp = template;
    if (this.typeParameterMap.size() > 0) {
        for (final Map.Entry<String, String> entry : this.typeParameterMap.entrySet()) {
            final String k = entry.getKey();
            final String v = entry.getValue();
            temp = ClassNameUtils.replace(temp, ClassNameUtils.CLASS_TYPE_VARIABLE_MARK + k, v);
            if (formalType) {
                // follow intellij
                temp = ClassNameUtils.replace(temp, ClassNameUtils.FORMAL_TYPE_VARIABLE_MARK + k, v);
            }
        }
    } else {
        for (final String entry : this.typeParameters) {
            temp = ClassNameUtils.replace(temp, ClassNameUtils.CLASS_TYPE_VARIABLE_MARK + entry, ClassNameUtils.OBJECT_CLASS);
            if (formalType) {
                // follow intellij
                temp = ClassNameUtils.replace(temp, ClassNameUtils.FORMAL_TYPE_VARIABLE_MARK + entry, ClassNameUtils.OBJECT_CLASS);
            }
        }
        if (!this.modifier.contains("static")) {
            temp = TRIM_RE.matcher(temp).replaceAll("");
        }
    }
    final String rendered = ClassNameUtils.replace(temp, ClassNameUtils.FORMAL_TYPE_VARIABLE_MARK, "").trim();
    return log.traceExit(entryMessage, rendered);
}
Also used : EntryMessage(org.apache.logging.log4j.message.EntryMessage) HashMap(java.util.HashMap) Map(java.util.Map)

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