Skip to content

Commit

Permalink
Merge pull request #3568 from simonvonhackewitz/checkstyle
Browse files Browse the repository at this point in the history
cleanup: improve formatting in java files
  • Loading branch information
michaellilltokiwa committed Aug 16, 2024
2 parents 644ba0d + c9af7c6 commit 7406d7d
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 35 deletions.
3 changes: 2 additions & 1 deletion src/dev/flang/ast/FormalGenerics.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ public List<AbstractType> clone()
/**
* Check if this are the formal generics of f used as actuals.
*/
boolean actualsOf(AbstractFeature f) {
boolean actualsOf(AbstractFeature f)
{
return f.generics() == FormalGenerics.this;
}

Expand Down
3 changes: 2 additions & 1 deletion src/dev/flang/ast/Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public enum Kind
Of, // Syntactic sugar 'enum : choice of red, green, blue is', exists only during parsing
Native; // a native feature

public String toString(){
public String toString()
{
return switch(this)
{
case FieldInit : yield "field initialization";
Expand Down
7 changes: 4 additions & 3 deletions src/dev/flang/ast/UnresolvedType.java
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,8 @@ else if (tolerant && (o instanceof UnresolvedType ut))
var ot = outer();
if (ot != null && ot.isGenericArgument())
{
if (tolerant) {return null;}
else {AstErrors.formalGenericAsOuterType(pos(), this);}
if (tolerant) { return null; }
else { AstErrors.formalGenericAsOuterType(pos(), this); }
}

var mayBeFreeType = mayBeFreeType() && outer.isValueArgument();
Expand Down Expand Up @@ -755,7 +755,8 @@ static ResolvedType finishResolve(Resolution res,
boolean ignoreActualTypePars,
boolean tolerant)
{
if (tolerant) {unresolvedGenerics = new List<>();}
if (tolerant) { unresolvedGenerics = new List<>(); }

if (!ignoreActualTypePars)
{
if (refOrVal == RefOrVal.ThisType && generics.isEmpty())
Expand Down
3 changes: 2 additions & 1 deletion src/dev/flang/be/interpreter/Intrinsics.java
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@ Value get(
}

@Override
int length(){
int length()
{
return (int)size;
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/dev/flang/fe/LibraryType.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public abstract class LibraryType extends ResolvedType
*
* @param s the features that have already been found
*/
protected void usedFeatures(Set<AbstractFeature> s){
protected void usedFeatures(Set<AbstractFeature> s)
{
// a library type has already been checked. nothing to be done.
}

Expand Down
16 changes: 9 additions & 7 deletions src/dev/flang/tools/docs/Html.java
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,15 @@ private static String featureAbsoluteURL0(AbstractFeature f)
{
return "";
}
if (f.isTypeFeature()) {
return featureAbsoluteURL0(f.typeFeatureOrigin());
} else
{
String prefix = f.outer().isTypeFeature() ? "type." : "";
return featureAbsoluteURL0(f.outer()) + "/" + prefix + urlEncode(f.featureName().toString());
}
if (f.isTypeFeature())
{
return featureAbsoluteURL0(f.typeFeatureOrigin());
}
else
{
String prefix = f.outer().isTypeFeature() ? "type.": "";
return featureAbsoluteURL0(f.outer()) + "/" + prefix + urlEncode(f.featureName().toString());
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/dev/flang/util/ANY.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public class ANY
/**
* `class:method:line` of the condition that failed
*/
private static String origin(){
private static String origin()
{
var st = (new Throwable()).getStackTrace();
if (st.length < 3)
{
Expand Down
42 changes: 22 additions & 20 deletions src/dev/flang/util/SourcePosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,28 +222,30 @@ public String showInSource()
}
if (!Terminal.ENABLED)
{
for (int j=0; l == line() && j < column()-1; j++)
{
sb.append('-');
}
if (bytePos() == endPos)
{
sb.append('^');
} else
{
int len = str.length() - leadingWhiteSpace;
for (int i = 0; i < leadingWhiteSpace; i++)
{
sb.append('-');
}
for (int i = 0; i < len; i++)
{
sb.append('^');
}
for (int j = 0; l == line() && j < column() - 1; j++)
{
sb.append('-');
}
if (bytePos() == endPos)
{
sb.append('^');
}
else
{
int len = str.length() - leadingWhiteSpace;
for (int i = 0; i < leadingWhiteSpace; i++)
{
sb.append('-');
}
for (int i = 0; i < len; i++)
{
sb.append('^');
}
}
}
}
}
if (!Terminal.ENABLED && (p < _sourceFile.lineEndPos(l) || p == _bytePos || p == byteEndPos()-1) && p+1 < byteEndPos() && p+1 == _sourceFile.lineEndPos(l))
if (!Terminal.ENABLED && (p < _sourceFile.lineEndPos(l) || p == _bytePos || p == byteEndPos() - 1)
&& p + 1 < byteEndPos() && p + 1 == _sourceFile.lineEndPos(l))
{
sb.append("\n");
}
Expand Down

0 comments on commit 7406d7d

Please sign in to comment.