Showing 2 of 56 files from the diff.
Other files ignored by Codecov

@@ -13,9 +13,9 @@
Loading
13 13
import de.dlr.sc.overtarget.language.targetmodel.RepositoryLocation;
14 14
import de.dlr.sc.overtarget.language.targetmodel.TargetFile;
15 15
import de.dlr.sc.overtarget.language.targetmodel.TargetModel;
16 +
import de.dlr.sc.overtarget.language.util.TargetFileHandler;
16 17
import java.util.ArrayList;
17 18
import org.eclipse.core.resources.IFile;
18 -
import org.eclipse.core.resources.IProject;
19 19
import org.eclipse.emf.common.util.EList;
20 20
import org.eclipse.emf.ecore.util.EcoreUtil;
21 21
import org.eclipse.xtext.xbase.lib.CollectionExtensions;
@@ -26,7 +26,7 @@
Loading
26 26
 */
27 27
@SuppressWarnings("all")
28 28
public class ReferencedTargetHelper {
29 -
  public static final String TARGET_NAME = "targetForReferences";
29 +
  public static final String TARGET_FOR_REFERENCES_NAME = "targetForReferences";
30 30
  
31 31
  /**
32 32
   * This method copies the original tmodel and
@@ -59,7 +59,7 @@
Loading
59 59
  }
60 60
  
61 61
  public String renameTmodel(final TargetModel model) {
62 -
    final String renamedTmodel = ReferencedTargetHelper.TARGET_NAME;
62 +
    final String renamedTmodel = ReferencedTargetHelper.TARGET_FOR_REFERENCES_NAME;
63 63
    model.setName(renamedTmodel);
64 64
    return model.getName();
65 65
  }
@@ -89,52 +89,6 @@
Loading
89 89
    }
90 90
  }
91 91
  
92 -
  /**
93 -
   * In the project the targetFile is searched with the outputPath.
94 -
   * Checks if the targetFile is located directly in the project folder or in an extra folder.
95 -
   * 
96 -
   * @param file targetFile which is searched for
97 -
   * @param outputDirectory output directory of generated targetFile
98 -
   * @param fileName name of the tmodel/targetFile
99 -
   * @return targetFile
100 -
   */
101 -
  public IFile findTargetFileInProject(final IFile file, final String outputDirectory, final String fileName) {
102 -
    final IProject project = file.getProject();
103 -
    final String targetFileName = fileName.replace(".tmodel", OvertargetGenerator.TARGET_FILE_EXTENSION);
104 -
    final String outputPath = outputDirectory.toString().replaceFirst(".", "");
105 -
    boolean _equals = outputPath.equals("/");
106 -
    if (_equals) {
107 -
      final IFile targetFile = project.getFile(targetFileName);
108 -
      boolean _exists = targetFile.exists();
109 -
      if (_exists) {
110 -
        return targetFile;
111 -
      }
112 -
    } else {
113 -
      final String targetPath = (outputPath + targetFileName);
114 -
      final IFile targetFileWithFolder = project.getFile(targetPath);
115 -
      boolean _exists_1 = targetFileWithFolder.exists();
116 -
      if (_exists_1) {
117 -
        return targetFileWithFolder;
118 -
      }
119 -
    }
120 -
    return null;
121 -
  }
122 -
  
123 -
  /**
124 -
   * In the project the targetFile is searched with the outputPath.
125 -
   * Checks if the targetFile is located directly in the project folder or in an extra folder.
126 -
   * 
127 -
   * @param file targetFile which is searched for
128 -
   * @param outputDirectory output directory of generated targetFile
129 -
   * @return targetFile
130 -
   */
131 -
  public IFile findTargetFileInProject(final IFile file, final String outputDirectory) {
132 -
    String _name = file.getName();
133 -
    final String fileName = ("/" + _name);
134 -
    final String targetFileName = fileName.replace(".tmodel", OvertargetGenerator.TARGET_FILE_EXTENSION);
135 -
    return this.findTargetFileInProject(file, outputDirectory, targetFileName);
136 -
  }
137 -
  
138 92
  /**
139 93
   * In the project the targetForReferences file is searched with the outputPath.
140 94
   * Checks if the file is located directly in the project folder or in an extra folder.
@@ -144,7 +98,8 @@
Loading
144 98
   * @return targetForReferences
145 99
   */
146 100
  public IFile findTargetForReferencesFile(final IFile file, final String outputDirectory) {
147 -
    final String fileName = (("/" + ReferencedTargetHelper.TARGET_NAME) + OvertargetGenerator.TARGET_FILE_EXTENSION);
148 -
    return this.findTargetFileInProject(file, outputDirectory, fileName);
101 +
    final String fileName = (ReferencedTargetHelper.TARGET_FOR_REFERENCES_NAME + OvertargetGenerator.TARGET_FILE_EXTENSION);
102 +
    final TargetFileHandler targetFileHandler = new TargetFileHandler();
103 +
    return targetFileHandler.findTargetFile(file, outputDirectory, fileName);
149 104
  }
150 105
}

@@ -0,0 +1,88 @@
Loading
1 +
/**
2 +
 * Copyright (c) 2020 German Aerospace Center (DLR), Simulation and Software Technology, Germany.
3 +
 * 
4 +
 * This program and the accompanying materials are made available under the
5 +
 * terms of the Eclipse Public License 2.0 which is available at
6 +
 * http://www.eclipse.org/legal/epl-2.0.
7 +
 * 
8 +
 * SPDX-License-Identifier: EPL-2.0
9 +
 */
10 +
package de.dlr.sc.overtarget.language.util;
11 +
12 +
import de.dlr.sc.overtarget.language.generator.OvertargetGenerator;
13 +
import de.dlr.sc.overtarget.language.targetmodel.TargetModel;
14 +
import org.eclipse.core.resources.IFile;
15 +
import org.eclipse.core.resources.IProject;
16 +
import org.eclipse.emf.common.util.URI;
17 +
import org.eclipse.emf.ecore.EObject;
18 +
import org.eclipse.emf.ecore.resource.Resource;
19 +
import org.eclipse.emf.ecore.resource.ResourceSet;
20 +
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
21 +
import org.eclipse.xtext.xbase.lib.Exceptions;
22 +
import org.eclipse.xtext.xbase.lib.InputOutput;
23 +
24 +
/**
25 +
 * This class handles getting files, such as target resources (.tmodel) or targetFiles (.target).
26 +
 */
27 +
@SuppressWarnings("all")
28 +
public class TargetFileHandler {
29 +
  /**
30 +
   * This method gets a targetModel
31 +
   * 
32 +
   * @param file	target file (.target) located in a project
33 +
   * @param rs	resourceSet which can include tmodels, can be null
34 +
   * @return targetModel
35 +
   */
36 +
  public TargetModel getTargetModel(final IFile file, final ResourceSet rs) {
37 +
    final URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
38 +
    ResourceSet resourceSet = rs;
39 +
    if ((rs == null)) {
40 +
      ResourceSetImpl _resourceSetImpl = new ResourceSetImpl();
41 +
      resourceSet = _resourceSetImpl;
42 +
    }
43 +
    try {
44 +
      final Resource resource = resourceSet.getResource(uri, true);
45 +
      EObject _get = resource.getContents().get(0);
46 +
      final TargetModel targetModel = ((TargetModel) _get);
47 +
      return targetModel;
48 +
    } catch (final Throwable _t) {
49 +
      if (_t instanceof Exception) {
50 +
        InputOutput.<String>println("Tmodel file does not exist.");
51 +
        return null;
52 +
      } else {
53 +
        throw Exceptions.sneakyThrow(_t);
54 +
      }
55 +
    }
56 +
  }
57 +
  
58 +
  /**
59 +
   * In the project the targetFile is searched within the outputPath.
60 +
   * Checks if the targetFile is located directly in the project folder or in an extra folder.
61 +
   * 
62 +
   * @param file targetFile which is searched for
63 +
   * @param outputDirectory output directory of generated targetFile
64 +
   * @param fileName name of the tmodel/targetFile
65 +
   * @return targetFile
66 +
   */
67 +
  public IFile findTargetFile(final IFile file, final String outputDirectory, final String fileName) {
68 +
    final IProject project = file.getProject();
69 +
    final String targetFileName = fileName.replace(".tmodel", OvertargetGenerator.TARGET_FILE_EXTENSION);
70 +
    final String outputPath = outputDirectory.toString().replaceFirst(".", "");
71 +
    boolean _equals = outputPath.equals("/");
72 +
    if (_equals) {
73 +
      final IFile targetFile = project.getFile(targetFileName);
74 +
      boolean _exists = targetFile.exists();
75 +
      if (_exists) {
76 +
        return targetFile;
77 +
      }
78 +
    } else {
79 +
      final String targetPath = ((outputPath + "/") + targetFileName);
80 +
      final IFile targetFileWithFolder = project.getFile(targetPath);
81 +
      boolean _exists_1 = targetFileWithFolder.exists();
82 +
      if (_exists_1) {
83 +
        return targetFileWithFolder;
84 +
      }
85 +
    }
86 +
    return null;
87 +
  }
88 +
}
Files Complexity Coverage
de.dlr.sc.overtarget.language 73.12% 76.58%
Project Totals (20 files) 73.12% 76.58%
610.1
TRAVIS_OS_NAME=linux
openjdk8=

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading