Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated memoization from signature matching
- Loading branch information
Showing
22 changed files
with
271 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/BasicProjectMemoizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
|
||
package net.sourceforge.pmd.lang.metrics; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import net.sourceforge.pmd.lang.ast.QualifiableNode; | ||
import net.sourceforge.pmd.lang.ast.QualifiedName; | ||
|
||
/** | ||
* Simple implementation of a project memoizer. Memoizers are accessible in constant time, provided the QualifiedName's | ||
* hashCode is well distributed. | ||
* | ||
* @param <T> Type of type declaration nodes of the language | ||
* @param <O> Type of operation declaration nodes of the language | ||
* | ||
* @author Clément Fournier | ||
*/ | ||
public class BasicProjectMemoizer<T extends QualifiableNode, O extends QualifiableNode> implements ProjectMemoizer<T, O> { | ||
|
||
private Map<QualifiedName, MetricMemoizer<T>> classes = new HashMap<>(); | ||
private Map<QualifiedName, MetricMemoizer<O>> operations = new HashMap<>(); | ||
|
||
|
||
@Override | ||
public void addClassMemoizer(QualifiedName qname) { | ||
classes.put(qname, new BasicMetricMemoizer<T>()); | ||
} | ||
|
||
|
||
@Override | ||
public void addOperationMemoizer(QualifiedName qname) { | ||
operations.put(qname, new BasicMetricMemoizer<O>()); | ||
} | ||
|
||
|
||
@Override | ||
public MetricMemoizer<O> getOperationMemoizer(QualifiedName qname) { | ||
return operations.get(qname); | ||
} | ||
|
||
|
||
@Override | ||
public MetricMemoizer<T> getClassMemoizer(QualifiedName qname) { | ||
return classes.get(qname); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.