use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.
the class Source method getMethodCall.
public Optional<MethodCall> getMethodCall(final int line, final int column, final boolean onlyName) {
final EntryMessage entryMessage = log.traceEntry("line={} column={}", line, column);
int col = column;
final Scope scope = Scope.getInnerScope(line, this.classScopes);
if (nonNull(scope)) {
final Collection<MethodCall> symbols = scope.getMethodCall(line);
final int size = symbols.size();
log.trace("variables:{}", symbols);
if (onlyName) {
for (final MethodCall methodCall : symbols) {
if (methodCall.nameContains(col)) {
final Optional<MethodCall> result = Optional.of(methodCall);
return log.traceExit(entryMessage, result);
}
}
} else {
while (size > 0 && col-- > 0) {
for (final MethodCall methodCallSymbol : symbols) {
if (methodCallSymbol.containsColumn(col)) {
final Optional<MethodCall> result = Optional.of(methodCallSymbol);
return log.traceExit(entryMessage, result);
}
}
}
}
}
final Optional<MethodCall> empty = Optional.empty();
return log.traceExit(entryMessage, empty);
}
use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.
the class ReferenceSearcher method searchMethodCallCondition.
private static Optional<SearchCondition> searchMethodCallCondition(Source source, int line, int col, String symbol) {
EntryMessage msg = log.traceEntry("line={} col={} symbol={}", line, col, symbol);
Optional<MethodCall> mcResult = source.getMethodCall(line, col, true);
Optional<SearchCondition> result = mcResult.map(mc -> {
String methodName = mc.name;
List<String> arguments = mc.getArguments();
String declaringClass = mc.declaringClass;
if (isNull(declaringClass)) {
return null;
}
MemberDescriptor method = searchMatchMethod(declaringClass, methodName, arguments).orElseGet(() -> searchMatchConstructor(declaringClass, arguments).orElse(null));
if (isNull(method)) {
// not match
return null;
}
MethodDescriptor md = (MethodDescriptor) method;
if (md.getMemberType().equals(CandidateUnit.MemberType.CONSTRUCTOR)) {
return new SearchCondition(mc.declaringClass, mc.name, SearchCondition.Type.CONSTRUCTOR, mc.getArguments());
}
return new SearchCondition(mc.declaringClass, mc.name, SearchCondition.Type.METHOD, mc.getArguments());
});
log.traceExit(msg);
return result;
}
use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.
the class ReferenceSearcher method searchClassCondition.
private static Optional<SearchCondition> searchClassCondition(Source source, int line, int col, String symbol) {
final CachedASMReflector reflector = CachedASMReflector.getInstance();
final EntryMessage entryMessage = log.traceEntry("line={} col={} symbol={}", line, col, symbol);
Optional<SearchCondition> result;
String fqcn = source.getImportedClassFQCN(symbol, null);
if (isNull(fqcn)) {
if (!source.getPackageName().isEmpty()) {
fqcn = source.getPackageName() + '.' + symbol;
result = reflector.containsClassIndex(fqcn).map(index -> {
SearchCondition sc = new SearchCondition(index.getRawDeclaration(), index.getName(), SearchCondition.Type.CLASS);
return Optional.of(sc);
}).orElseGet(() -> {
final Set<String> parents = new HashSet<>(8);
for (final ClassScope classScope : source.getClassScopes()) {
final String className = classScope.getFQCN();
parents.add(className);
}
parents.addAll(source.importClasses);
for (final ClassIndex index : reflector.searchInnerClasses(parents)) {
final String returnType = index.getReturnType();
if (returnType.endsWith(symbol)) {
SearchCondition sc = new SearchCondition(index.getRawDeclaration(), index.getName(), SearchCondition.Type.CLASS);
return Optional.of(sc);
}
}
return Optional.empty();
});
} else {
result = Optional.empty();
}
} else {
SearchCondition sc = new SearchCondition(fqcn, ClassNameUtils.getSimpleName(fqcn), SearchCondition.Type.CLASS);
result = Optional.of(sc);
}
log.traceExit(entryMessage);
return result;
}
use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.
the class MethodScope method dumpVariable.
@Override
public void dumpVariable() {
final EntryMessage entryMessage = log.traceEntry("**** {} {} return {}", this.getScopeType(), this.name, this.returnType);
super.dumpVariable(log);
for (final ExpressionScope expressionScope : this.expressions) {
expressionScope.dumpVariable();
}
for (final BlockScope blockScope : this.scopes) {
blockScope.dumpVariable();
}
log.traceExit(entryMessage);
}
use of org.apache.logging.log4j.message.EntryMessage in project meghanada-server by mopemope.
the class ClassScope method dumpFieldAccess.
@Override
public void dumpFieldAccess() {
final EntryMessage entryMessage = log.traceEntry("**** {} {} methods:{}", this.getScopeType(), this.name, this.scopes.size());
super.dumpFieldAccess(log);
for (final ExpressionScope expressionScope : this.expressions) {
expressionScope.dumpFieldAccess();
}
for (final BlockScope blockScope : this.scopes) {
blockScope.dumpFieldAccess();
}
for (final ClassScope cs : this.classScopes) {
cs.dumpFieldAccess();
}
log.traceExit(entryMessage);
}
Aggregations