-
Notifications
You must be signed in to change notification settings - Fork 316
/
PluginXmlAccess.java
126 lines (113 loc) · 3.71 KB
/
PluginXmlAccess.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.xtext.xtext.generator.model;
import com.google.inject.Inject;
import com.google.inject.Injector;
import java.util.List;
import java.util.Objects;
import org.apache.log4j.Logger;
import org.eclipse.xtend.lib.annotations.Accessors;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtend2.lib.StringConcatenationClient;
import org.eclipse.xtext.generator.IFileSystemAccess2;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Pure;
import org.eclipse.xtext.xtext.generator.CodeConfig;
import org.eclipse.xtext.xtext.generator.IGuiceAwareGeneratorComponent;
/**
* Configuration object for plugin.xml files for use in Eclipse.
*/
@Accessors
@SuppressWarnings("all")
public class PluginXmlAccess extends TextFileAccess implements IGuiceAwareGeneratorComponent {
private static final Logger LOG = Logger.getLogger(PluginXmlAccess.class);
@Inject
private CodeConfig codeConfig;
public PluginXmlAccess() {
this.setPath("plugin.xml");
}
private final List<CharSequence> entries = CollectionLiterals.<CharSequence>newArrayList();
@Override
public void setContent(final StringConcatenationClient content) {
throw new UnsupportedOperationException("cannot directly set contents on a plugin.xml. Use entries property instead");
}
@Override
public CharSequence getContent() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("<?xml version=\"1.0\" encoding=\"");
String _elvis = null;
String _encoding = this.codeConfig.getEncoding();
if (_encoding != null) {
_elvis = _encoding;
} else {
_elvis = "UTF-8";
}
_builder.append(_elvis);
_builder.append("\"?>");
_builder.newLineIfNotEmpty();
_builder.append("<?eclipse version=\"3.0\"?>");
_builder.newLine();
_builder.append("<plugin>");
_builder.newLine();
{
for(final CharSequence entry : this.entries) {
_builder.append("\t");
_builder.append(entry, "\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("</plugin>");
_builder.newLine();
return _builder;
}
/**
* Merge the contents of the given plugin.xml into this one.
*/
public boolean merge(final PluginXmlAccess other) {
boolean _xblockexpression = false;
{
String _path = this.getPath();
String _path_1 = other.getPath();
boolean _notEquals = (!Objects.equals(_path, _path_1));
if (_notEquals) {
String _path_2 = this.getPath();
String _plus = ("Merging plugin.xml files with different paths: " + _path_2);
String _plus_1 = (_plus + ", ");
String _path_3 = other.getPath();
String _plus_2 = (_plus_1 + _path_3);
PluginXmlAccess.LOG.warn(_plus_2);
}
_xblockexpression = this.entries.addAll(other.entries);
}
return _xblockexpression;
}
@Override
public void writeTo(final IFileSystemAccess2 fileSystemAccess) {
boolean _isEmpty = this.entries.isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
super.writeTo(fileSystemAccess);
}
}
@Override
public void initialize(final Injector injector) {
injector.injectMembers(this);
}
@Pure
public CodeConfig getCodeConfig() {
return this.codeConfig;
}
public void setCodeConfig(final CodeConfig codeConfig) {
this.codeConfig = codeConfig;
}
@Pure
public List<CharSequence> getEntries() {
return this.entries;
}
}