Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nixel2007 committed Jul 9, 2021
1 parent 069d091 commit 9f8d05b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder;
import com.github._1c_syntax.mdclasses.Configuration;
import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase;
import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBSL;
import com.github._1c_syntax.mdclasses.mdo.MDCommonModule;
import com.github._1c_syntax.mdclasses.mdo.support.MDOModule;
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
Expand Down Expand Up @@ -166,9 +166,9 @@ public Configuration getConfiguration() {
return configurationMetadata.getOrCompute();
}

public Set<AbstractMDObjectBase> getGlobalModules() {
public Set<AbstractMDObjectBSL> getGlobalModules() {

Set<AbstractMDObjectBase> globalModules = new HashSet<>();
Set<AbstractMDObjectBSL> globalModules = new HashSet<>();

getConfiguration().getCommonModules().values().stream()
.filter(MDCommonModule::isGlobal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.github._1c_syntax.bsl.languageserver.context.symbol.SymbolTree;
import com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder;
import com.github._1c_syntax.bsl.languageserver.utils.Ranges;
import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBSL;
import com.github._1c_syntax.mdclasses.mdo.support.MDOModule;
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
import lombok.RequiredArgsConstructor;
import lombok.Synchronized;
Expand All @@ -50,6 +52,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Component
@RequiredArgsConstructor
Expand Down Expand Up @@ -204,11 +207,19 @@ private Optional<SourceDefinedSymbol> getSourceDefinedSymbol(MultiKey<String> mu
ModuleType moduleType = ModuleType.valueOf(multikey.getKey(1));
String symbolName = multikey.getKey(2);

return serverContext.getDocument(mdoRef, moduleType)
Stream<DocumentContext> reffedModules = serverContext.getDocument(mdoRef, moduleType).stream();
Stream<DocumentContext> globalModules = serverContext.getGlobalModules().stream()
.map(AbstractMDObjectBSL::getModules)
.flatMap(Collection::stream)
.map(MDOModule::getUri)
.map(serverContext::getDocument);

return Stream.concat(reffedModules, globalModules)
.map(DocumentContext::getSymbolTree)
// TODO: SymbolTree#getSymbol(Position)?
// Для поиска не только методов, но и переменных, которые могут иметь одинаковые имена
.flatMap(symbolTree -> symbolTree.getMethodSymbol(symbolName));
.flatMap(symbolTree -> symbolTree.getMethodSymbol(symbolName).stream())
.map(SourceDefinedSymbol.class::cast)
.findAny();

}

private SourceDefinedSymbol getFromSymbol(URI uri, Position position) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void testGetReferenceToGlobalMethodFromApplicationModule() {
// then
assertThat(reference.getFrom()).isEqualTo(methodSymbol);
assertThat(reference.getSymbol()).isEqualTo(calledMethodSymbol);
assertThat(reference.getSelectionRange()).isEqualTo(Ranges.create(5, 4, 41));
assertThat(reference.getSelectionRange()).isEqualTo(Ranges.create(5, 4, 29));
assertThat(reference.getUri()).isEqualTo(uri);
}

Expand Down Expand Up @@ -215,7 +215,7 @@ void testGetReferencesFromLocalMethodSymbol() {

// then
assertThat(references)
.hasSize(3)
.hasSize(5)
.contains(Reference.of(localMethodSymbol, localMethodSymbol, locationLocal))
.contains(Reference.of(localMethodSymbol, commonModuleMethodSymbol, locationCommonModule))
.contains(Reference.of(localMethodSymbol, managerModuleMethodSymbol, locationManagerModule))
Expand Down

1 comment on commit 9f8d05b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'BSL LS perfomance measurement (SSL 3.1)'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: 9f8d05b Previous: 970c31a Ratio
.github/scripts/benchmark.py::test_analyze_ssl31 248.4809619585673 sec (stddev: 44.364569585466114) 89.34729766845703 sec (stddev: 3.8178570363610183) 2.78

This comment was automatically generated by workflow using github-action-benchmark.

CC: @otymko

Please sign in to comment.