com.ibm.wala.cast.js.html.CompositeFileMapping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.ibm.wala.cast.js Show documentation
Show all versions of com.ibm.wala.cast.js Show documentation
T. J. Watson Libraries for Analysis
/*
* Copyright (c) 2013 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*/
package com.ibm.wala.cast.js.html;
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
import java.util.ArrayList;
import java.util.List;
public class CompositeFileMapping implements FileMapping {
private final List mappings = new ArrayList<>(2);
public CompositeFileMapping(FileMapping a, FileMapping b) {
addMapping(a);
addMapping(b);
}
private void addMapping(FileMapping fm) {
if (fm instanceof CompositeFileMapping) {
mappings.addAll(((CompositeFileMapping) fm).mappings);
} else {
mappings.add(fm);
}
}
@Override
public IncludedPosition getIncludedPosition(Position line) {
for (FileMapping fm : mappings) {
IncludedPosition result = fm.getIncludedPosition(line);
if (result != null) {
return result;
}
}
return null;
}
@Override
public String toString() {
return mappings.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy