@Test public void findDefinitionNegativeCase() throws IOException { TurinFile turinFile = new Parser().parse(this.getClass().getResourceAsStream("/basicManga.to")); SrcSymbolResolver srcSymbolResolver = new SrcSymbolResolver(ImmutableList.of(turinFile)); PropertyReference propertyReference = createMock(PropertyReference.class); EasyMock.expect(propertyReference.contextName()).andReturn("not_manga"); EasyMock.expect(propertyReference.getName()).andReturn("name"); replayAll(); Optional<PropertyDefinition> optionalDefinition = srcSymbolResolver.findDefinition(propertyReference); assertEquals(false, optionalDefinition.isPresent()); }
@Override public Optional<PropertyDefinition> findDefinition(PropertyReference propertyReference) { String name = propertyReference.contextName() + "." + propertyReference.getName(); if (propertyDefinitions.containsKey(name)) { return Optional.of(propertyDefinitions.get(name)); } else { return Optional.empty(); } }
SrcSymbolResolver implements SymbolResolver { @Override public Optional<PropertyDefinition> findDefinition(PropertyReference propertyReference) { String name = propertyReference.contextName() + "." + propertyReference.getName(); if (propertyDefinitions.containsKey(name)) { return Optional.of(propertyDefinitions.get(name)); } else { return Optional.empty(); } } }
SrcSymbolResolver implements SymbolResolver { @Override public Optional<PropertyDefinition> findDefinition(PropertyReference propertyReference) { String name = propertyReference.contextName() + "." + propertyReference.getName(); if (propertyDefinitions.containsKey(name)) { return Optional.of(propertyDefinitions.get(name)); } else { return Optional.empty(); } } SrcSymbolResolver(List<TurinFile> turinFiles); }
SrcSymbolResolver implements SymbolResolver { @Override public Optional<PropertyDefinition> findDefinition(PropertyReference propertyReference) { String name = propertyReference.contextName() + "." + propertyReference.getName(); if (propertyDefinitions.containsKey(name)) { return Optional.of(propertyDefinitions.get(name)); } else { return Optional.empty(); } } SrcSymbolResolver(List<TurinFile> turinFiles); @Override SymbolResolver getParent(); @Override void setParent(SymbolResolver parent); @Override Optional<PropertyDefinition> findDefinition(PropertyReference propertyReference); @Override Optional<TypeDefinition> findTypeDefinitionIn(String typeName, Node context, SymbolResolver resolver); @Override Optional<TypeUsage> findTypeUsageIn(String typeName, Node context, SymbolResolver resolver); @Override Optional<JvmMethodDefinition> findJvmDefinition(FunctionCall functionCall); @Override Optional<Symbol> findSymbol(String name, Node context); @Override boolean existPackage(String packageName); @Override Optional<ContextDefinition> findContextSymbol(String contextName, Node context); }
SrcSymbolResolver implements SymbolResolver { @Override public Optional<PropertyDefinition> findDefinition(PropertyReference propertyReference) { String name = propertyReference.contextName() + "." + propertyReference.getName(); if (propertyDefinitions.containsKey(name)) { return Optional.of(propertyDefinitions.get(name)); } else { return Optional.empty(); } } SrcSymbolResolver(List<TurinFile> turinFiles); @Override SymbolResolver getParent(); @Override void setParent(SymbolResolver parent); @Override Optional<PropertyDefinition> findDefinition(PropertyReference propertyReference); @Override Optional<TypeDefinition> findTypeDefinitionIn(String typeName, Node context, SymbolResolver resolver); @Override Optional<TypeUsage> findTypeUsageIn(String typeName, Node context, SymbolResolver resolver); @Override Optional<JvmMethodDefinition> findJvmDefinition(FunctionCall functionCall); @Override Optional<Symbol> findSymbol(String name, Node context); @Override boolean existPackage(String packageName); @Override Optional<ContextDefinition> findContextSymbol(String contextName, Node context);  }