mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
Resolve unnecessary else warnings
Signed-off-by: Titouan Vervack <titouan.vervack@sigasi.com>
This commit is contained in:
parent
a911cd76bb
commit
4aed451630
4 changed files with 47 additions and 41 deletions
|
@ -216,10 +216,11 @@ public abstract class AbstractFormatter2 implements IFormatter2 {
|
|||
if (ruleName.startsWith("ML"))
|
||||
return new MultilineCommentReplacer(comment, '*');
|
||||
if (ruleName.startsWith("SL")) {
|
||||
if (comment.getLineRegions().get(0).getIndentation().getLength() > 0)
|
||||
if (comment.getLineRegions().get(0).getIndentation().getLength() > 0) {
|
||||
return new SinglelineDocCommentReplacer(comment, "//");
|
||||
else
|
||||
return new SinglelineCodeCommentReplacer(comment, "//");
|
||||
}
|
||||
|
||||
return new SinglelineCodeCommentReplacer(comment, "//");
|
||||
}
|
||||
}
|
||||
String elementName = new GrammarElementTitleSwitch().showQualified().showRule().doSwitch(grammarElement);
|
||||
|
|
|
@ -48,35 +48,36 @@ public abstract class AbstractHiddenRegion extends AbstractTextSegment implement
|
|||
List<IHiddenRegionPart> parts = getParts();
|
||||
if (parts.isEmpty()) {
|
||||
return Collections.<ITextSegment>singletonList(this);
|
||||
} else {
|
||||
ITextSegment lastWhitespace = null;
|
||||
List<ITextSegment> result = Lists.newArrayList();
|
||||
for (IHiddenRegionPart part : parts) {
|
||||
if (part instanceof IWhitespace) {
|
||||
if (lastWhitespace == null) {
|
||||
result.add(part);
|
||||
lastWhitespace = part;
|
||||
} else {
|
||||
int mergedLength = lastWhitespace.getLength() + part.getLength();
|
||||
lastWhitespace = new TextSegment(access, lastWhitespace.getOffset(), mergedLength);
|
||||
result.set(result.size() - 1, lastWhitespace);
|
||||
}
|
||||
} else if (part instanceof IComment) {
|
||||
if (lastWhitespace == null) {
|
||||
result.add(new TextSegment(access, part.getOffset(), 0));
|
||||
} else {
|
||||
lastWhitespace = null;
|
||||
}
|
||||
if (includeComments) {
|
||||
result.add(part);
|
||||
}
|
||||
}
|
||||
|
||||
ITextSegment lastWhitespace = null;
|
||||
List<ITextSegment> result = Lists.newArrayList();
|
||||
for (IHiddenRegionPart part : parts) {
|
||||
if (part instanceof IWhitespace) {
|
||||
if (lastWhitespace == null) {
|
||||
result.add(part);
|
||||
lastWhitespace = part;
|
||||
} else {
|
||||
int mergedLength = lastWhitespace.getLength() + part.getLength();
|
||||
lastWhitespace = new TextSegment(access, lastWhitespace.getOffset(), mergedLength);
|
||||
result.set(result.size() - 1, lastWhitespace);
|
||||
}
|
||||
} else if (part instanceof IComment) {
|
||||
if (lastWhitespace == null) {
|
||||
result.add(new TextSegment(access, part.getOffset(), 0));
|
||||
} else {
|
||||
lastWhitespace = null;
|
||||
}
|
||||
if (includeComments) {
|
||||
result.add(part);
|
||||
}
|
||||
}
|
||||
if (lastWhitespace == null) {
|
||||
result.add(new TextSegment(access, getEndOffset(), 0));
|
||||
}
|
||||
return ImmutableList.copyOf(result);
|
||||
}
|
||||
|
||||
if (lastWhitespace == null) {
|
||||
result.add(new TextSegment(access, getEndOffset(), 0));
|
||||
}
|
||||
return ImmutableList.copyOf(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -119,12 +120,13 @@ public abstract class AbstractHiddenRegion extends AbstractTextSegment implement
|
|||
@Override
|
||||
public int getOffset() {
|
||||
if (hiddens.isEmpty()) {
|
||||
if (previous != null)
|
||||
if (previous != null) {
|
||||
return previous.getOffset() + previous.getLength();
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return hiddens.get(0).getOffset();
|
||||
}
|
||||
|
||||
return hiddens.get(0).getOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -74,9 +74,9 @@ public abstract class AbstractFileSystemAccess implements IFileSystemAccess, IFi
|
|||
public String apply(OutputConfiguration from) {
|
||||
if (currentSource == null) {
|
||||
return from.getOutputDirectory();
|
||||
} else {
|
||||
return from.getOutputDirectory(currentSource);
|
||||
}
|
||||
|
||||
return from.getOutputDirectory(currentSource);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -119,10 +119,11 @@ public abstract class AbstractFileSystemAccess implements IFileSystemAccess, IFi
|
|||
* @since 2.3
|
||||
*/
|
||||
protected CharSequence postProcess(String fileName, String outputConfiguration, CharSequence content) {
|
||||
if (postProcessor != null)
|
||||
if (postProcessor != null) {
|
||||
return postProcessor.postProcess(getURI(fileName, outputConfiguration), content);
|
||||
else
|
||||
return content;
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,8 +132,9 @@ public abstract class AbstractFileSystemAccess implements IFileSystemAccess, IFi
|
|||
protected CharSequence postProcess(String fileName, String outputConfiguration, CharSequence content, String charset) {
|
||||
if (postProcessor instanceof IFilePostProcessorExtension) {
|
||||
return ((IFilePostProcessorExtension)postProcessor).postProcess(getURI(fileName, outputConfiguration), content, Charset.forName(charset));
|
||||
} else
|
||||
return postProcess(fileName, outputConfiguration, content);
|
||||
}
|
||||
|
||||
return postProcess(fileName, outputConfiguration, content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,8 +79,9 @@ public abstract class AbstractGenericModule implements Module {
|
|||
properties.load(in);
|
||||
Names.bindProperties(binder, properties);
|
||||
return properties;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue