Commit 5a1abe36 authored by Daniel Honsel's avatar Daniel Honsel
Browse files

Fixed finding references in other modules.

Currently the performance is really bad. Further improvements are needed.
parent fdce308e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
  <ConfigurationProfiles>
    <QualityCheckProfile>
      <profileName>defaultProfile</profileName>
      <profileVersion>v2.0.0</profileVersion>
      <profileVersion>v2.0.0b5</profileVersion>
      <resourceExtensionsRegExp>ttcn|ttcn3|3mp</resourceExtensionsRegExp>
      <ignoredResourceRegExp>.*IGNORED.*</ignoredResourceRegExp>
      <projectExtension>t3p</projectExtension>
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import de.ugoe.cs.swe.common.logging.LoggingInterface;
import de.ugoe.cs.swe.common.logging.LoggingInterface.LogLevel;

public class T3Q {
	private static String versionNumber = "v2.0.0";
	private static String versionNumber = "v2.0.0b5";
	// set during automated server builds
	private static String buildStamp = "---BUILD_STAMP---";
	public static QualityCheckProfile activeProfile = null;
+31 −6
Original line number Diff line number Diff line
@@ -606,17 +606,42 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {

	// TODO: figure out another way to find referenced objects
	private def boolean isUnreferenced(EObject type, EObject parent) {
		//stopwatch.start
		stopwatch.start

		val target = newHashSet(type);
		val TTCN3ElementReferenceAcceptor acceptor = new TTCN3ElementReferenceAcceptor()

		parent.findCrossReferences(target, acceptor)
		
		//stopwatch.stop
		stopwatch.stop

		//System.err.println("Finding cross references takes: " + stopwatch.toString)
		//stopwatch.reset
		System.err.println("Finding cross references 1 took: " + stopwatch.toString)
		
		stopwatch.reset
		stopwatch.start
		
		// TODO: do not call this for all objects
		// TODO: improve performance (hit list for resources which are often called successfully?)
		// TODO: write own findCrossReferences?
		// TODO: cache found referenced objects?
		// TODO: consider only resources that are importing the current one!
		
		if (!acceptor.foundReference) {
			for (r : parent.resourceSet.resources) {
				r.allContents.next.findCrossReferences(target, acceptor)
				if (acceptor.foundReference) {
					stopwatch.stop
					System.err.println("Finding cross references 2 took: " + stopwatch.toString)
					return false;
				}
			}
		}
		
		stopwatch.stop
		
		System.err.println("Finding cross references 2 took: " + stopwatch.toString)
		
		stopwatch.reset

		return !acceptor.foundReference
	}